Quick comparison of two Namespaces proposals

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
82 messages Options
12345
Reply | Threaded
Open this post in threaded view
|

Re: Quick comparison of two Namespaces proposals

Jason Johnson-5
On 9/17/07, Göran Krampe <[hidden email]> wrote:
>
> - I personally think hierarchical namespaces is "too much". I opted for
> single level namespaces and still think that is enough.

But this is a slippery slope.  Afterall, flat wasn't enough, why
should we think 1 level would be enough forever?

> - Imports are done in your code "per Namespace" which is immensely better
> than like for example in Java where it is per class (well, per file, but
> anyway). It is still though the major difference with my proposal in which
> there are *no* explicit imports at all.

Well, the issue I have with your proposal is it isn't really a
Namespace/Package proposal, it's simply a proposal to always add your
prefixes with a ::, and add some tool support to deal with it.

In my opinion Namespaces are a complicated subject and using such a
simple method to deal with them is just sweeping the problem under the
rug for someone else.

I try to make my own solutions as simple as possible, but no simpler.
Personally, I think that if we need namespaces now there are good
examples to follow:  Lisp, Python, possibly Haskell all have good
Namespace/Package systems we could emulate.

> - I agree that shared pools theoretically could be replaced with
> Namespaces, but then we actually have imports *per class*, which I really
> don't like. You may argue, "but we already have them!" - yes, I agree, but
> I don't like them anyway and in my proposal I opted out by simply
> ignoring/not touching them. :)

What is the problem with shared pools?  That they're a kind of global
variable?  I haven't used them much myself, but personally I would
prefer a good argument for getting rid of them since the creators of
Smalltalk seem to think they were useful.

> - Your Namespaces are linked to a Package scheme, I personally would like
> to keep these concepts separate.

>From Lisp or Python terms "Namespace" and "Package" are synominous.  I
think you are talking about Package as in "an MC package", no?  That
is a package as well, but it's from a different namespace. :)  In
regards to language I don't think there is much difference between the
two except that people tend to call their thing "Namespace" if it's
extremely simple (e.g. C++'s solution) and package if it's more
complete.

> - You go hierarchical, I stayed simple and kept it on one level.

I think this is fundamentally a hierarchical issue.

> - You added an explicit import list per Namespace, I opted to not have
> imports at all.

For a complete system imports are required unless you want to be
typing the whole path out everytime, which is what we have right now
(i.e. no need to add a bunch of stuff to just end up where we are now)

Reply | Threaded
Open this post in threaded view
|

Re: Quick comparison of two Namespaces proposals

Jason Johnson-5
In reply to this post by Bert Freudenberg
On 9/18/07, Bert Freudenberg <[hidden email]> wrote:

>
> > Oh no, are people really so strongly for ::?
>
> I'm rather strongly against ".". And not only because the dot is
> already too overloaded in Smalltalk.
>
> Dot-notation is becoming ubiquitous in "pop CS" to the point where
> people don't even admit there are alternatives. In one German state
> teaching "dot notation" to kids is made mandatory by the school
> administration, ruling out the use of Smalltalk as a teaching
> language. I kid you not.
>
> Having it creep into Squeak would make this individual sad. If this
> means anything to anybody ;)
>
> - Bert -

Well it does. :)  Personally I'm not so sold on '.', I just hate to
see <insert barage of hideous languages>'s :: come to Smalltalk as
well.

I don't think the dot is an option anyway given the obvious reasons
which have already been covered.

What do you think of message syntax for this?  I think it could be
done at compile time as well, since the compiler is determining the
reciever of a message anyway.

Reply | Threaded
Open this post in threaded view
|

Re: Quick comparison of two Namespaces proposals

Jason Johnson-5
In reply to this post by Igor Stasenko
Well this is quite an interesting proposal in itself, though I would
say this is above and beyond what we need for namespaces at the moment
(given we currently have none at all).  This seems like something that
may prove itself to be the way to go in the future.  I'm interested to
see how it turns out.

On 9/17/07, Igor Stasenko <[hidden email]> wrote:

