Difference between revisions of "Public"
(English translation of German page) |
|||
(3 intermediate revisions by one other user not shown) | |||
Line 11: | Line 11: | ||
* makes sense if the subroutine is not used outside the unit. | * makes sense if the subroutine is not used outside the unit. | ||
− | As long as the subroutine has not been declared in the interface section of the unit, it is not visible to other units. | + | As long as the subroutine has not been declared in the interface section of the unit, it is not visible to other units.<br> |
+ | However, it will be possible to access the function subTest at the assembly-language level, by using its mangled name. | ||
<syntaxhighlight lang=pascal> | <syntaxhighlight lang=pascal> | ||
− | function subTest : string; | + | function subTest : string; Public; |
begin | begin | ||
subTest := 'abc'; | subTest := 'abc'; | ||
end; | end; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
+ | In the old syntax, the modifier <syntaxhighlight lang="pascal" inline>Public</syntaxhighlight> was surrounded by square brackets: '''[Public]''', but the | ||
+ | upcoming atrributes syntax uses square brackets as well, so better not to use them for this modifier. | ||
+ | <br> | ||
+ | <br> | ||
+ | The public modifier can also be followed by a name directive to specify the assembler name, as follows: | ||
+ | <syntaxhighlight lang=pascal> | ||
+ | function subTest : string; Public name 'subtest'; | ||
+ | begin | ||
+ | subTest := 'abc'; | ||
+ | end; | ||
+ | </syntaxhighlight> | ||
+ | The assembler symbol as specified by the ’public name’ directive will be ’subtest’, in all lowercase letters. |
Latest revision as of 17:18, 6 August 2022
│
Deutsch (de) │
English (en) │
Back to Reserved words.
The modifier public:
- is part of the programming of subroutines;
- makes a subroutine public within the unit;
- makes sense if the subroutine is not used outside the unit.
As long as the subroutine has not been declared in the interface section of the unit, it is not visible to other units.
However, it will be possible to access the function subTest at the assembly-language level, by using its mangled name.
function subTest : string; Public;
begin
subTest := 'abc';
end;
In the old syntax, the modifier Public
was surrounded by square brackets: [Public], but the
upcoming atrributes syntax uses square brackets as well, so better not to use them for this modifier.
The public modifier can also be followed by a name directive to specify the assembler name, as follows:
function subTest : string; Public name 'subtest';
begin
subTest := 'abc';
end;
The assembler symbol as specified by the ’public name’ directive will be ’subtest’, in all lowercase letters.