Name spaces in Spoon

goran at goran at
Fri May 26 21:24:43 UTC 2006


"Ralph Johnson" <johnson at> wrote:
> I've been continuing to think about the problem.  I said earlier today
> that Göran was missing the fact that Spoon allows two or more classes
> to have the same name, and Craig Latta said that was one of its
> features.  But then I realized that perhaps Göran thought that was a
> bug, not a feature, and that he wanted all classes in a module to have
> the module name as a prefix.  In that case, two classes would never
> have the same name.

Well, I can't say that I am passing any criticism on Spoon - I know too
little about it - I am merely presenting my approach as a different way
of dealing with these issues.

But yes, in my approach a class name is "Blabla::Blupp" or just "Blupp".
Obviously those two names are not the same. Nor is "Blibli::Blupp".

Two classes could still end up with the same name if:

1. You don't use a Blabla:: prefix.
2. You end up using the same prefix (namespace) as someone else.

There are ways to solve these situations too - like remapping names on
import, or having a prefix registry somewhere to minimize #2.

> If all classes in a module had the module name as a prefix then we
> couldn't say "Set", we'd have to say something like ANSI::Set (because
> it is a class from the ANSI standard).

But if you play with my code you realize that the tools "render" the
class names short - if the short name is unique in your image - which it
most surely is. Net effect: Almost always short names.

Same goes for typing them.

>  The rename refactoring would
> fix all the old code to use the new name, but converting old code
> would still be a bit of a pain.

No, not really - because you don't *have to* put classes under prefixes!
So old code works just fine.

> -Ralph Johnson

regards, Göran

More information about the Squeak-dev mailing list