[fpc-devel] Question about Syntax: I there a reason for this design?

Boian Mitov mitov at mitov.com
Sun Sep 21 18:43:15 CEST 2014


I used to think the same way, until I actually started to use anonymous 
methods, and I realized what a full I used to be.
The simplest difference is that you can return anonymous method as a result 
of your function and it will preserve all the captured context.
Local methods can't do that.
Furthermore local methods will not work when passed as parameter to another 
thread, as they lose context when the owner function exits.
You can watch my session on CodeRage last year explaining most of that, and 
I will be doing some sessions this year on multithreading, and parallel 
processing where even more will be shown both at ITDevCon and hopefully 
CodeRage.

With best regards,
Boian Mitov

-------------------------------------------------------
Mitov Software
www.mitov.com
-------------------------------------------------------
-----Original Message----- 
From: Jonas Maebe
Sent: Sunday, September 21, 2014 3:13 AM
To: FPC developers' list
Subject: Re: [fpc-devel] Question about Syntax: I there a reason for this 
design?

On 21/09/14 08:10, Samuel Herzog wrote:
As you observed, anonymous methods and nested routines are essentially
identical other than the syntax, and I agree the latter generally also
result in better readable code.  Therefore I'm still inclined to
implement it somehow (at least for C-blocks, as already partially
implemented in http://svn.freepascal.org/svn/fpc/branches/blocks/),
because it seems a shame not to use an existing, perfectly suited
language construct and instead force everyone to use a new one.




More information about the fpc-devel mailing list