Public: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | 1 | Back to [[Reserved words]]. | |
| 2 | 2 | ||
| 3 | 3 | The modifier **public**: | |
| 4 | 4 | ||
| 5 | 5 | - is part of the programming of subroutines; | |
| 6 | 6 | - makes a subroutine public within the unit; | |
| 7 | 7 | - makes sense if the subroutine is not used outside the unit. | |
| 8 | 8 | ||
| 9 | 9 | As long as the subroutine has not been declared in the interface section of the unit, it is not visible to other units.\ | |
| 10 | 10 | However, it will be possible to access the function subTest at the assembly-language level, by using its mangled name. | |
| 11 | 11 | ||
| 12 | 12 | ``` pascal | |
| 13 | 13 | function subTest : string; Public; | |
| 14 | 14 | begin | |
| 15 | 15 | subTest := 'abc'; | |
| 16 | 16 | end; | |
| 17 | 17 | ``` | |
| 18 | 18 | ||
| 19 | 19 | 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.\ | |
| 20 | - | ||
| 20 | + | ||
| 21 | 21 | The public modifier can also be followed by a name directive to specify the assembler name, as follows: | |
| 22 | 22 | ||
| 23 | 23 | ``` pascal | |
| 24 | 24 | function subTest : string; Public name 'subtest'; | |
| 25 | 25 | begin | |
| 26 | 26 | subTest := 'abc'; | |
| 27 | 27 | end; | |
| 28 | 28 | ``` | |
| 29 | 29 | ||
| 30 | 30 | The assembler symbol as specified by the ’public name’ directive will be ’subtest’, in all lowercase letters. | |
| 31 | 31 | ||
| 32 | 32 | --- | |
| 33 | 33 | *From the Free Pascal wiki, page "Public", as it stood on 2022-08-06 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* |
