Displaying contents of Environments; how are exported namesbound?

Jocelyn Paine popx@pop3.ifs.org.uk
Sun Dec 16 14:32:00 GMT 2001


On Sat, 6 Oct 2001, Per Bothner wrote:

> Jocelyn Paine wrote:
> 
> >What's the best way, from inside a Kawa function, to display all the
> >bindings in the current environment and its predecessors, right back to
> >the global ones?
> >
> I don't think there is any easy way to do that in Kawa.  We need some way to
> iterate over all the bindings of an Environment.  Should be easy enough, 
> once
> we decide on a good API. Should check what other Scheme's provide.
>
For the moment, I'd be willing to write the display routine in Java and
call it from Kawa. Where in the source should I look to do that? There are
two subproblems: getting all the bindings, which probably also requires
getting the current environment's predecessor environments, and then
displaying in a sensible format the name and value in each binding.
 
> >Given an environment E that I have just created, and a compiled module M,
> >how can I add M's exported names to E?
> >
> You could try:
> 
> (invoke-static <gnu.kawa.reflect.ClassMemberConstraint> 'defineAll
>   (make <M>)
>   E)
> 
Sounds just what I need. As a matter of interest (I'm still trying to
understand Kawa's name resolution), suppose that from inside M, I were to
do this to the current environment, i.e. where E is
Environment.getCurrent() .

If I were then to create and eval a lambda expression which contains one
of M's exported names N as a free variable, would Kawa resolve N by
looking it up in the environment, or in the static set of exported names
that is, as you say, "something like" an environment? Which takes
precedence? 

Jocelyn Paine



More information about the Kawa mailing list