[fpc-pascal] What's a unit?

Marco van de Voort marcov at stack.nl
Tue Feb 19 14:53:13 CET 2013

In our previous episode, Mark Morgan Lloyd said:
> Does a unit- rather than something it contains- have any sort of 
> representation which is recognisably distinct from an object?

Maybe. But what it certain doesn't have is a runtime instance. unit is
mostly a compiletime concept, and the Delphi exceptions to that (mostly due to
package system) are not implemented.
> I've got a situation where if a library (.dll or .so) is opened under 
> program control it is represented by an object, with entry points 
> expressed as methods. Alternatively, if it's statically linked then it's 
> represented by a unit, with entry points represented by procedures and 
> functions. That allows me to write things like

No, that does not exist to my best knowledge. Delphi might have ways
for packages, but that is also shaky (and target dependent) at best. 

The only way is to define a record with procedure variables for the static
case manually I guess. 

More information about the fpc-pascal mailing list