On 9/19/07, Göran Krampe goran@krampe.se wrote:
Hi!
On 9/19/07, goran@krampe.se goran@krampe.se wrote:
"Michael van der Gulik" mikevdg@gmail.com 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).
If I understand you correctly (there are lots of assumptions here that I am not totally getting) - you are saying:
- Package IS a Namespace.
- Two packages CAN define names in the same namespace.
I may be daft but I don't get it. So P1 "contains" N1 and so does P2? And a package IS a Namespace? So N1 can appear in multiple places in your hierarchy, is that what you mean?
Well... kind of. I'll explain it in code:
Package is a subclass of Namespace; Namespace is a subclass of Dictionary.
p1 := Package new. n1 := Namespace new name: #Namespace1. p1 at: #Namespace1 put: n1. " should be p1 addNamespace: n1. " n1 at: #X put: X.
p2 := Package new. n2 := Namespace new name: #Namespace1. p1 at: #Namespace1 put: n2. n2 at: #Y put: Y.
Now, if you add both p1 and p2 to your local import list, you can refer to Namespace1.X and Namespace1.Y.
Does this answer your question?
Regards, Gulik.