[fpc-devel] Syntax choice (was: Blocks support)

Dmitry Boyarintsev skalogryz.lists at gmail.com
Sun Jul 20 22:27:04 CEST 2014


Hello,

I was curious about the proposed syntax option, why "in block" rather than
just "block"? There's no "block" reserved word in FPC yet (unlike mentioned
earlier Oxygen).

In general "reference to" seems like a poor choice made by Embarcadero (and
FPC has to follow).
* using "in block" seems more reasonable and more consistent with pascal
"postfix" or "suffix" functions declarations in general.
* name "reference to" somewhat overlaps with "^" syntax. Which is also
named "reference to".

Is it planned to use explicit term "C-block" (or "Apple-block") for the
feature. To avoid conflicts with pascal declaration blocks
http://www.freepascal.org/docs-html/ref/refse98.html

thanks,
Dmitry


On Fri, Jul 18, 2014 at 5:20 AM, Jonas Maebe <jonas.maebe at elis.ugent.be>
wrote:

> On 16/07/14 14:12, Jonas Maebe wrote:
>
>  I've (locally, not yet in svn) implemented support for blocks in FPC (
>> http://en.wikipedia.org/wiki/Blocks_(C_language_extension) ).
>>
>
> I've now committed the initial implementation in the blocks branch on svn.
> As discussed on the fpc-devel list, the syntax has been changed to:
>
> type
>   NSArrayEnumeratorBlock = reference to procedure (obj: id; idx:
> NSUInteger; var stop: boolean); cdecl;
>
> The reason is that Delphi already introduced the "reference to" syntax for
> anonymous functions in Pascal. The extra "cdecl;" indicates that it's the
> C-variant of an anonymous function (i.e., a "block").
>
> Apart from supporting global routines, the current implementation also
> already supports assigning the address of a method of a Pascal class/object
> to a block variable (or passing it to a block parameter). Nested
> functions/procedures are not yet supported.
>
>
> Jonas
> _______________________________________________
> Mac-Pascal mailing list
> Mac-Pascal at lists.sonic.net
> https://lists.sonic.net/mailman/listinfo/mac-pascal
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20140720/c5a9edc5/attachment.html>


More information about the fpc-devel mailing list