This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Exception when calling fn. using for-each in Java


Jocelyn Paine <popx@pop3.ifs.org.uk> writes:

> Thanks for the comments about this. As a matter of interest, why
> is it that for-each requires the global environment, but the
> simpiler functions I tested that don't call for-each work without
> registering the environment?

It doesn't appear to be the for-each.  Even when I comment out the entire
for-each, the class initializer still needs the environment.  This is
because it looks for the binding for <java.util.Vector>.  That binding
ends up being "inlined", so the run-time lookup is wasted.  So one could
argue that it is a compiler bug that causes the global environment to
be required.  Or you could be happy that the compiler is smart enough
to inline the global reference!  In any case, if you run Scheme code,
you should expect that the Scheme environment needs to be initialized.
In some cases the compiler may be able to inline things so you don't
need it - but you can't count on that.

It might be better to have the Scheme environment be automatically
loaded, perhaps using a variant of compiler-generated (require ...).
But that has not been implemented.
-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/~per/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]