This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: Kawa 1.11 released
On 11/13/2010 03:35 AM, Daniele Benegiamo wrote:
As you are waiting also for requests: as I use Kawa in JavaEE to process
special messages with a Scheme DSL, I would like to see improvements on
the Environment interface, with a better encapsulation. Now the
Environment is a single static instance binded to the current thread,
it's impossible to reset it or delete defined objects, it's impossible
to change safely the used Environment instance (actually the used
instances are two...). I think that a revisited interface would improve
the way Kawa is used as a library.
As far as I know, the Environment interface is mostly OK, and should do what
you're asking for. You can create new Environments, and bind/re-bind
the current thread's Environment: See setCurrent, setSaveCurrent,
and restoreCurrent. The latter are the recommended way to set the
current thread's Environment and then restore it to the old one.
They are new in 1.11, so you may not have noticed. Also, note that
in 1.10 you needed to use a Future to cleanly set thread-specific
properties (including variable values); this should now work for
threads created in any manner.
There is a source of confusion in the userEnv field of Language
object. If you leave that unset, then Language.getEnvironment()
returns the dynamic (thread) environment, which is easier to change.
In other words: Don't create a new Scheme instance, but use the
default one returned by Scheme.getInstance(), which has userEnv
unset.
Probably the documentation is confusing. An FAQ entry may also
be in order. Please take another look, and tell us what works
and what doesn't. Suggestions for improving the manual are
also welcome.
--
--Per Bothner
per@bothner.com http://per.bothner.com/