Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2014-07

Syntax choice (was: Blocks support)

5 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Dmitry Boyarintsev

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

Jonas Maebe wrote 29 lines
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 https://lists.sonic.net/mailman/listinfo/mac-pascal

Reply by email

Jonas Maebe
to Dmitry Boyarintsev
Dmitry Boyarintsev wrote
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).

I proposed to use "is block" because of the analogy with the already existing "is nested". Neither "block" nor "nested" was/is/would be a reserved word afterwards, just like many other words that have a special meaning in one context or another (look at compiler/tokens.pas; most tokens are not reserved words".

In general "reference to" seems like a poor choice made by Embarcadero (and FPC has to follow).

We don't have to (except in Delphi mode), but it's fine by me.

* 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".

It's also a similar concept (you have a pointer to something that describes a function), but it's incompatible and different so you need a different syntax. Any different syntax is fine, as far as I'm concerned.

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

"C-block" is fine by me.

Jonas

Reply by email

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

AFAIU, many keywords are not reserved, but recognized only due to their context. Hence somebody could have used "block" as a normal symbol. But "in block" is compatible with older code and recognizable to the compiler due to the reserved word "in".

--Michael

Reply by email

Dmitry Boyarintsev
to Jonas Maebe: I proposed to use "is block" because of the analogy with the already existing "is…
Jonas Maebe wrote 6 lines
I proposed to use "is block" because of the analogy with the already existing "is nested". Neither "block" nor "nested" was/is/would be a reserved word afterwards, just like many other words that have a special meaning in one context or another (look at compiler/tokens.pas; most tokens are not reserved words".

Yes, true. I should have not used "reserved" term but rather context special words.
And since "is nested" is there, it does make sense to propose "is block".

It's also a similar concept (you have a pointer to something that describes a function), but it's incompatible and different so you need a different syntax. Any different syntax is fine, as far as I'm concerned.

It's just my personal appeal to reuse as many of existing reserved/context words as possible. (In which case "is block" seems better to me, than "reference to"... just because its less typing, though too "block"-specific)

I'd think that as soon as the feature is added to the trunk, some other source parsing libraries (CodeTools, fpc-passrc) needs to be updated.

thanks,
Dmitry

Reply by email

Sven Barth
to Dmitry Boyarintsev

Am 21.07.2014 18:15 schrieb "Dmitry Boyarintsev" <

: On Sun, Jul 20, 2014 at 6:28 PM, Jonas Maebe
> > It's also a similar concept (you have a pointer to something that

describes a function), but it's incompatible and different so you need a different syntax. Any different syntax is fine, as far as I'm concerned.

It's just my personal appeal to reuse as many of existing

reserved/context words as possible. (In which case "is block" seems better to me, than "reference to"... just because its less typing, though too "block"-specific)

The point is that we'll need the "reference to" anyway for Delphi compatibility. Otherwise I agree that Pascal normally uses suffixes...

Regards,
Sven

Reply by email