> On 17/09/2007, Göran Krampe <[hidden email]> wrote:
> > Hi folks!
> >
> > I just read through Michael van der Gulik's page:
> >
> > http://gulik.pbwiki.com/Namespaces
> >
> > Just stumbled over it btw, and I have only read it once and wrote down
> > some notes compared to my own little "venture" in this area:
> >
> > http://swiki.krampe.se/gohu/32
> >
> > Which I like to call "Prefixes Improved" perhaps. Anyway, here goes and
> > this is mainly addressed to Michael btw.
> >
> > Namespace comments:
> >
> > - I personally think hierarchical namespaces is "too much". I opted for
> > single level namespaces and still think that is enough.
> >
> > - I personally don't like the "." notation for namespaces, especially
> > since we already use "." for statement separation. I still think "::" is
> > the best I have seen, although granted - this is a tiny, tiny detail.
> >
> > - Imports are done in your code "per Namespace" which is immensely better
> > than like for example in Java where it is per class (well, per file, but
> > anyway). It is still though the major difference with my proposal in which
> > there are *no* explicit imports at all.
> >
> > - I agree that shared pools theoretically could be replaced with
> > Namespaces, but then we actually have imports *per class*, which I really
> > don't like. You may argue, "but we already have them!" - yes, I agree, but
> > I don't like them anyway and in my proposal I opted out by simply
> > ignoring/not touching them. :)
> >
> > - Your Namespaces are linked to a Package scheme, I personally would like
> > to keep these concepts separate.
> >
> > So... to sum it all up:
> >
> > - You also bind at compile time just like globals are bound now (and just
> > as in my code). No difference.
> > - You also reify the namespaces as instances of Namespace, as I do. No
> > difference, though you intend to nuke SystemDictionary - I don't.
> > - You also have a Dictionary protocol on the Namespaces enabling normal
> > dynamic lookup just as I have. Kinda normal if you reify them as objects
> > of course.
> >
> > But...
> >
> > - You go hierarchical, I stayed simple and kept it on one level.
> > - You use ".", I use "::".
> > - Your code use *both* qualified names (long with dot-notation) and non
> > qualified names (short), I *always* use qualified names in the source and
> > only let the tools "render" them short (or accept writing them short) when
> > they are indeed unique or when the user has a policy that allows a lookup
> > - like for example resolving by default to "local names" (in the same
> > Namespace).
> > - You added an explicit import list per Namespace, I opted to not have
> > imports at all.
> > - You coupled Namespaces with Packages, I did not at all go there.
> >
> > So the big differences are the two last ones - Explicit import lists vs my
> > approach of no-imports-render-and-accept-short-names and mixing it with a
> > package concept vs not doing that. :)
> >
> > regards, Göran
> >
> >
>
> It was me, who proposed Michael van der Gulik's to add package dependencies.
> Besides Namespaces, keeping package dependencies is important thing to
> make single image holding every known package in squeak universe (by
> universe i mean all known forks, which currently forced to keep own
> separated development branches and cannot be used with single image
> due to many conflicts).
> With package hierarchies, you can have image working with different
> forks, and even interoperate them.
>
> The idea was to keep own namespace(i.e. - globals and behaviors) for
> each package,  and also keep a list of imported packages.
> Only single package should not have any imports - its a Kernel package.
> Any others have at least Kernel in imports.
> Now, how things going on:
> suppose you making own package and want to modify some classes/methods
> in package(s) you import.
> When you making changes, they going not to imported package, but in
> your package instead. This is much likely you adding an extensions
> with MC (adding category *MyPackage extensions to foreign class), but
> in much more clever way :)
>
> Keeping your changed behaviors and names in own package prevents from
> creating version conflicts with other packages which using old
> behaviors/classes. Your changes are visible only to your package or
> any other packages which importing yours. This is most important
> feature, which allows us to make different versions of tools to live
> in same image and coexist without conflicts.
>
> There of course must be a good tools to support development in such
> environment. Since any changes you making must go to some package
> (like with changesets), developer must always know to which package
> he's doing changes.
> - for any package in system, which haves at least a single export
> (imported by another package, or marked as a 'release' package), you
> are unable to modify it contents. Instead, you must keep changes with
> other package - either by creating a new version of it, or by adding
> changes to your own package, which make use of it.
>
> An update operation is pretty simple. Suppose i maintainer of package
> X, which currently imports packages Y 1.0  and Z 1.0. Now i want to
> update my package to use Y 2.0 and Z 3.0.
>
> I simply clicking 'update imports', and creating a new separate
> version of my package with replaced imports. Now i can run tests/debug
> e.t.c. When i considered that all is fine, now i can set it as default
> 'release' version and publish it.
>
> The overall idea is simple: make your code available/visible only to
> those who wants to use it (by imports). So, you don't need to harvest
> entire image to find out source of problem, and  you will never fear
> installing updates , because they are unable to make existing code
> nonfunctional.
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>
>
>
>

Reply | Threaded
Open this post in threaded view
|

RE: Quick comparison of two Namespaces proposals

