On Sep 22, 2004, at 10:58 AM, Dan Sugalski wrote:

*) There are three things that can be in a namespace: Another namespace, a method or sub, and a variable.

*) The names of namespaces, methods & subs, and variables do *not* collide. You may have a namespace Foo, a sub Foo, and a variable Foo at the same level of a namespace.

The easiest way to say these two point may be just to say that each namespace has three sections, and a given lookup is always a lookup in a specific section.


One problem: Some languages (Scheme, for example, and arguably C) have a unified namespace for subs and variables. What to do there?

*) Sub and method names *will* collide, so be careful there.

I'm not sure that they will. Classes are namespace-like, but aren't precisely namespaces. Since methods live in classes (and subs don't), this may just work itself out. (To give a concrete example, for a class Foo with an instance method bar, I never really look up any Foo::bar--instead, I invoke bar in an instance of Foo, which doesn't need to go looking for the relevant namespace--the "namespace" is directly attached to the Foo class.) It's a different story for class methods, which really are basically just subs (not really methods). But we still may have a problem if there are any languages which allow class and instance methods of the same name, in the same class.


*) If a language wants different types of variables to have the same name, it has to mangle the names. (So you can't have an Array, a String, and an Integer all named Foo) The only language I know of that does this is Perl, and we just need to include the sigil as part of the name and we're fine there.

This seems antithetical to cross-language functionality. Treating the perl sigil as part of the variable name is cute and all, but if we take that to heart at the Parrot level, then we really cut off cross-language access in any natural way. So I think Perl's "$foo" needs to look like "foo" to Python, or else everything will be nasty looking. Which will loop back to how handle "$foo" and "@foo" at the same time.


You're right that functions' lacking sigils makes this less of a problem, but that seems like a fragile truce.

*) Namespaces, by default, support notifications.

What does that mean? Notification of what?

JEff



Reply via email to