[fpc-pascal] Free Pascal 2.4.0 released

Michael Van Canneyt michael at freepascal.org
Sun Jan 3 12:04:25 CET 2010



On Sun, 3 Jan 2010, Florian Klaempfl wrote:

> Peter W A Wood schrieb:
>>> Jonas Maebe wrote:
>>>> http://edn.embarcadero.com/article/33336
>>>>
>>>> Note that even Delphi doesn't have them yet ("it might also turn
>>>> up in Delphi in the future").
>>>>
>>> Looks as something related to:
>>> http://en.wikipedia.org/wiki/Anonymous_function#Delphi ? If so then
>>> this is already implemented in delphi.
>>
>> From my understanding, Delphi's so-called "Anonymous Functions" work
>> as closures - the inner function/procedure having access to the
>> variables of the outer function/procedure even if the outer function
>> has completed execution. Delphi's anonymous functions can have names
>> so they don't seem to be so anonymous. Anonymous functions were
>> implemented in Delphi 2009.
>>
>> Apparently, they are referred to as anonymous functions as the term
>> closures is used for something different in C++ Builder.
>
>
> I still don't get what's the real use of such constructs? I see only
> that it seems to encourage a hacky scripting language like coding style?

Or like Javascript. That one gives me a headache when just looking at it :(

I don't understand what is so bad about having to name a function ? 
OK, in C or languages where you have only 1 namespace this may require
some thinking.

But pascal has 'local' functions, so they don't pollute your namespace.
If coded in an object, it's just a private method if you want.
And if not that, you can code it in the implementation part of 
your unit. Plenty of possibilities, and you always have readable code.

Michael.



More information about the fpc-pascal mailing list