Ramon Leon-5
In reply to this post by Jason Johnson-5
> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On
> Behalf Of Jason Johnson
> Sent: Tuesday, September 18, 2007 9:10 AM
> To: [hidden email]; The general-purpose Squeak developers list
> Subject: Re: Quick comparison of two Namespaces proposals
>
> Oh no, are people really so strongly for ::?  It make source
> code look absolutely awful.  The period looks a thousand
> times better, but I don't think there is a non-ambiguous way to do it.
>

Maybe you should look at Gorans proposal first.  In general, :: would
separate the prefix from the class name in such a way that the tools can
hide Kernel:: except when there's ambiguity, or in file outs.  Formalizing
prefixes that we all currently do by convention anyway while keeping the
simplicity of a single global namespace and avoiding the need for imports.
It's actually a nice proposal and :: doesn't look bad at all, since you'll
hardly ever see it.

Ramon Leon


Reply | Threaded
Open this post in threaded view
|

Re: Quick comparison of two Namespaces proposals

Jason Johnson-5
I've looked at the proposal, and you will see it.  Today you wouldn't
because there are no namespaces and thus no conflicts.

I agree we need namespaces, I just think we can do better, both in
looks and in functionality.  It's nothing against Goeran, just as I
told him, I think his Delta's thing is right on the money.  I just
think this is really going to "give us only enough rope...."

On 9/18/07, Ramon Leon <[hidden email]> wrote:

> > -----Original Message-----
> > From: [hidden email]
> > [mailto:[hidden email]] On
> > Behalf Of Jason Johnson
> > Sent: Tuesday, September 18, 2007 9:10 AM
> > To: [hidden email]; The general-purpose Squeak developers list
> > Subject: Re: Quick comparison of two Namespaces proposals
> >
> > Oh no, are people really so strongly for ::?  It make source
> > code look absolutely awful.  The period looks a thousand
> > times better, but I don't think there is a non-ambiguous way to do it.
> >
>
> Maybe you should look at Gorans proposal first.  In general, :: would
> separate the prefix from the class name in such a way that the tools can
> hide Kernel:: except when there's ambiguity, or in file outs.  Formalizing
> prefixes that we all currently do by convention anyway while keeping the
> simplicity of a single global namespace and avoiding the need for imports.
> It's actually a nice proposal and :: doesn't look bad at all, since you'll
> hardly ever see it.
>
> Ramon Leon
>
>
>

Reply | Threaded
Open this post in threaded view
|

RE: Quick comparison of two Namespaces proposals

Ramon Leon-5
> I've looked at the proposal, and you will see it.  Today you
> wouldn't because there are no namespaces and thus no conflicts.
>
> I agree we need namespaces, I just think we can do better,

That's the thing, not everyone agrees about needing them, which in the past
has made adding them a losing battle.

> both in looks and in functionality.  It's nothing against
> Goeran, just as I told him, I think his Delta's thing is
> right on the money.  I just think this is really going to
> "give us only enough rope...."

Which is at least a step forward, more than you're likely to get with any
other proposal.  Watch what a battle adding "real" namespaces turns into,
and you'll see how good formalizing prefixes looks after a while.

Ramon Leon


Reply | Threaded
Open this post in threaded view
|

Re: Quick comparison of two Namespaces proposals

Göran Krampe
In reply to this post by Michael van der Gulik-2
Hi!

"Michael van der Gulik" <[hidden email]> wrote:

> On 9/18/07, G=F6ran Krampe <[hidden email]> wrote:
> > > - I personally don't like the "." notation for namespaces, especially
> > >> since we already use "." for statement separation. I still think "::"
> > is
> > >> the best I have seen, although granted - this is a tiny, tiny detail.
> > >
> > > Meh. I like the dots; they look tidy. If you can give me a good reason
> > not
> > > to use them then I'm happy to change.
> >
> > A *good* reason? Hehe, not really. I don't recall the details in
> > lexer/parser etc - adding support for $: inside global names was rather
> > simple - I have no idea if it is just as simple with $.
> >
> > My reasoning behind :: was that it "stands out" in the syntax - you will
> > not accidentally mistake it for something else. The "." is IMHO not at al=
> l
> > as clear. For example, what does this code say:
> >
> >     self add: Kernel.Array new: 4
> >
> > Is it the same as?:
> >
> >     self add: Kernel.
> >     Array new: 4
>
> Hmm.
>
> self add: Kernel.Array new: 4.
> self add: Kernel::Array new: 4.
>
> What do other people think?

Let me just note that the second version using :: is NOT ambiguous for
the parser - the one using "." seems to be unless I am missing something
obvious.

> Keep in mind that I only expect people to use this syntax when the import
> list allows ambiguity in the names. Typically, you'd just see:
>
> self add: Array new: 4.
>
> because Kernel has been added to the import list.

