Lazarus

Free Pascal => FPC development => Topic started by: guest60499 on November 24, 2017, 08:29:33 am

Title: Anonymous Functions and Procedures
Post by: guest60499 on November 24, 2017, 08:29:33 am
Hello,

I know this has been discussed at some length, but I am interested in implementing this functionality (in part due to the availability of libraries such as OmniThreadLibrary (http://www.omnithreadlibrary.com/)).

The syntax is fairly well documented (e.g. the diagrams here (https://www.freepascal.org/docs-html/ref/refse60.html#x121-14300010.1)). Is there a code-oriented introduction to the parsing facilities? Is there a complete BNF-like description of the syntax?

Are there any code-generation concerns that would make this inordinately difficult?

Cheers,
     guest
Title: Re: Anonymous Functions and Procedures
Post by: Thaddy on November 24, 2017, 10:17:00 am
Well, take a look at codeblocks (in trunk) that is related but only available for MAC. There is work being done, however.
Title: Re: Anonymous Functions and Procedures
Post by: guest60499 on November 24, 2017, 09:12:48 pm
Well, take a look at codeblocks (in trunk) that is related but only available for MAC. There is work being done, however.
Do you mean the IDE Code::Blocks (http://www.codeblocks.org/)? If not and if you are referring to some structure that aids in emitting instructions - how is it OSX specific? Why should I be looking at this?

Looking at the code will obviously be necessary, but I need help finding my way around. That is why I asked the questions that I did.
Title: Re: Anonymous Functions and Procedures
Post by: Cyrax on November 24, 2017, 09:33:30 pm
Well, take a look at codeblocks (in trunk) that is related but only available for MAC. There is work being done, however.
Do you mean the IDE Code::Blocks (http://www.codeblocks.org/)? If not and if you are referring to some structure that aids in emitting instructions - how is it OSX specific? Why should I be looking at this?

Looking at the code will obviously be necessary, but I need help finding my way around. That is why I asked the questions that I did.

No, he means this: http://wiki.lazarus.freepascal.org/FPC_New_Features_Trunk#Support_for_interfacing_with_C_blocks_functionality
Title: Re: Anonymous Functions and Procedures
Post by: Thaddy on November 25, 2017, 09:41:35 am
Quote
No, he means this: http://wiki.lazarus.freepascal.org/FPC_New_Features_Trunk#Support_for_interfacing_with_C_blocks_functionality
Correct. Note the remarks indicate similar implementation on the compiler level.
Title: Re: Anonymous Functions and Procedures
Post by: guest60499 on November 25, 2017, 10:55:27 am
It doesn't look like anything has been accomplished, as that seems like normal Object Pascal code. Is the author claiming compatibility with some Apple-defined ABI? I don't see any syntax additions demonstrated.
Title: Re: Anonymous Functions and Procedures
Post by: Thaddy on November 25, 2017, 12:54:07 pm
I suggest a guide dog in your case
Title: Re: Anonymous Functions and Procedures
Post by: guest60499 on November 25, 2017, 08:56:49 pm
Well, I appreciate the suggestion, especially the page it was on. Sadly I don't think it is relevant. Even when it works (or if it is working) it seems very fragile and to rely too heavily on OSX features to be useful.

My questions about the parsing code are still open.
Title: Re: Anonymous Functions and Procedures
Post by: PascalDragon on December 13, 2017, 03:16:00 pm
Anonymous functions are already being worked on by a 3rd party developer and are in fact essentially finished. What's missing are him addressing the points we developers raised, writing tests for the compiler's testsuite (http://wiki.freepascal.org/Testing_FPC) and then us integrating the code into trunk.

If you want to help the author with writing tests you can find his mailing address in the related thread (http://lists.freepascal.org/pipermail/fpc-devel/2017-July/038101.html) on fpc-devel.
Title: Re: Anonymous Functions and Procedures
Post by: ahydra on December 30, 2017, 11:44:59 pm
This sounds wonderful. Is it limited to code with cdecl calling convention though? (if so, why?)
Title: Re: Anonymous Functions and Procedures
Post by: PascalDragon on January 02, 2018, 10:18:52 pm
This sounds wonderful. Is it limited to code with cdecl calling convention though? (if so, why?)
The C-blocks linked in one of the above posts are indeed cdecl only, cause they're for interfacing with corresponding code on Mac OS X and iOS which only deals with cdecl (though that's only important for i386) and also to differentiate the C-blocks from Delphi's anonymous functions which always use register calling convention (again only really important on i386 [and m68k]). The latter isn't implemented yet in trunked, but is still work in progress.
TinyPortal © 2005-2018