Namespaces code for 3.9

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Namespaces code for 3.9

Göran Krampe
Hi people!

All those interested in namespaces might want to know that I made my
code work in 3.9:

        http://map.squeak.org/packagebyname/namespaces

It needs people playing, reading, testing etc. It is very simple to use,
test it by installing from SM and start playing like this:

1. Create Foo::One, Foo::Two, Bar::Two, Zoo::Three. Note the slightly
different class template. These namespaces are totally independent of
the class category. Print these:
        Namespace spaces
        Foo == (Smalltalk at: #Foo)
        (Foo at: #One) == Foo::One

2. Add a method in Zoo::Three that accesses "One". It should work fine
and not ask any questions. It should accept and render as only "One"
even though the fully qualified name is "Foo::One". So as long as you
have short names (without the prefix) that are still unique in your
image you should not need to write or read the prefix.

3. Then create a method in Zoo::Three that mentions "Two" - you should
get a question about which
one you mean and it should auto expand to the fully qualified
(=prefixed) name. Also, if you type "Two" in a workspace - you should
get a question.

4. Add a method in Foo::One that references "Two". It should not ask,
because the default policy is that references to "local" names (names
existing in the same namespace as the class you are writing methods in)
resolve to the local name, even if there are other "Two"s in the image.
But this is just a tools thing - we could even have a Preference about
this.

5. Also PLEASE READ class comments of Namespace and LookupContext!


All tools should hopefully work fine with this code and if you don't use
Namespaces this code should NOT affect you (but if it does in some way
that is probably a bug) and the only problems I am aware of (off the top
of my head) are:

- Empty Namespaces are not currently removed automatically. You need to
do it manually (as the class comment describes).

- Browsing code is a bit slower because the browser needs to parse the
code to "render" it with short names. If we use Shout more and more this
could be included in Shout which I think is quite fast.

- The versions browser (versions of methods) and probably a few other
like a changes list etc - typically the tools showing code that is not
compiled - do not do the rendering bit and thus always shows fully
qualified names.

- A few things should be turned into Preferences I guess. Like if the
class template should be just like before, if short local names resolve
without questions etc.

I am writing a meticulous description of this code and will publish that
as an article later on - but typically not until late june. But IMHO the
code is easy (and relatively small) to understand. I have written about
it in the past, like here for example:

        http://swiki.krampe.se/gohu/32

regards, Göran