Of course, and similarly goes for my proposal - you would very rarely
see or type fully qualifieid names there too. But again - I am trying to
put my finger on a parsing disambiguity here. :)

> What I am a bit concerned about is that I've made the BNF grammar more
> complex or that I've made it stupid. If a dot/period is followed by
> whitespace, it terminates the current statement; else it can validly be par=
> t
> of a word or keyword.
[SNIP of change]

> >> - Your Namespaces are linked to a Package scheme, I personally would
> > >> like
> > >> to keep these concepts separate.
> > >
> > > (background for people: Package is a subclass of Namespace and forms th=
> e
> > > root of a namespace hierarchy).
> > >
> > > Why is this a bad thing? Could you be more specific?
> >
> > IMHO a package is a "deployment unit" more than anything else. A namespac=
> e
> > on the other hand is a "pool of unique names" that we developers share
> > with each other one way or the other.
> >
> > I can see a package both using and defining names in several namespaces.
> > And I can see several packages defining names in the same namespace. Thus
> > I don't see the need for making a hard connection between the two
> > concepts.
>
> I see nothing wrong with a deployment unit containing a pool of unique
> names. In my approach, a package does both use and define names in several
> namespaces.

Ok, so one package can define names in several different namespaces?
Ehh... that sounds slightly different than what I read - perhaps I
misunderstood the relationship between a Package and a Namespace in your
solution.

> What do you mean by several packages defining names in the same namespace?
> Are you talking about method overrides? Then like I said before, I can't
> work out how to do this without creating a security issue (I'm planning on
> Packages containing completely untrusted code which can be securely execute=
> d locally).

I am not talking about method overrides, no. I am simply talking about
package P1 defining a class X in N1 and package P2 defining class Y in
N1. Nothing magical. :)

But I think you wrote that Package is actually a subclass of Namespace
so perhaps your mental model of package == namespace is making this
sound *crazy*. :) But I still think these two concepts are orthogonal -
even though often we (developers on planet earth) *decide* that one
should be tightly bound to the other.

I see value in NOT making that tie, for once.

> If you're talking about defining the same class in multiple packages, then

No, I am not. :)

regards, Göran

Reply | Threaded
Open this post in threaded view
|

Re: Quick comparison of two Namespaces proposals

Michael Davies-2
In reply to this post by Jason Johnson-5
On 18/09/2007, Jason Johnson <[hidden email]> wrote:
> What about message style sytax?
>
> e.g.
>
> self add: (Kernel Array new: 4)
>

This looks like how GNU Smalltalk handles namespaces. Following up the
references in the gst info files, I found some discussion on the
Squeak wiki which includes some work done by Augustin Mrazik in 1992:

http://wiki.squeak.org/squeak/727

Reply | Threaded
Open this post in threaded view
|

Re: Quick comparison of two Namespaces proposals

Nicolas Cellier-3
In reply to this post by Ron Teitelbaum
Some other dialects already have Namespaces (vw gst ...)

Any desire to be source-compatible?

Nicolas

Ron Teitelbaum a écrit :

> +1 for ::
>
> Even if it is really
>
> self add: (Kernel::Array new: 4).  
>
> :)
>
> Ron
>


Reply | Threaded
Open this post in threaded view
|

Re: Quick comparison of two Namespaces proposals

Göran Krampe
In reply to this post by stephane ducasse
Hi!

stephane ducasse <[hidden email]> wrote:

> >
> > - Imports are done in your code "per Namespace" which is immensely  
> > better
> > than like for example in Java where it is per class (well, per  
> > file, but
> > anyway). It is still though the major difference with my proposal  
> > in which
> > there are *no* explicit imports at all.
>
> the problem with per namespace is that you can get unanticipated  
> conflicts.
> here is a scenario that klaus from Smalltalk/x explained to me once
>
> you have two namespace
>
> N1
> A
>
>
> N2 import N1
> B
> method foo
> ^ B
>
> everthing compiles
>
> now you add a new class B in N1
> and the system does not bark....
>
> a while later you recompile the method foo and now you may be in  
> trouble.

Ok, so to explain your use case further - before N1 had a B, the foo
method was obviously bound to the B in N2 - because there was no other
B. Then you added another B to N1 and then recompile foo and now there
are two B-choices - the local one in N2 or the imported one in N1,
right?

In my proposal this is not a problem at all, this is what would happen:

