On Tue, Jul 6, 2010 at 9:22 AM, Michael Van Canneyt
<mich...@freepascal.org> wrote:
>
>
> On Tue, 6 Jul 2010, Graeme Geldenhuys wrote:
>
>> On 5 July 2010 23:17, Michael Van Canneyt wrote:
>>>
>>> I would even add to this that you need to guard for exceptions:
>>>
>>> A:=TSomeClass.Create;
>>> try
>>>  // do stuff
>>> finally
>>>  A.Free; Make sure it is freed, even in case of exception.
>>> end;
>>
>>
>> Wouldn't it be nice if we had a try..except..finally statement
>> supported in FPC. All-in-one.
>>
>> eg:
>>
>> A := TSomeClass.Create;
>> try
>>  // do stuff
>> except
>>  // handle error
>> finally
>>  A.Free; //  it is freed, even in case of exception.
>> end;
>>
>>
>> This would save such a lot of typing and indentation.
>
> In this particular case you don't need the finally at all.
> If you catch the exception, code will execute normally after the except
> block. You don't need the finally then.

It depends what will do in "except/end" block...


Marcos Douglas
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to