A little namespace "proposal"

Richard Staehli rastaehli at mac.com
Thu Apr 8 23:21:22 UTC 2004


Requiring that the source *always* have the qualified names is fine 
unless you plan to use namespaces a lot.  If namespaces are useful, and 
I assume we agree that they are, then our code becomes verbose, 
depending on the length of the namespace qualifier strings.  If the 
names for namespaces are not to conflict they must be allocated by some 
domain hierarchy like internet host names or via GUIDs (yuck).

Another solution to keep the code simple (without imports) is allow 
(optional) identifier alias declarations in the class definition (you 
can't compile without the class definition anyway).

An alias for a long namespace identifier can be used to make code 
easier to read.  An alias for a commonly used identifier can be 
declared to avoid having to fully qualify every occurrence.  The code 
appears just the way its author wrote it, although tools may still 
pretty print or even automatically expand aliases.

Adapting Göran's scenario:

1. There is only one Delay in the image, Delay.  (Resolve unqualified 
names to the default Smalltalk namespace.)

2. You edit class Foo::Bar and type "Delay". No need to look beyond the 
default namespace.

3. Tweak::Delay is created. No problem, the resolution of "Delay" in
Foo::Bar is unaffected.

4. You edit another method in class Foo::Bar and type "Tweak::Delay". 
Compiler resolves qualified name to Tweak version.

5. After many more references to "Tweak::Delay", you decide to simplify 
the source by adding alias declarations "TDelay -> Tweak::Delay" and 
"Smalltalk::Delay -> Delay" to the class definition.  This affects only 
the source of this class and the way the compiler translates global 
identifiers.  In the cases where it helps to abbreviate identifiers, 
this mechanism requires only that the reader check the class definition 
for alias translation.  A tool could automate this.

Rich



More information about the Squeak-dev mailing list