Sign in Join

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

Mailing lists / fpc-devel / 2020-02

Public modifier: brackets or not?

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

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

Bart

Hi,

I'm a little confused.

From:
https://www.freepascal.org/docs-html/ref/refsu81.html

This page gives 2 examples.

Function Second : Real; [Public];
begin
  Second := 1;
end;

and

Function Second : Real; Public name ’second’;
begin
  Second := 1;
end;

In the first, Public is in brackets, in the second it is not.

However, this will compile also:

Function Second : Real; [Public name ’second’];
begin
  Second := 1;
end;

So, what is the correct syntax?

Bart

Reply by email

Mattias Gaertner
to Bart
Show quoted text 31 lines
Hi, I'm a little confused. From: https://www.freepascal.org/docs-html/ref/refsu81.html This page gives 2 examples. Function Second : Real; [Public]; begin Second := 1; end; and Function Second : Real; Public name ’second’; begin Second := 1; end; In the first, Public is in brackets, in the second it is not. However, this will compile also: Function Second : Real; [Public name ’second’]; begin Second := 1; end; So, what is the correct syntax?

The [] is the old syntax.
It bites attributes, so better not use it.

Mattias

Reply by email

Sven Barth
to Bart: I'm a little confused. From: https://www.freepascal.org/docs-html/ref/refsu81.html This…

Bart via fpc-devel schrieb am So., 23.
Feb. 2020, 16:35:

Show quoted text 9 lines
However, this will compile also: Function Second : Real; [Public name ’second’]; begin Second := 1; end; So, what is the correct syntax?

Both are correct. The brackets allow a comma separated list of directives. However as Mattias wrote this syntax conflicts with attributes and thus is disabled if modeswitch PrefixedAttributes is enabled.

Regards,
Sven

Reply by email