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

Michael Fuchs freepascal at ypa-software.de
Wed Oct 19 09:31:58 CEST 2011


Am 18.10.2011 21:42, schrieb Sven Barth:
> For anonymous functions you can take a look at Embarcadero's Delphi help
> here:
> http://docwiki.embarcadero.com/RADStudio/en/Anonymous_Methods_in_Delphi

The Embarcadero style of anonymous functions does not satify me.

   myFunc := function(x, y: Integer): Integer
   begin
     Result := x + y;
   end;

This is not easier than writing:

   function Bla(x, y: Integer): Integer
   begin
     Result := x + y;
   end;

   myfunc := @Bla;


I would prefer a style like

   myfunc := @function(x, y: Integer): Integer Result := x + y;

But this makes it hard to read. Of course it would be nice to have 
anonymous functions or even lambdas (think about integrated languages 
like LinQ). But maybe Pascals strength of easy readable code gets lost.

Michael



More information about the fpc-pascal mailing list