14.9.17 public

The Public keyword is used to declare a function globally in a unit. This is useful if the function should not be accessible from the unit file (i. e. another unit/program using the unit doesn’t see the function), but must be accessible from the object file. As an example:

Unit someunit;  
interface  
Function First : Real;  
Implementation  
Function First : Real;  
begin  
  First := 0;  
end;  
Function Second : Real; [Public];  
begin  
  Second := 1;  
end;  
end.

If another program or unit uses this unit, it will not be able to use the function Second, since it isn’t declared in the interface part. However, it will be possible to access the function Second at the assembly-language level, by using its mangled name (see the Programmer’s Guide).

The public modifier can also be followed by a name directive to specify the assembler name, as follows:

Unit someunit;  
interface  
Function First : Real;  
Implementation  
Function First : Real;  
begin  
  First := 0;  
end;  
Function Second : Real; Public name 'second';  
begin  
  Second := 1;  
end;  
end.

The assembler symbol as specified by the “public name” directive will be “second”, in all lowercase letters.