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]
Other format: [Raw text]

Re: new Scheme()


Per Bothner wrote:
Dean Ferreyra wrote:
 > Up until recently this kind of construct worked for us:


public class Env { public static void main(String[] strings) { kawa.standard.Scheme.registerEnvironment(); kawa.standard.Scheme scm = new kawa.standard.Scheme(); scm.eval( "(require 'srfi-1)" );


but with the latest CVS pull I get a null pointer exception on the eval(). Adding a call to this:

scm.setEnvironment(scm.getNewEnvironment());

before the eval() seems to be the fix.

Is this right?


No, I don't think so.  Creating a "new Scheme" is questionable;
the changes I've been making are towards making langauges be
"singleton classes" initialized at class initialization time.

Instead, try:
  kawa.standard.Scheme scm = kawa.standard.Scheme.getInstance();
  ... scm.getNewEnvironment() ...

This works, for now:
  ... scm.getEnvironment() ...
However, I'm not sure it will do so:  I think we want to move to a model
where the current "user environment" is language-independent.  That
implies that each language has an environment of predefined bindings,
but the user environment is thread-specific, not language-specific.

Okay, thanks.


I do still have a point of confusion about environments, though I don't think it affects our current code. Can users maintain separate environments explicitly? This Java snippet generates a NullPointerException for me:

  kawa.standard.Scheme.registerEnvironment();
  kawa.standard.Scheme scm = kawa.standard.Scheme.getInstance();
  gnu.mapping.Environment env = scm.getNewEnvironment();
  scm.eval( "(define a 1)", env );

when trying to expand "(define ...)" or other macros.

Dean


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