First we have a class named N1::A and a class named N2::B. There is no
import (since I don't have that concept at all). When typing in method
N2::B>>foo and typing "B" nothing strange or odd will happen - as long
as there is no other B around in the image (in any other namespace)
Squeak will resolve it to N2::B and the *source* stored in method foo
will be:

   ^ N2::B

...BUT it will *look* like "^ B" in the browsers because the short form
is enough - there is no other B around so we render and accept the short
form "B".

Now someone creates another B in the image - N1::B. After that we browse
foo and it still renders in short form. How is that? Well, if the
reference would have been to a class in ANOTHER namespace (non local)
then it suddenly would render like "^ N2::B" because the short form is
no longer "enough". So there is a policy to accept and render short
forms even if there are multiple Bs *if* the reference is LOCAL - which
is the case here.

Anyway, so what if we recompile then? No problem, it is in fact NOTHING
different from now. The reference was always FULLY QUALIFIED in the
source and thus a recompile is no problem at all.

regards, Göran

Reply | Threaded
Open this post in threaded view
|

Re: Quick comparison of two Namespaces proposals

Göran Krampe
In reply to this post by Jason Johnson-5
Hi!

"Jason Johnson" <[hidden email]> wrote:
> On 9/17/07, Göran Krampe <[hidden email]> wrote:
> >
> > - I personally think hierarchical namespaces is "too much". I opted for
> > single level namespaces and still think that is enough.
>
> But this is a slippery slope.  Afterall, flat wasn't enough, why
> should we think 1 level would be enough forever?

This reasoning makes no real sense to me. Why would multiple levels be
"better"? Are we afraid of running out of namespace names? IMHO the
proliferation of namespaces and hierarchies of them in other languages
(like Java) is more based on the fact that they are used for
organisational purposes.

I don't see the need for that many namespaces - in fact, they should
probably map rather well to *communities* or *projects* rather than
*packages*. Which again is why I don't consider namespace==package.

To make myself even clearer: The base Smalltalk-80 libraries could all
be in one single namespace - and for convenience, let's jus stick to
good ole "Smalltalk". The whole Seaside community could use ONE
namespace. The Croqueteers could use ONE or a few. We don't need to
create a namespace for every little silly class library you know! :)

> > - Imports are done in your code "per Namespace" which is immensely better
> > than like for example in Java where it is per class (well, per file, but
> > anyway). It is still though the major difference with my proposal in which
> > there are *no* explicit imports at all.
>
> Well, the issue I have with your proposal is it isn't really a
> Namespace/Package proposal, it's simply a proposal to always add your
> prefixes with a ::, and add some tool support to deal with it.
>
> In my opinion Namespaces are a complicated subject and using such a
> simple method to deal with them is just sweeping the problem under the
> rug for someone else.

Well, I disagree of course. :) I think most people think it is so
complicated because they mix it up with deployment/packaging AND/OR SCM
issues.

Just maintaining spaces of unique names isn't rocket science IMHO. And
yes, I agree - my proposal is NOT a *Package* proposal - it *is* a
Namespace proposal though. Even though calling it "Prefixes improved"
might make it sound less threatening. :)

BUT... please give me use cases etc that you think are not handled by my
scheme and I will try to answer with how it would work. Like I just did
with Stephane's use case.

> I try to make my own solutions as simple as possible, but no simpler.
> Personally, I think that if we need namespaces now there are good
> examples to follow:  Lisp, Python, possibly Haskell all have good
> Namespace/Package systems we could emulate.

But why? Smalltalk is different. We can always *learn* from other
languages but just copying is not good.

> > - I agree that shared pools theoretically could be replaced with
> > Namespaces, but then we actually have imports *per class*, which I really
> > don't like. You may argue, "but we already have them!" - yes, I agree, but
> > I don't like them anyway and in my proposal I opted out by simply
> > ignoring/not touching them. :)
>
> What is the problem with shared pools?  That they're a kind of global
> variable?  I haven't used them much myself, but personally I would
> prefer a good argument for getting rid of them since the creators of
> Smalltalk seem to think they were useful.

I would like to hear the views from the creators in this case. Just the
fact that they are very seldomly used should IMHO signal us to
reconsider. They are a namespace imported per class. They do create an
"environment" where code behaves differently and where you can easily
"trick" the reader - like having a shared pool shadowing a global etc.

IMHO a mechanism that widens the gap between what you read and type and
what is actually executed - is generally a problem. Imports in general
is such a problem, especially imports per class and in which ordering of
imports matter (just mention the word "class path" to a java developer
and watch him/her squirm).

Also - the fact that a shared pool does not even have to be a global,
well, it sure makes them "tricksy enough" to warrant some scrutiny IMHO.

