[fpc-devel] Closures via interfaces
Sven Barth
pascaldragon at googlemail.com
Sun May 26 16:05:53 CEST 2013
On 26.05.2013 12:12, Vasiliy Kevroletin wrote:
> Hi all,
>
> About 2 months ago there was a big discussion about closures(thread
> "Delphi anonymous methods"). After this discussion I started work on
> Delhi-like closures for fpc. I am far from finish and current
> implementation is not perfect. But I already have positive results: it's
> possible to declare and use anonymous functions. After few changes
> closures will be able to capture variables. I created mantis#24481 to
> handle this work. Everyone who is interested in closures and good in
> compiler is welcome into mantis. I would be happy if someone looked into
> changes and said few words.
>
> I described details of proposed and partly implemented approach in
> mantis. This is Delphi's approach. Some people call it "closures via
> interfaces". In slightly modified way it will allow to capture variables
> by value (which was requested in previous discussion). I like this
> approach because it's simple: it doesn't require to change codegenerator
> or rtl. On the other hand for each closure it creates new interface. And
> almost for each closure it creates new class. As a result: space
> overhead because of virtual tables and rtti.
>
> My question to community is: what do you think about proposed
> implementation? Are there arguments for another approach?
Thank you for the update. I'm still looking at your changes, but one
thing I noticed: please adhere to the coding style used in the compiler
(look at pgenutil.pas for example). For example don't use "1 line
if-statements" (e.g. "if x then foo;"), but put the statement into a
seperate line.
I should have told you this before you started, but I've forgotten it :(
Regards,
Sven
More information about the fpc-devel
mailing list