A little namespace "proposal"

Andreas Raab andreas.raab at gmx.de
Thu Apr 8 23:40:40 UTC 2004


Hi Richard,

>From my POV, "renaming classes elsewhere" is generally a no-no. You chose a
particularly good example for this, which precisely illustrates the problem
of "naively renaming" things. The name TDelay would cause *utter* confusion
as it is actually a name that is defined in Croquet (uh, ah!).

So when you do this, you suddenly have something that uses "TDelay" which
looks precisely like Croquet's TDelay - and you know, when you load Croquet
there will be only "a single class TDelay" in your image so anyone looking
at this almost certainly has to assume that it is Croquet::TDelay you mean.
And you won't be able to find any "other" TDelay when you do things like
"browse it" etc. The end result: Utter confusion and exactly the reason why
I hate the idea of giving "other classes new names". In such situation you
should either avoid the conflict or be explicit by qualifying it.

So my inclination is: No renaming, no aliases. If you can't avoid the
conflict then you have to qualify. At least it allows people to see where
this stuff really comes from.

Cheers,
  - Andreas

----- Original Message ----- 
From: "Richard Staehli" <rastaehli at mac.com>
To: <squeak-dev at lists.squeakfoundation.org>
Sent: Friday, April 09, 2004 1:21 AM
Subject: Re: A little namespace "proposal"


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