[Lazarus] Namespace

Hans-Peter Diettrich DrDiettrich1 at aol.com
Tue Jan 11 22:32:38 CET 2011


Andrew Brunner schrieb:

> ns is where I plan to put my "parent" namespace.  All other
> structs/consts/defaults/enums/ etc will be declared there and under
> children of ns (globals there and children have their own from that
> point on...).

You can apply that to your unit names as well.


> With namespaces - I can organize differing structs
> even classes within the same unit bypassing the circular reference
> issue.

This is not a feature of namespaces, it's a compiler feature. A Pascal 
(OPL) compiler could allow for circular unit references as well, at the 
cost of compilation time (eventually multiple passes are required).


> IMEO namespaces are something to get EXCITED about.

True, as long as a language has no other means of structuring code. But 
OPL already has a notion of namespaces, called "units" :-]

Namespaces instead are unrelated to source files, so that a compiler and 
linker has to know about all source files that contribute to every 
single namespace. Development systems try their best to hide this 
consequence, but they are not always successful. In fact .NET needs 
assembly references in the first place, so that it can know which source 
modules make up every assembly. Only from that catalogue it's possible 
to build the namespaces, by extracting the declarations from the 
assemblies. This additional namespace tree is not required in OPL, where 
unit names (and packages) already are unique and sufficient for 
disambiguation.

DoDi





More information about the Lazarus mailing list