Exporting Namespaces

J J azreal1977 at hotmail.com
Fri Feb 23 16:13:44 UTC 2007


>From: "Michael van der Gulik" <mikevdg at gmail.com>
>Reply-To: The general-purpose Squeak developers 
>list<squeak-dev at lists.squeakfoundation.org>
>To: "The general-purpose Squeak developers 
>list"<squeak-dev at 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




More information about the Squeak-dev mailing list