A lightweight namespace "proposal"

Peter van Rooijen peter at vanrooijen.com
Thu Apr 22 16:11:56 UTC 2004


goran.krampe at bluefish.se wrote:
> Peter van Rooijen <peter at vanrooijen.com> wrote:
> 
>>1) How to treat the already unique set of class names in the images as 
>>they are, without namespaces?
> 
> I think that many of the classes in the current Basic image should still
> be in Smalltalk - the root space you talk about.

Yes and no. I talked about "the root namespace", but I did not call it 
Smalltalk. I agree with you inasfar that expressions like Smalltalk at: 
#Set should still work. Whether the value of the name #Smalltalk in code 
in the root namespace should be the root namespace itself is a question 
I didn't address. I believe it doesn't matter as long as the Smalltalk 
at: forms still work as expected and the other calls to Smalltalk keep 
having the expected effect, so that old code is not hurt by having 
namespaces. The joys of encapsulation through message sending :-).

> Not *all* though - we still have a lot of stuff in the Basic image that
> really should be separate packages and thus probably have their own
> namespace, or at least not be in Smalltalk.

Yes, I basically agree with that. Since all the class names currently 
are already unique, they *could* all be in the same namespace without 
causing problems. But there are undoubtedly many names that have been 
disambiguated artificially (with prefixes or by using synonyms), and 
they could benefit from being in another namespace. This can be done in 
steps/phases, at moments of convenience.

By the way, I have been talking about the "root namespace" (because I 
assumed it would sound familiar), but at the same time I have advocated 
not having a namespace *hierarchy*, but one root namespace and many 
non-root namespaces. Therefore, the adjective "root" is not really 
intention-revealing.

I would suggest using this terminolgy: there is one "system namespace", 
and then there are many "user namespaces". This is also correctly 
suggestive of intention as using a namespace implies a responsibility to 
avoid duplicate short names, and this must be done by the humans who are 
the users of the Squeak programming system.

Short name duplication in the system namespace is avoided by the system 
maintainers, as usual.

The system namespace in my lightweight namespaces proposal would have no 
name. This means that if we need to refer to it by name anyway, we would 
use the empty string. This gives complete consistency in the syntax, 
with ::Set meaning the class with the short name Set in the system 
namespace.

Referring to the system namespace by name would not be something one 
needs very often. One instance would be when have a package that is in a 
user namespace, and you want a particular class in that package to be in 
the system namespace. This is still something you want, but you won't 
need it for most code, because most of the time it will be just right 
for the code for a class in a particular package to be in the namespace 
of that package.

Cheers,

Peter



More information about the Squeak-dev mailing list