fpc procedure modifier []

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

fpc procedure modifier []

Mattias Gaertner
Hi,

Where can I find some information about the [] procedure modifier of
FPC?
For example:

procedure fpc_check_object(_vmt : pointer);
[public,alias:'FPC_CHECK_OBJECT'];  compilerproc;

What $modes support this?
The reason I ask is I'm trying to distinguish them from Delphi
Attributes in pparser.

Btw, 'compilerproc' is not listed here:
https://www.freepascal.org/docs-html/ref/refse97.html#x187-20900014.10

Mattias
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpc procedure modifier []

Maciej Izak
2017-11-16 11:39 GMT+01:00 Mattias Gaertner <[hidden email]>:
What $modes support this?
The reason I ask is I'm trying to distinguish them from Delphi
Attributes in pparser.

for Delphi like attributes FPC will have new modeswitch "prefixedattributes" . The implicit usage for $prefixedattributes  in DELPHI/DELPHIUNICODE mode is not decided yet (but IMO this is probable scenario).

--
Best regards,
Maciej Izak

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpc procedure modifier []

Mattias Gaertner
On Thu, 16 Nov 2017 11:49:59 +0100
Maciej Izak <[hidden email]> wrote:

> 2017-11-16 11:39 GMT+01:00 Mattias Gaertner <[hidden email]>:
>
> > What $modes support this?
> > The reason I ask is I'm trying to distinguish them from Delphi
> > Attributes in pparser.
> >  
>
> for Delphi like attributes FPC will have new modeswitch "prefixedattributes" .
> The implicit usage for $prefixedattributes  in DELPHI/DELPHIUNICODE mode is
> not decided yet (but IMO this is probable scenario).

Good to know. Thanks.

So, how will FPC distinguish the two []?

Mattias
 
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpc procedure modifier []

Free Pascal - General mailing list
Am 16.11.2017 14:01 schrieb "Mattias Gaertner" <[hidden email]>:
On Thu, 16 Nov 2017 11:49:59 +0100
Maciej Izak <[hidden email]> wrote:

> 2017-11-16 11:39 GMT+01:00 Mattias Gaertner <[hidden email]>:
>
> > What $modes support this?
> > The reason I ask is I'm trying to distinguish them from Delphi
> > Attributes in pparser.
> >
>
> for Delphi like attributes FPC will have new modeswitch "prefixedattributes" .
> The implicit usage for $prefixedattributes  in DELPHI/DELPHIUNICODE mode is
> not decided yet (but IMO this is probable scenario).

Good to know. Thanks.

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). 

Regards, 
Sven

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpc procedure modifier []

Maciej Izak
In reply to this post by Mattias Gaertner
2017-11-16 14:01 GMT+01:00 Mattias Gaertner <[hidden email]>:
Good to know. Thanks.

So, how will FPC distinguish the two []?

for now the idea is very simple: for active prefixedattributes "procedure modifier []" will be inaccessible (which means breaking for backward compatibility). This is the reason why $prefixedattributes in DELPHI/DELPHIUNICODE may be not enabled by default. In Delphi mode "procedure modifier []" is used very rare (if ever?) so I see no real problem (even if the problem exist can be simple eliminated by switching off prefixedattributes).

anyway maybe is possible to use both "[]" at the same time, but that need to be checked.
 
--
Best regards,
Maciej Izak

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpc procedure modifier []

Mattias Gaertner
In reply to this post by Free Pascal - General mailing list
On Thu, 16 Nov 2017 14:12:18 +0100
Sven Barth via fpc-pascal <[hidden email]> 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?

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

Mattias
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpc procedure modifier []

Michael Van Canneyt


On Thu, 16 Nov 2017, Mattias Gaertner wrote:

> On Thu, 16 Nov 2017 14:12:18 +0100
> Sven Barth via fpc-pascal <[hidden email]> 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.

I think that prefixedattributes should simply disable the use of proc
modifier []. The probability of having code that needs both is almost zero,
the [] syntax is very old and almost not used.

Mode Delphi(Unicode) enables prefixedattributes, all other modes need an
explicit modeswitch to enable it.

Let's keep it clear, simple and unambiguous.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpc procedure modifier []

