<br><br><div><span class="gmail_quote">On 9/20/07, <b class="gmail_sendername">Göran Krampe</b> &lt;<a href="mailto:goran@krampe.se">goran@krampe.se</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Michael!<br><br>&gt;&gt; If I understand you correctly (there are lots of assumptions here that I<br>&gt;&gt; am not totally getting) - you are saying:<br>&gt;&gt;<br>&gt;&gt; - Package IS a Namespace.<br>&gt;&gt; - Two packages CAN define names in the same namespace.
<br>&gt;&gt;<br>&gt;&gt; I may be daft but I don&#39;t get it. So P1 &quot;contains&quot; N1 and so does P2?<br>&gt;&gt; And<br>&gt;&gt; a package IS a Namespace? So N1 can appear in multiple places in your<br>&gt;&gt; hierarchy, is that what you mean?
<br>&gt;&gt;<br>&gt;<br>&gt; Well... kind of. I&#39;ll explain it in code:<br>&gt;<br>&gt; Package is a subclass of Namespace; Namespace is a subclass of Dictionary.<br>&gt;<br>&gt; p1 := Package new.<br>&gt; n1 := Namespace new name: #Namespace1.
<br>&gt; p1 at: #Namespace1 put: n1. &quot; should be p1 addNamespace: n1. &quot;<br>&gt; n1 at: #X put: X.<br>&gt;<br>&gt; p2 := Package new.<br>&gt; n2 := Namespace new name: #Namespace1.<br>&gt; p1 at: #Namespace1 put: n2.
<br>&gt; n2 at: #Y put: Y.<br>&gt;<br>&gt; Now, if you add both p1 and p2 to your local import list, you can refer to<br>&gt; Namespace1.X and Namespace1.Y.<br>&gt;<br>&gt; Does this answer your question?<br><br>Ehm, well. :) It looks like a Package can contain any namespaces (like for
<br>example one that you already have with the same name in another package)<br>and that the complete &quot;tree&quot; of the namespaces is the merged tree of all<br>packages in your image? But then I have a hard time seeing that a Package
<br>ISA Namespace (subclass). Or perhaps the Namespace tree is in fact not a<br>tree at all.<br><br>And even if I am wrong... this feels complicated to me. </blockquote></div><br><br>Yea, it&#39;s pretty complicated. I spent ages contriving up the design, but the results are pretty spectacular and allow for some pretty nifty tricks.
<br><br>I&#39;ve edited <a href="http://gulik.pbwiki.com/Namespaces">http://gulik.pbwiki.com/Namespaces</a>. Let me know if this is easier to understand.<br><br>Packages sub-class from Namespaces so that they can contain Namespaces in the same way that Namespaces contain other Namespaces. It also means they can be validly added to import lists.
<br><br>My namespaces are not all merged together, because the compiler does not search every package/namespace instance in the image. The compiler /only/ searches a method&#39;s local Namespace instance, and then it searches that local Namespace&#39;s import list. It does not search anywhere else. If the name is not found in the local Namespace instance or in the import list, the code will not compile. To make use of a name, you need to add the namespace object containing that name to the local namespace&#39;s import list.
<br><br>Gulik.<br><br><br clear="all"><br>-- <br><a href="http://people.squeakfoundation.org/person/mikevdg">http://people.squeakfoundation.org/person/mikevdg</a><br><a href="http://gulik.pbwiki.com/">http://gulik.pbwiki.com/
</a>