Name spaces in Spoon

Volker Nitsch volker.nitsch at
Sat May 27 09:36:23 UTC 2006

On 5/26/06, goran at <goran at> wrote:
> Hi!
> "Alejandro F. Reimondo" <aleReimondo at> wrote:
> > Hi,
> >
> > > > It was something like Prefix::ClassName and the point was that only
> > > > one or two places in the image had to change to legalize that kind of
> > > > name.
> > > Yes, the patch to get a Squeak image to accept code using such global
> > > names is very, very small.
> >
> > What do you think about sending the name
> >  as message...
> >     MyGlobalContext::ThisClass
> >  becomes:
> >     MyGlobalContext ThisClass
> >  the global context (aNameSpace, anEnvironment
> >  or SystemDictionary)
> >  can respond to the message returning the real
> >  object (or via dnu build a method to return it)
> > Using this "trick" we do not need new syntax
> >  and the solution is solved as usual (sending messages).
> >
> > bets,
> > Ale.
> Just wish to note that this approach was indeed tested IIRC in the
> 3.3modules code, and if my memory serves me right Dan proposed it - but
> I am not sure. Personally I was hesitant at the time, and still is.
> A few comments:
> 1. It would move the binding time to runtime instead of compile time (or
> if you prefer to call it "code install"-time). I can probably imagine
> both pros and cons with that. It is a big change.
> 2. In my personal opinion it is less readable than
> MyGlobalContext::ThisClass. It blends into the rest of the code so that
> the reference itself doesn't "stand out". It also deviates from the
> "words beginning with capitals refer to classes (or globals)".
> 3. The :: solution actually does not "need new syntax". It just needs us
> to allow $: in global names. Sure, you can call it a "syntax change" -
> but it is very, very small.

What i like with java is classloaders. Java does not know where the
classes are. Instead each class has an classloader and java uses that
classloader to get a handle to the code for a classname. At
compile-time (actually load-time). So that classloader is kind of an
active namespace.
How about doing something similar for a starter? The compiler passes
names to  an user-hook and the hook passes back such a handle? Or an
"expanded" classname.
One way to use that is, use very long classnames globally,
MyGlobalContextHasThisClass, inside code use MThisClass and let that
hook translate.
Allow some more syntax, so people who like MyGobalContext::ThisClass
could do it. Write some real code in your favorite style. Better base
for discussions.

That translator could be stored by categories, a category in the
browser would show its naming-rules.

For refactoring there could be the other way around too. Then for
refactor-tools a method is first expanded to long names, refactored,
and abbreviated by the categories rules. Current tools still work.

> regards, Göran


"Any problem in computer science can be solved with another layer of
indirection. But that usually will create another problem." David

More information about the Squeak-dev mailing list