Recent

Author Topic: Anonymous Functions and Procedures  (Read 9105 times)

guest60499

  • Guest
Anonymous Functions and Procedures
« 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).

The syntax is fairly well documented (e.g. the diagrams here). 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

Thaddy

  • Hero Member
  • *****
  • Posts: 14164
  • Probably until I exterminate Putin.
Re: Anonymous Functions and Procedures
« Reply #1 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.
Specialize a type, not a var.

guest60499

  • Guest
Re: Anonymous Functions and Procedures
« Reply #2 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? 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.

Cyrax

  • Hero Member
  • *****
  • Posts: 836
Re: Anonymous Functions and Procedures
« Reply #3 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? 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

Thaddy

  • Hero Member
  • *****
  • Posts: 14164
  • Probably until I exterminate Putin.
Re: Anonymous Functions and Procedures
« Reply #4 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.
« Last Edit: November 25, 2017, 09:43:10 am by Thaddy »
Specialize a type, not a var.

guest60499

  • Guest
Re: Anonymous Functions and Procedures
« Reply #5 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.

Thaddy

  • Hero Member
  • *****
  • Posts: 14164
  • Probably until I exterminate Putin.
Re: Anonymous Functions and Procedures
« Reply #6 on: November 25, 2017, 12:54:07 pm »
I suggest a guide dog in your case
Specialize a type, not a var.

guest60499

  • Guest
Re: Anonymous Functions and Procedures
« Reply #7 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.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5444
  • Compiler Developer
Re: Anonymous Functions and Procedures
« Reply #8 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 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 on fpc-devel.

ahydra

  • New Member
  • *
  • Posts: 19
Re: Anonymous Functions and Procedures
« Reply #9 on: December 30, 2017, 11:44:59 pm »
This sounds wonderful. Is it limited to code with cdecl calling convention though? (if so, why?)

PascalDragon

  • Hero Member
  • *****
  • Posts: 5444
  • Compiler Developer
Re: Anonymous Functions and Procedures
« Reply #10 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