Name spaces in Spoon

Michael Latta lattam at mac.com
Fri May 26 21:32:42 UTC 2006


Come to think of it : is already allowed in symbols, so this may be a
non-issue.  I would need to check the scanner code more directly.

What I strongly advise against is having short names be able to match long
names by virtue of being in a "context" that somehow "imports" or implicitly
qualifies names.  Down that road lies much unneeded confusion and
complexity.

Michael


-----Original Message-----
From: squeak-dev-bounces at lists.squeakfoundation.org
[mailto:squeak-dev-bounces at lists.squeakfoundation.org] On Behalf Of Michael
Latta
Sent: Friday, May 26, 2006 2:25 PM
To: 'The general-purpose Squeak developers list'
Subject: RE: Name spaces in Spoon

You can not treat :: as "just part of the name" as that conflicts with : as
a separator in keyword selectors, or would at least make the job of the
scanner much more difficult.  I do see the value in processing the :: at
compile time rather than doing a simple message send to a dictionary which
would do class name resolution at run-time.

It is not a huge syntax change, but since it has unique semantics I would
advise treating it as a syntax change rather than just adding characters to
the name space.  If you really want it to just be part of the name so that
all such names appear in the system dictionary then I would advise using a
character that is not already used in the language.  You could also simply
say that all names should have a prefix and solve it by convention.  That
would make a structured browser less reliable however, so some extra
metadata that separates the prefix from the proper name is warranted.

Maybe :: is not so bad, and should just be part of the name.  Or we could
just allow objects to be embedded in source code and we do not need class
names, literals, etc.

Michael



-----Original Message-----
From: squeak-dev-bounces at lists.squeakfoundation.org
[mailto:squeak-dev-bounces at lists.squeakfoundation.org] On Behalf Of
goran at krampe.se
Sent: Friday, May 26, 2006 12:58 PM
To: The general-purpose Squeak developers list
Subject: Re: Name spaces in Spoon

Hi!

"Alejandro F. Reimondo" <aleReimondo at smalltalking.net> wrote:
> Hi,
> 
> > > It was something like Prefix::ClassName and the point was that only
> > > one or two places in the image had to change to legalize that kind of
> > > name.
> > Yes, the patch to get a Squeak image to accept code using such global
> > names is very, very small.
> 
> What do you think about sending the name
>  as message...
>     MyGlobalContext::ThisClass
>  becomes:
>     MyGlobalContext ThisClass
>  the global context (aNameSpace, anEnvironment
>  or SystemDictionary)
>  can respond to the message returning the real
>  object (or via dnu build a method to return it)
> Using this "trick" we do not need new syntax
>  and the solution is solved as usual (sending messages).
> 
> bets,
> Ale.

Just wish to note that this approach was indeed tested IIRC in the
3.3modules code, and if my memory serves me right Dan proposed it - but
I am not sure. Personally I was hesitant at the time, and still is.

A few comments:

1. It would move the binding time to runtime instead of compile time (or
if you prefer to call it "code install"-time). I can probably imagine
both pros and cons with that. It is a big change.

2. In my personal opinion it is less readable than
MyGlobalContext::ThisClass. It blends into the rest of the code so that
the reference itself doesn't "stand out". It also deviates from the
"words beginning with capitals refer to classes (or globals)".

3. The :: solution actually does not "need new syntax". It just needs us
to allow $: in global names. Sure, you can call it a "syntax change" -
but it is very, very small.

regards, Göran





More information about the Squeak-dev mailing list