> > - Your Namespaces are linked to a Package scheme, I personally would like
> > to keep these concepts separate.
>
> From Lisp or Python terms "Namespace" and "Package" are synominous.  I
> think you are talking about Package as in "an MC package", no?  That
> is a package as well, but it's from a different namespace. :)  In
> regards to language I don't think there is much difference between the
> two except that people tend to call their thing "Namespace" if it's
> extremely simple (e.g. C++'s solution) and package if it's more
> complete.

I know that most languages mix these concepts - but that doesn't make it
mystically right. :) Most code packages (as in deployment unit - think
class library for example) are developed by individuals or groups of
developers and it is convenient to create a little "sandbox" in which
that group can maintain their own names without having to risk
collisions with the rest of the world. This is what I call "pessimistic
approach" - as in, you "lock" your own space and that's it. Downsides
are proliferation of lots of small namespaces "just in case" and
duplicated classes - lots of Date classes for example (see java again).

I am proposing fewer namespaces that are "more shared" and instead
"embrace collisions" by using an optimistic approach and deal with them
when they appear. This is what we do today in SystemDictionary when we
don't use prefixes - we are in fact maintaining and tending a shared
namespace (hundreds of developers) and sometimes we end up with
collisions and then we deal with that. This is GOOD. Putting every
little silly class in its own little space - like for example if we
equal class category to namespace - that would be nuts.
 
> > - You go hierarchical, I stayed simple and kept it on one level.
>
> I think this is fundamentally a hierarchical issue.

I am very curious to why you think so. Even in java the hierarchy is
just by convention. I definitely do not see any obvious reason to why
namespaces should have a father-child relation and I definitely don't
see any obvious interpretation of such a relation. Really, I am not
trolling. :)

> > - You added an explicit import list per Namespace, I opted to not have
> > imports at all.
>
> For a complete system imports are required unless you want to be
> typing the whole path out everytime, which is what we have right now
> (i.e. no need to add a bunch of stuff to just end up where we are now)

This last statement shows clearly that you have not read about my
proposal in any kind of depth, which of course is fine - it is by all
means not required bedtime reading. :) But let me just say that imports
is NOT the only way to get rid of fully qualified names in typing and
reading.

In my proposal all classes (globals of course, but hey - we are talking
about 99% classes) that have unique short names in the image (that would
easily be 98% I guess) are always rendered and typed in their short
form. ONLY the classes which are duplicates (Fruit::Orange and
Color::Orange) would be rendered in fully qualified form and they still
only need to be typed shortly - the browser will ask which one you mean
and expand upon save.

AND... they would still be accepted in short form and rendered in short
form if the reference is LOCAL - for example if code in Fruit::Apple
references Orange you only type "Orange" and read "Orange" even though
Color::Orange exists. But this is only policy - but I felt it was a nice
thing to do.

And no, not a single import in sight! :)

regards, Göran

Reply | Threaded
Open this post in threaded view
|

Re: Quick comparison of two Namespaces proposals

Michael van der Gulik-2
In reply to this post by Brent Pinkney-2
Array is a class, not a message. This is /not/ elegant and simply doesn't make sense. This is my last comment on this approach.

What is possible is:

self add: (Kernel-Array new: 4).

Here, #- is a message.

Michael.


On 9/19/07, Brent Pinkney <[hidden email]> wrote:

+10000 for:

self add: (Kernel Array new: 4).

This mechanism preseves the elegant foundation of Smalltalk: 'Everyting is an Object, which receives a messages and returns an object'.
In this (Dan's ?) solution, the implementation is late bound and can use the same lookup algorithm as used for messages.

The other solutions lack this elegance.

On Dinsdag, 18 September 2007, Ron Teitelbaum wrote:
> +1 for ::
>
> Even if it is really
>
> self add: (Kernel::Array new: 4).
>
> :)

>
> Ron
>
> > -----Original Message-----
> > From: [hidden email] [mailto:[hidden email]
> > [hidden email]] On Behalf Of Bert Freudenberg
> > Sent: Tuesday, September 18, 2007 6:31 AM
> > To: The general-purpose Squeak developers list
> > Subject: Re: Quick comparison of two Namespaces proposals
> >
> > On Sep 18, 2007, at 11:55 , Michael van der Gulik wrote:
> >
> > > self add: Kernel.Array new: 4.
> > > self add: Kernel::Array new: 4.
> > >
> > > What do other people think?
> >
> > +10 for ::
> >
> > Though I hope this won't become a bikeshed discussion of syntax, but
> > actually result in a Namespace solution getting adopted.
> >
> > - Bert -
> >
> >
>
>
>
>






Reply | Threaded
Open this post in threaded view
|

Re: Quick comparison of two Namespaces proposals

