[fpc-pascal] fpc procedure modifier []

Sven Barth pascaldragon at googlemail.com
Thu Nov 16 20:02:22 CET 2017

On 16.11.2017 15:10, Mattias Gaertner wrote:
> On Thu, 16 Nov 2017 14:12:18 +0100
> Sven Barth via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
>> [...]
>> So, how will FPC distinguish the two []?
>> The only idea I have is to check whether the first identifier is a
>> attribute and if not handle it as a modifier (or if a comma is following
>> the first identifier).
> pparser can't do that.
> And I fear that this heuristic will lead to confusing error messages. I
> hope there is a better way.
> Delphi does not support it. It thinks it is an undefined attribute. So
> IMO FPC's [] modifier should be disabled in mode delphi+delphiunicode.
> So the problem will only happen in mode objfpc or when the user
> enable the modeswitch prefixedattributes.
> Maybe pparser can use a heuristic. What is the syntax and keywords of
> fpc's [] modifier?

Keywords are all supported modifiers.

"[" <MODIFIER> [,<MODIFIER>[,...]] "]"

And this can be mixed and matched with non-bracketed modifiers, so the
following is valid:

=== code begin ===

procedure Bla; cdecl; [public, overload]; iocheck;

=== code end ===

> If it is correct that FPC's modifier was never documented and is
> hardly used, perhaps a $modeswitch procmodifierbrackets can be
> added?

It is at least not totally undocumented:

It's a feature that FPC supports and thus there are probably users out
there that use it no matter whether it's in Delphi mode or not.


More information about the fpc-pascal mailing list