Namespaces
Bert Freudenberg
bert at impara.de
Sat Apr 3 23:58:17 UTC 2004
Am 03.04.2004 um 11:28 schrieb stéphane ducasse:
> The choice of andreas was how to support namespaces without impacting
> the scope of the
> user with unnecessary symbols and preserving as much as possible as
> the current environment.
> (I was driving late yesterday and I tried to understand what I wanted
> to say in my idiot post). But the
> price is that you have somehowe explicit namespace or scope access. So
> as a user I may see that there are namespace and refer to symbol
> outside the world. (for me doing that what was I called programmer
> audience vs a scripter would not have to worry or have the possibility
> to use the :: operator).
Hmm, the funny thing about Andreas' approach seems to be that :: is no
operator at all. It's simply part of the class name. So class Bar in
namespace Foo just has the name #Foo::Bar. Indeed, "::" is a great
choice here because colons can already be part of literal symbols.
In a sense, it's TSTTCPW. You already can define a class named Foo::Bar
today (try it!). A little scanner modification makes Foo::Bar get
recognized as one word. This lets you refer to the class directly
(today you'd have to write "Smalltalk at: #Foo::Bar").
So without any "namespace support" I can define and use a class named
"Foo::Bar". All current tools should continue to work. What the
namespace support then adds is not much more than allowing you to use
the short name "Bar" for "Foo::Bar" if you are inside the "Foo"
namespace.
I must admit I like the simplicity of this approach a lot. And since it
is so unintrusive, it should minimize conflict with more sophisticated
techniques like classboxes.
- Bert -
More information about the Squeak-dev
mailing list
|