Maciej Izak
2017-11-16 15:21 GMT+01:00 Michael Van Canneyt <[hidden email]>:
I think that prefixedattributes should simply disable the use of proc
modifier []. The probability of having code that needs both is almost zero,
the [] syntax is very old and almost not used.

Mode Delphi(Unicode) enables prefixedattributes, all other modes need an
explicit modeswitch to enable it.

Let's keep it clear, simple and unambiguous.

+1 . so I think that we have clear situation.

--
Best regards,
Maciej Izak

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpc procedure modifier []

Free Pascal - General mailing list
In reply to this post by Mattias Gaertner
On 16.11.2017 15:10, Mattias Gaertner wrote:

> On Thu, 16 Nov 2017 14:12:18 +0100
> Sven Barth via fpc-pascal <[hidden email]> 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;
begin
end;

=== 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:
https://www.freepascal.org/docs-html/current/ref/refsu81.html#x199-22100014.10.12

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.

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpc procedure modifier []

Free Pascal - General mailing list
In reply to this post by Free Pascal - General mailing list
On 16.11.2017 14:12, Sven Barth wrote:

> Am 16.11.2017 14:01 schrieb "Mattias Gaertner"
> <[hidden email] <mailto:[hidden email]>>:
>
>     On Thu, 16 Nov 2017 11:49:59 +0100
>     Maciej Izak <[hidden email] <mailto:[hidden email]>> wrote:
>
>     > 2017-11-16 11:39 GMT+01:00 Mattias Gaertner
>     <[hidden email] <mailto:[hidden email]>>:
>     >
>     > > What $modes support this?
>     > > The reason I ask is I'm trying to distinguish them from Delphi
>     > > Attributes in pparser.
>     > >
>     >
>     > for Delphi like attributes FPC will have new modeswitch
>     "prefixedattributes" .
>     > The implicit usage for $prefixedattributes  in
>     DELPHI/DELPHIUNICODE mode is
>     > not decided yet (but IMO this is probable scenario).
>
>     Good to know. Thanks.
>
>     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). 

One other point to differentiate them: the modifier one always ends with
a semicolon after the closing bracket, Delphi's attributes never do that.

Regards,
Sven

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpc procedure modifier []

Maciej Izak


2017-11-16 20:17 GMT+01:00 Sven Barth via fpc-pascal <[hidden email]>:
One other point to differentiate them: the modifier one always ends with
a semicolon after the closing bracket, Delphi's attributes never do that.

sadly this is not true at all :(

see:


in above example it works without semicolon without any problems 

--
Best regards,
Maciej Izak

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpc procedure modifier []

Free Pascal - General mailing list
On 16.11.2017 20:25, Maciej Izak wrote:

>
>
> 2017-11-16 20:17 GMT+01:00 Sven Barth via fpc-pascal
> <[hidden email] <mailto:[hidden email]>>:
>
>     One other point to differentiate them: the modifier one always ends with
>     a semicolon after the closing bracket, Delphi's attributes never do
>     that.
>
>
> sadly this is not true at all :(
>
> see:
>
> https://svn.freepascal.org/cgi-bin/viewvc.cgi?view=revision&revision=35000
>
> in above example it works without semicolon without any problems 

Okay, that might be true in the middle of the modifier list, but not if
it's the last one:

=== code begin ===

unit tprocmod;

interface

procedure Bla; cdecl; [public, overload]

var
  test: LongInt;

implementation

procedure Bla;
begin
end;


end.

=== code end ===

This results in "Syntax error, ";" expected but "VAR" found".

In how far that can be used to handle the modifiers and attributes
together in parallel needs to be seen...

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fpc procedure modifier []

Mattias Gaertner
In reply to this post by Maciej Izak
On Thu, 16 Nov 2017 15:25:55 +0100
Maciej Izak <[hidden email]> wrote:

> 2017-11-16 15:21 GMT+01:00 Michael Van Canneyt <[hidden email]>:
>
> > I think that prefixedattributes should simply disable the use of proc
> > modifier []. The probability of having code that needs both is almost zero,
> > the [] syntax is very old and almost not used.
> >
> > Mode Delphi(Unicode) enables prefixedattributes, all other modes need an
> > explicit modeswitch to enable it.
> >
> > Let's keep it clear, simple and unambiguous.  

I like clear, simple and unambiguous.

 
> +1 . so I think that we have clear situation.


Mattias
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal