You are not logged in

i'm cleaning up some of my local kawa hacks and noticed that
this fix has not gotten into the source trunk. does this need
a proper patch diff + changelog entry, or is there another
reason not to incorporate it?
thanks...

The patch is probably ok, since it just comments out an optimization. I don't have a good feeling for how much difference the optimization makes. It seems like it should be possible to replace the optimization by one defer the optimization to lookupInherited: If the appropriate flags are set then we cam skip the lookup in the parent.

#|kawa:4|# (define x 1)
Invalid parameter, was: gnu.expr.BuiltinEnvironment cannot be cast to gnu.mapping.SimpleEnvironment
java.lang.ClassCastException: gnu.expr.BuiltinEnvironment cannot be cast to gnu.mapping.SimpleEnvironment
at gnu.mapping.SimpleEnvironment.addLocation(SimpleEnvironment.java:204)
at gnu.mapping.SimpleEnvironment.addLocation(SimpleEnvironment.java:175)
at gnu.expr.ModuleExp.evalModule2(ModuleExp.java:329)
at gnu.expr.ModuleExp.evalModule(ModuleExp.java:188)
at kawa.Shell.run(Shell.java:284)
at kawa.Shell.run(Shell.java:197)
at kawa.Shell.run(Shell.java:178)
at kawa.TelnetRepl.apply0(TelnetRepl.java:23)
at gnu.mapping.RunnableClosure.run(RunnableClosure.java:78)
at gnu.mapping.Future.run(Future.java:44)

################

it was a little surprising that the repl's parent environment
was #<environment language-builtins> -- I'd have expected
the parent to be the TelnetRepl's environment.

I took a look at cloneForThread in gnu.mapping.Environment,
and did an experiment with commenting the following block
of code at the beginning of the method. I don't claim
that this is a fix by any means...not sure what's going
on here....but this change allows setIndirectDefines
to (appear to) work correctly

// There is no point for a lookup to search this Environment,
// since its bindings will be cloned. Instead patch the new Environment
// so it inherits from its grandparents instead.
/*
if (this instanceof InheritingEnvironment)
{
InheritingEnvironment p = (InheritingEnvironment) this;
int numInherited = p.numInherited;
env.numInherited = numInherited;
env.inherited = new Environment[numInherited];
for (int i = 0; i < numInherited; i++)
env.inherited[i] = p.inherited[i];
}
*/