Michael van der Gulik-2
In reply to this post by stephane ducasse


On 9/19/07, stephane ducasse <[hidden email]> wrote:
the problem with per namespace is that you can get unanticipated
conflicts.
here is a scenario that klaus from Smalltalk/x explained to me once

you have two namespace

N1
        A


N2 import N1
        B
        method foo
                ^ B

everthing compiles

now you add a new class B in N1
and the system does not bark....

a while later you recompile the method foo and now you may be in
trouble.

This is a problem that I'm currently working with. I think I'll try completely disallowing ambiguous names. If a name in a method can resolve to anything other than exactly one binding, then the compiler complains. The user will have to resolve this either by reorganising the local import list, or making the name less ambiguous using either dotted notation or Krampe notation ('::').

Michael.


Reply | Threaded
Open this post in threaded view
|

Re: Quick comparison of two Namespaces proposals

Igor Stasenko
In reply to this post by Michael van der Gulik-2
On 19/09/2007, Michael van der Gulik <[hidden email]> wrote:
> Array is a class, not a message. This is /not/ elegant and simply doesn't
> make sense. This is my last comment on this approach.
>
> What is possible is:
>
> self add: (Kernel-Array new: 4).
>
> Here, #- is a message.
>

Again, discussion downs not to about how namespaces should behave, but
to choosing appropriate and  conventional syntax for it. Personally, i
don't think its really matters.
Please, people, lets focus on more important things, if you don't want
to flame this topic, like in previous 'pipe syntax'.


> Michael.
>
>
>
> On 9/19/07, Brent Pinkney <[hidden email]> wrote:
> >
> > +10000 for:
> >
> > self add: (Kernel Array new: 4).
> >
> > This mechanism preseves the elegant foundation of Smalltalk: 'Everyting is
> an Object, which receives a messages and returns an object'.
> > In this (Dan's ?) solution, the implementation is late bound and can use
> the same lookup algorithm as used for messages.
> >
> > The other solutions lack this elegance.
> >
> > On Dinsdag, 18 September 2007, Ron Teitelbaum wrote:
> > > +1 for ::
> > >
> > > Even if it is really
> > >
> > > self add: (Kernel::Array new: 4).
> > >
> > > :)
> > >
> > > Ron
> > >
> > > > -----Original Message-----
> > > > From: [hidden email]
> [mailto: squeak-dev-
> > > > [hidden email]] On Behalf Of Bert
> Freudenberg
> > > > Sent: Tuesday, September 18, 2007 6:31 AM
> > > > To: The general-purpose Squeak developers list
> > > > Subject: Re: Quick comparison of two Namespaces proposals
> > > >
> > > > On Sep 18, 2007, at 11:55 , Michael van der Gulik wrote:
> > > >
> > > > > self add: Kernel.Array new: 4.
> > > > > self add: Kernel::Array new: 4.
> > > > >
> > > > > What do other people think?
> > > >
> > > > +10 for ::
> > > >
> > > > Though I hope this won't become a bikeshed discussion of syntax, but
> > > > actually result in a Namespace solution getting adopted.
> > > >
> > > > - Bert -
> > > >
> > > >
> > >
> > >
> > >
> > >
> >
> >
> >
> >
>
>
>
>
>


--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

Re: Quick comparison of two Namespaces proposals

Michael van der Gulik-2
In reply to this post by Damien Pollet


On 9/19/07, Damien Pollet <[hidden email]> wrote:
Period has a potential conflict with expression separator, and
double-colon could be kept for variadic messages or argument-related
stuff (currently, when there is a colon, an argument is not far, so it
would be nice to keep this association).

What about underscore, since it's not used elsewhere in the syntax ;-)
Kernel_Array looks like an identifier, Kernel _ Array can be a binary message...

Period works okay if Period followed by whitespace is an expression separator, and period followed by a printable character can be part of a name.

What's a variadic message?

I'm not sure what the status of underscores are. Currently I think they're still a hack for the back-arrow in the squeak image, and from what I hear they are not accepted in Croquet? It is possible to free them up and make people use either a Unicode back-arrow :-) or :=.

Michael.


Reply | Threaded
Open this post in threaded view
|

Re: Quick comparison of two Namespaces proposals

Enno Schwass
In reply to this post by Göran Krampe
Hi

