[fpc-devel] for-in-index loop

Sven Barth pascaldragon at googlemail.com
Mon Jan 28 15:58:34 CET 2013


Am 28.01.2013 14:39, schrieb Paul Ishenin:
>
>>> I would use anonymouse methods in pascal - I use them in javascript
>>> when I need to perform something asynchronosly.
>>
>> Since you can do the same with simple named methods too, I see no need
>> for creating the readibility horror that results of it.
>
> It is a readability horror when for injecting a small piece of code as 
> anonymouse method in place where it is needed you *must* declare a new 
> named method (which will no be used anywhere else) few screens up or 
> down.

I agree here. Also think about e.g. Synchronize. You must create a 
parameterless method + fields for each method you want to execute in the 
main thread. Here I definitely prefer anonymous methods.  And an also 
important aspect of them is that they can "capture" variable state from 
outside it's body. You can't do the exact same with nested procedures...

Regards,
Sven



More information about the fpc-devel mailing list