A little namespace "proposal"
lex at cc.gatech.edu
Thu Apr 15 16:27:44 UTC 2004
goran.krampe at bluefish.se wrote:
> Not wanting to sound like a parrot :) but again - why would we end up
> having to read fully qualified names? You may not be describing my
> proposal anymore (not sure) but if you *are* then the only reason for a
> fully qualified name to appear in the Tweak code would be if an object
> was referenced in a Tweak method that:
Yes, in the baseline "quick" proposal, with no additions, people will
frequently end up viewing fully qualified names.
Here's the scenario. Andreas writes a humongous blop of code called
Tweak which has its own namespace and which has a lot of collisions with
the rest of Squeak. Andreas files out his code and mails it to Alice.
Alice loads the code and tries to browse it.
That's it. Note that Alice has browsers with a different lookup context
than Andreas. Quite possibly Alice is using the default context that
Squeak ships with, because she is trusting her tools to have good
default settings. Whenever Alice views Tweak code, all the Tweak
references will have fully qualified names.
Now, there is an argument that this may be good. After all, it makes it
very clear what the individual variables are referring to. However, it
also makes the overall algorithm much harder to read. Further, the code
is definitely in a different form than the maintainer likes to view and
edit the code. Further yet, no matter what the default rendering is, a
confused user can always tell their tool to use full qualification if
they desire it.
On the flip side, suppose Alice is going to live wild and would like to
use Andreas's lookup context. I suspect this will be very common, just
as it's very common in text editing a C program to use the author's
indentation style regardless of how much you dislike it. How does Alice
get the appropriate lookup context? Does she have to go look on a Wiki
and then type it in by hand? What?
I don't know what the exact transfer mechanism should be. I suggest,
though, that we integrate lookup contexts into the code base in a way
that there is always an author-approved lookup context available, and we
adjust monticello and fileout etc. to transfer these contexts. Users do
not have to use them, but they will have them when desired. By default,
the author-specified context should be used.
> I would guess there are very, very few such objects (classes).
That is the current case, but I doubt the situation will stay like that
once namespaces are ubiquitous. And anyway, namespaces are there to be
used. If we truly decide that their usage will remain rare, then let's
leave them out altogether.
I expect they will get used, however. Just look at all the classes with
artificial prefixes on them such as RB or SM. All of these would be
better if namespaces were available.
> In my current vocabulary a Namespace is a named Dictionary with symbols
> as keys and objects as values. An "Andreas context" or what I
> subsequently called LookupContext is an object that is used by Compiler
> and Browser to both help resolving unqualified names when compiling
> Smalltalk code and to help rendering code in a suitable fashion.
Yes that is what I have meant. In the simplest incarnation, a lookup
context is simply a list of namespaces, but other things are possible.
More information about the Squeak-dev