<div dir="ltr">Hi Rudi,<div><br></div><div>Some time ago, I promissed I'd look at implementing the three argument version of FIND-CLASS. I can't really test it, but I've finally managed to hack up my proposed solution. Find the patch included below and attached to the ticket.</div>
<div><br></div><div style>Also, I'm not sure the compiler sets up a global compilation environment. I think that if it doesn't, you want to bind a new environment somewhere in the COMPILE-FROM-STREAM to *compile-file-environment*.</div>
<div style><br></div><div style>HTH,</div><div><br></div><div><br clear="all"><div><br></div>-- <br><div dir="ltr">Bye,<div><br></div><div>Erik.</div><div><br></div><div><a href="http://efficito.com/" target="_blank">http://efficito.com</a> -- Hosted accounting and ERP.</div>
<div style>Robust and Flexible. No vendor lock-in.</div><div style><br></div><div style><br></div><div style>The patch:</div><div style><br></div><div style><br></div><div style><div>Index: Environment.java</div><div>===================================================================</div>
<div>--- Environment.java<span class="" style="white-space:pre"> </span>(revision 14552)</div><div>+++ Environment.java<span class="" style="white-space:pre"> </span>(working copy)</div><div>@@ -42,6 +42,7 @@</div><div> private Binding blocks;</div>
<div> private Binding tags;</div><div> public boolean inactive; //default value: false == active</div><div>+ private static final ConcurrentHashMap<Symbol, LispObject> classMap;</div><div> </div><div> public Environment() {}</div>
<div> </div><div>@@ -53,7 +54,11 @@</div><div> lastFunctionBinding = parent.lastFunctionBinding;</div><div> blocks = parent.blocks;</div><div> tags = parent.tags;</div><div>+ classMap = parent.classMap;</div>
<div> }</div><div>+ else</div><div>+ classMap = new ConcurrentHashMap<Symbol, LispObject>();</div><div>+</div><div> }</div><div> </div><div> // Construct a new Environment extending parent with the specified symbol-</div>
<div>@@ -217,6 +222,36 @@</div><div> return null;</div><div> }</div><div> </div><div>+ final public LispObject addClass(LispObject name, LispObject c)</div><div>+ {</div><div>+ classMap.put(checkSymbol(name), c);</div>
<div>+ return c;</div><div>+ }</div><div>+</div><div>+ final public LispObject findClass(LispObject name, boolean errorp)</div><div>+ {</div><div>+ final Symbol symbol = checkSymbol(name);</div><div>+ final LispObject c = classMap.get(symbol);</div>
<div>+</div><div>+ if (c != null)</div><div>+ return c;</div><div>+</div><div>+ if (errorp)</div><div>+ {</div><div>+ StringBuilder sb =</div><div>+ new StringBuilder("There is no class named ");</div>
<div>+ sb.append(name.princToString());</div><div>+ sb.append('.');</div><div>+ return error(new LispError(sb.toString()));</div><div>+ }</div><div>+ return NIL;</div><div>+ }</div><div>+</div>
<div>+ final public void removeClass(LispObject name)</div><div>+ {</div><div>+ classMap.remove(checkSymbol(name));</div><div>+ }</div><div>+</div><div> // Returns body with declarations removed.</div><div> public LispObject processDeclarations(LispObject body)</div>
<div> </div><div>Index: LispClass.java</div><div>===================================================================</div><div>--- LispClass.java<span class="" style="white-space:pre"> </span>(revision 14552)</div><div>+++ LispClass.java<span class="" style="white-space:pre"> </span>(working copy)</div>
<div>@@ -328,8 +328,7 @@</div><div> LispObject third)</div><div> </div><div> {</div><div>- // FIXME Use environment!</div><div>- return findClass(first, second != NIL);</div>
<div>+ return checkEnvironment(third).findClass(first, second != NIL);</div><div> }</div><div> };</div><div> </div><div>@@ -339,7 +338,6 @@</div><div> {</div><div> @Override</div><div> public LispObject execute(LispObject first, LispObject second)</div>
<div>-</div><div> {</div><div> final Symbol name = checkSymbol(first);</div><div> if (second == NIL)</div><div>@@ -350,6 +348,18 @@</div><div> addClass(name, second);</div><div> return second;</div>
<div> }</div><div>+</div><div>+ @Override</div><div>+ public LispObject execute(LispObject first, LispObject second,</div><div>+ LispObject third, LispObject fourth)</div><div>
+ {</div><div>+ if (second == NIL)</div><div>+ {</div><div>+ checkEnvironment.removeClass(first);</div><div>+ return second;</div><div>+ }</div><div>+</div><div>+ return checkEnvironment(fourth).addCleass(first, second);</div>
<div> };</div><div> </div><div> // ### subclassp</div><div><br></div></div></div>
</div></div>