The traditional Smalltalk approach to namespaces is to have the root of the object graph be a SystemDictionary that holds a reference to itself in the key #'Smalltalk'. When compiling methods, globals (including classes) are looked up in this single dictionary.
In GemStone namespaces are supported by the use of a list of dictionaries which are searched at compile time for a name. The root of the object graph is AllUsers--an instance of UserProfileSet which holds instances of UserProfile. Each UserProfile holds a reference to a SymbolList, a subclass of Array that holds instances of SymbolDictionary. When you compile a method you supply an instance of SymbolList that will be used to look up globals (including classes). The SymbolList can be your default, the default for another user, or one that you created on the fly with specific dictionaries you want to be visible (in a particular order).
You can have the same key in multiple dictionaries, each having different values. If you want to get to the value in a different dictionary, then you navigate to that dictionary:
((AllUsers userWithId: 'DataCurator') symbolList objectNamed: 'Globals') at: #'Array'.
With GemStone you can have an image in which Swazoo, Hyper, KomHttpServer, Monticello, Seaside, etc., are all present (each was loaded and compiled so that it references its own classes and prerequisites). A user can have visibility to a variety of packages but the packages need not have visibility to each other.
James
-----Original Message----- From: squeak-dev-bounces@lists.squeakfoundation.org [mailto:squeak-dev- bounces@lists.squeakfoundation.org] On Behalf Of J J Sent: Friday, February 23, 2007 8:14 AM To: squeak-dev@lists.squeakfoundation.org Subject: Re: Exporting Namespaces
From: "Michael van der Gulik" mikevdg@gmail.com Reply-To: The general-purpose Squeak developers listsqueak-dev@lists.squeakfoundation.org To: "The general-purpose Squeak developers list"squeak-dev@lists.squeakfoundation.org Subject: Re: Exporting Namespaces Date: Wed, 21 Feb 2007 10:05:30 +1300
What would you suggest? I could use any non-whitespace character, I
think.
Currently I'm using dots:
a := Collections.Arrayed.Array new: 5.
I guess I could live with that if the guys who write the parser can. :)
Usually though you'd just use:
a := Array new: 5.
and add the Collections.Arrayed Namespace to your import list. Each
import
list is common to all classes at a certain branch of the Namespace hierarchy, so the dotted notation is only useful if, in the same branch
of
the Namespace hierarchy, you want to use two classes (or global vars)
that
have the same name.
When you say "global vars" you mean classes right?
And how does the import work? This is one thing I am concerned about: In python, your "unit of work" is a file. So you look at the top and see the imports and you know they are valid for *this file" (or if you import in a local scope it extends to the end of that scope). In smalltalk the compiled "unit of work" is a method, no? My import/export list is going to have to be in the class definition right?
I know these are things that can be overcome with the tools (maybe show the fully qualified class on mouseover), but it is just something to think about. Oh, and if a base class imports a bunch of stuff does a derived class get it too, or do I have to specify the same imports over and over? I suppose you could have a default import (e.g. Core.*), package imports and class imports.
I'm not entirely sure how I'd implement your message sending idea, and it doesn't particularly feel "right" to me. I assume you mean:
a := Collections Arrayed Array new: 5.
Michael.
No, actually my favorite so far was from (I believe) Gemstone. As I recall, it was something like:
((Collections at: #Arrayed) at: #Array) new: 5.
Well, something much nicer looking then that I think. And as you said, you don't normally have to do this. But the advantage (to me) of having it be done with a message send syntax is that imports and the like could be done with that as well, thereby making it easier to do method level imports without having to resort to pragmas or something.
Find a local pizza place, movie theater, and more..then map the best route! http://maps.live.com/?icid=hmtag1&FORM=MGAC01