Namespaces - what are they good for?

danielv at netvision.net.il danielv at netvision.net.il
Tue Apr 6 15:18:18 UTC 2004


I think Roel made a good point when he asked what Gorans proposal is
supposed to solve, though as Colin said earlier, I think it applies to
more than Gorans proposal.

I think we should decide how we want namespaces to affect Squeakers
first, then to decide how it should affect code.

I see two problems that namespaces are usually used to solve -
1. "When John Doe writes code, it shouldn't pollute the common
namespace"
2. "I am writing a piece of code that needs to look things up slightly
differently than usual in some places". Roel told me an example of this
need once, where he wanted to use an alternative version of Socket in
his code, without breaking the code that is already in the system and
depends on having the first version. If I understand Andreas' need well,
then most of it falls under this category. He wants user code to see 
different names. 

Now the java approach, and also the way modules are defined in Haskell
and VW IIRC, allows full control of both (read as - requires the programmer
to declare everything explicitly). I think that accepting problem 1 as a
universal problem almost automatically will lead to losing the "common
playground" feel of Smalltalk/Squeak libraries, which are wonderful,
IMO, because everything goes there, so reuse can happen even when not
planned. 

A more limited version of 1, call it 1', is "John Doe may want to name
part of his code in a way that doesn't pollute the public namespaces"
and then, under 2, he'd make look up in his code use the "hidden" code
anyway. IIUC this still covers the rest of Andreas need as he 
described it.

Are these the important problems? Are both equally important, or can 
we try out a partial (if its simpler) solution first?

If we agree that these are the problems we want to solve, then it
becomes interesting whether specific models allow us to do this, and
what tools would lead to the model being well used.

I think a good question about models is for what scopes do they allow
one to declare lookup strategies. Is it a PackageInfo? Is it a class? if
its a class, is namespace inherited? if not, are semantics of inherited
code different between a class and its subclasses? here we should keep
things simple, but we do need to think about the interactions...

Daniel



More information about the Squeak-dev mailing list