A little namespace "proposal"

goran.krampe at bluefish.se goran.krampe at bluefish.se
Wed Apr 7 10:00:00 UTC 2004


Hi!

Michael van der Gulik <squeakml at gulik.co.nz> wrote:
> Hello everybody.
> 
> Wow.. that became a big thread quickly.

Discussing namespaces is a guaranteed hit. :)
 
> goran.krampe at bluefish.se wrote:
> > 
> > Primary values I have sought to fulfill:
> > 
> > - Simplicity (for example, there are no "imports")
> 
> Are "imports" not simple?

Nope. Not IMHO. 

> > - Making it work "optimistically"
> > - Somewhat backwards compatible in the meaning that most things will
> > "work just like now".
> 
> You mean that it's also disposable and intended as a temporary measure, 
> for when somebody else comes along with a more thorough proposal?

Well, you said it wasn't rude. :) No, it is not intended as a temporary
measure.
It is meant to be a "thorough" proposal. IMHO thorough ~= complex.

> > - When creating a class in a class category the template would look
> > like:
> > 
> > 	Object subclass: #NameOfSubclass
> > 		instanceVariableNames: ''
> > 		classVariableNames: ''
> > 		poolDictionaries: ''
> > 		category: 'Kernel-Processes'
> > 		namespace: 'Kernel'
> 
> I like the namespace: part. But we already have a "category" - why can't 
> we re-use that instead?

Well, currently PackageInfo relies on categories for packaging. And
packaging could probably be something we want to do across namespaces.

> > ...thus autopicking the PI-first part of the category, or perhaps like
> > this:
> > 
> > 	Object subclass: #Kernel::NameOfSubclass
> > 		instanceVariableNames: ''
> > 		classVariableNames: ''
> > 		poolDictionaries: ''
> > 		category: 'Kernel-Processes'
> > 
> > ...whichever we like the best.
> 
> Umm...
> 
> Something subclass: #Namespace
> 	instanceVariableNames: 'myClasses importedNamespaces '
> 	classVariableNames: ''
> 	poolDictionaries: ''
> 	category: 'Kernel(?)'
> 	importedNamespaces: 'Kernel Collections Morphic Globals'
> 	" myClasses are a list of classes in this Namespace.
> 	  importedNamespaces is a list of other namespaces imported into this 
> one. "
> 
> and
> 
> Object>>namespace
> 	^ self class getNamespace.
> 
> So then you can do:
> 
> self namespace importNamespace: #AnotherNamespace
> 
> at runtime, or put them in the importedNamespaces list at.. er.. 
> compile-time.
> 
> Instead of saying ANamespace::AClass in code, you could do the (uglier):
> 
> c := self namespace getClass: #ClassName fromNamespace: #ANamespace.
> bob := c new.
> 
> or is that too ugly? It's wordy, but it "feels" right. All the existing 
> classes could be put into a "Smalltalk" namespace until they've been 
> sorted into their own namespaces. If a class name is not present in the 
> importedNamespaces list, then IMO that class shouldn't be accessable.
> 
> Smalltalk is a nice simple language. Please don't change it's syntax if 
> you don't need to!

Eh... and what you proposed was simple? :) :)

> I also think that modifications made to an external Namespace from a 
> "current" Namespace (e.g. adding yet another obscure method to String 
> that's only used by you) should be visible only from the Namespace from 
> which it was made. I.e. the "MikesStuff" namespace might add a 

Nah, don't agree. The "things look differently from different views" is
IMHO a dangerous road to take. Really. Monticello has IMHO a great
balance to that. It allows class extensions, but we aren't talking
method namespaces etc.

> "asChewingGum" method on String, but it can only be seen and used from 
> the "MikesStuff" Namespace and no other. Don't ask me how though... 
> perhaps ClassBoxes do this?
> 
> Mikevdg.

regards, Göran



More information about the Squeak-dev mailing list