[fpc-pascal] Re: Delphi's anonymous functions in Free Pascal

michael.vancanneyt at wisa.be michael.vancanneyt at wisa.be
Thu Aug 30 09:09:49 CEST 2012



On Wed, 29 Aug 2012, Arioch wrote:

>
> Florian Klämpfl wrote
>>
>>
>>>> This is the prototypical way to run a function over each element in a
>>>> collection, returning the results.
>>> (map (lambda (x) (+ x 1)) '(1 2 3))
>>> -> (2 3 4)
>>
>> I still don't see why this cannot be done by procedure variables: one
>> can easily pass a procedure reference to a compare function to any sort
>> library call.
>>
>
> Sorry for resurrecting al thread, but p[erhaps better to keep things
> together.
> 1) "anonymous methods" in Delphi are made in very Pascalish way, a lot of
> wording, a lot of boilerplate.
> That adds to readability, but makes their use much harder. If you have
> relatively complex 4-5 lines function, then the overhead is slightly
> noticeable. But such functions are a borderline to me, having them anonymous
> hampers both ease of read and ease of debug. I know C++ fans how say that
> begin/end are awfully long. Well, Delphi style of anonymous functions would
> frighten them even more.

I don't think anonymous functions should be added to the compiler at all.

They are IMHO a negation of what pascal stands for. If your programming
style is so strange that you need lamba functions or anonymous functions,
then Pascal is simply not for you.

Michael.


More information about the fpc-pascal mailing list