[fpc-devel] Delphi anonymous methods

Michael Fuchs freepascal at ypa-software.de
Mon Mar 4 09:01:21 CET 2013


Am 04.03.2013 01:15, schrieb Graeme Geldenhuys:
 > [...]
> It was clearly stated in the past that FPC will not support the C/C++
> language feature of declaration a variable in-line inside code blocks,
> but only in var sections.
>
> Example of not allowed code:
>
>    for i: integer = 0 to 10 do
>    begin
>    end;
 > [...]
> From what I can see, anonymous methods are just like the above code...

No, inside declaration is not anonymous, the declared var has a name.

Look at this:

   with TObject.Create do begin
     WriteLn(ToString);
     Free;
   end;

That is anonymous, and it works in Object-Pascal.

On the other hand I am not sure if anonymous are a good idea, even if I 
like them while working in VB.NET.
But please: if they are coming, don't implement them in the bad way of 
Delphi.

Michael



More information about the fpc-devel mailing list