[fpc-devel] Delphi anonymous methods

Sven Barth pascaldragon at googlemail.com
Sat Mar 2 22:56:00 CET 2013


On 02.03.2013 21:25, ListMember wrote:
> On 2013-03-02 21:55, Sven Barth wrote:
>> - (in context with the above point) couple the support for the
>> anonymous functions to a new modeswitch (enabled by default in mode
>> delphi), but allow "reference to" procvars in non-Delphi modes (this
>> way you'd only be able to use nested functions, but later on the
>> shorter syntax should be used there as well)
>
> This paragraph went way over my head.
>
> But, it sort of reminded me to ask about something else:
>
> Are anonymous methods (going to be) compatible with event methods?
>
> i.e. are they 'procedure of object' (or 'function of object') kind of
> constructs.
>
> The reason I am asking this is: There have been times when I could kill
> to be able to assign (temporarily) a local procedure/function an
> object's event (say, OnClick) so that I could capture the event's
> outcome right in there wthin the body of the active routine.
>
> Would this be possible?

In theory one could extend the "reference to" procvars to handle normal 
methods as well. But then the event handler would need to be defined as 
a "reference to" procvar as well instead of an "of object" one. An "of 
object" procvar on the other hand is too fixed. Only the new procvar 
type introduced together with anonymous functions would be flexible 
enough so that it could be used as a replacement for all other procvars 
(if implemented correctly in the compiler).

Regards,
Sven



More information about the fpc-devel mailing list