>> - I personally don't like the "." notation for namespaces, especially
>>> since we already use "." for statement separation. I still think  
>>> "::" is
>>> the best I have seen, although granted - this is a tiny, tiny  
>>> detail.
>>
>> Meh. I like the dots; they look tidy. If you can give me a good  
>> reason not
>> to use them then I'm happy to change.
>
> A *good* reason? Hehe, not really. I don't recall the details in
> lexer/parser etc - adding support for $: inside global names was  
> rather
> simple - I have no idea if it is just as simple with $.
>
> My reasoning behind :: was that it "stands out" in the syntax - you  
> will
> not accidentally mistake it for something else. The "." is IMHO not  
> at all
> as clear. For example, what does this code say:

And its known from the ruby language. I like the :: notation
I went from ruby to squeak and I like both.

just my 2 cent
Enno



Reply | Threaded
Open this post in threaded view
|

Re: Quick comparison of two Namespaces proposals

David Mitchell-10
In reply to this post by Göran Krampe
+1

On 9/18/07, [hidden email] <[hidden email]> wrote:
> I don't see the need for that many namespaces - in fact, they should
> probably map rather well to *communities* or *projects* rather than
> *packages*. Which again is why I don't consider namespace==package.

Reply | Threaded
Open this post in threaded view
|

Re: Quick comparison of two Namespaces proposals

Michael van der Gulik-2
In reply to this post by Bert Freudenberg


On 9/19/07, Bert Freudenberg <[hidden email]> wrote:
On Sep 18, 2007, at 18:09 , Jason Johnson wrote:

> Oh no, are people really so strongly for ::?

I'm rather strongly against ".". And not only because the dot is
already too overloaded in Smalltalk.

Dot-notation is becoming ubiquitous in "pop CS" to the point where
people don't even admit there are alternatives. In one German state
teaching "dot notation" to kids is made mandatory by the school
administration, ruling out the use of Smalltalk as a teaching
language. I kid you not.

Having it creep into Squeak would make this individual sad. If this
means anything to anybody ;)

I'm sorry to hear that. If it gets in, I might send you a beer to cheer you up.

Could you explain how the dot is overloaded in Smalltalk? Currently I'm only aware that it's used for ending statements.

The fact that the dot notation (in the context of Namespaces, I assume) is popular is quite important. If it  comes only with a small grammatic and typographic cost, then in my opinion it's a good idea to keep things consistent across languages.

What do other Smalltalks use? Could somebody knowledgable give me a quick run-down?

Other programming languages:
Python - '.'
Java - '.'
C++ - '::'
C# - '.'
Erlang - ':'
Haskell - '.' (note 1)

Not a programming language
XML - ':' (?)
Filesystems - '/', '\', ':'.

(1) http://bardolph.ling.ohio-state.edu/cgi-bin/dwww/usr/share/doc/haskell98-report/hier.pdf.gz






Reply | Threaded
Open this post in threaded view
|

Re: Quick comparison of two Namespaces proposals

Michael van der Gulik-2
In reply to this post by Michael Davies-2


On 9/19/07, Michael Davies <[hidden email]> wrote:
On 18/09/2007, Jason Johnson <[hidden email]> wrote:
> What about message style sytax?
>
> e.g.
>
> self add: (Kernel Array new: 4)
>

This looks like how GNU Smalltalk handles namespaces. Following up the
references in the gst info files, I found some discussion on the
Squeak wiki which includes some work done by Augustin Mrazik in 1992:

http://wiki.squeak.org/squeak/727



Thanks... this is a really good find. Reading.

Gulik.


Reply | Threaded
Open this post in threaded view
|

Re: Quick comparison of two Namespaces proposals

Michael van der Gulik-2
In reply to this post by Göran Krampe


On 9/19/07, [hidden email] <[hidden email]> wrote:
Hi!

Hello :-).
 
"Michael van der Gulik" <[hidden email]> wrote:
> What do you mean by several packages defining names in the same namespace?
> Are you talking about method overrides? Then like I said before, I can't
> work out how to do this without creating a security issue (I'm planning on
> Packages containing completely untrusted code which can be securely execute=
> d locally).

I am not talking about method overrides, no. I am simply talking about
package P1 defining a class X in N1 and package P2 defining class Y in
N1. Nothing magical. :)


My implementation handles this fine. In this case, you'd have P1 containing N1::X (using Krampe notation) and P2 containing N1::Y. The import list of your code using X and Y would include P1 and P2 (import lists contain only other Namespaces, and Packages are Namespaces).

When your code contains the name "N1::X", then the compiler will search P1 (from the import list) for N1, then that N1 for X and find it (and continue searching to make sure the name isn't ambiguous). When your code contains the name "N2::X" then the compiler will search P1 (from the import list) for N1, search that N1 for Y, not find it, search P2 (from the import list) for N1, search that N1 for Y, find it and return it (and continue searching to make sure it isn't ambiguous).

Michael.


12345