On 13.02.2013 09:58, Mark Morgan Lloyd wrote:
Michael Müller wrote:

I'm not sure if somebody else mentioned this already but I have the
feeling that Giuliano thinks that he has to decide to use try-finally
OR try-except but there are situations where you need both. One of the
criteria is if the object is local or global since for a global object
it is likely that you place the .Free (or for a global object better
FreeAndNil()) into a destructor or finalization section (which means
that you have to stop the program in case of an error and not continue
showing just a dialog) so you'll need only the try-except if you want
to catch the exception. In case of a local object you'll ALWAYS have
the lines

Obj := Class.Create;
try
  try
    // do some code
  finally
    Obj.Free;
  end;
except
  writeln('We have a problem);
  halt the program or reraise the exception or raise a new one
end;

I tried to make that point but I'm not sure the message reached its mark.

It's possibly unfortunate that Borland chose to use "try" for both
constructs, rather than having distinct try-except-end and
start-finally-end forms.


Other languages did the same, so I don't see the problem here...

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to