This is the mail archive of the kawa@sourceware.org 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: Embedding a REPL in a Java application


On 11/13/2009 04:10 PM, Jamison Hope wrote:
Is there a way to construct two instances of ReplDocument which share
an environment, without having access to package-visible fields?

After a little bit of thought, I think adding a "copy constructor" for ReplDocument might make sense:

  public ReplDocument (ReplDocument old)
  {
    this(new SwingContent(), old.language, old.environment, true);
  }

and add a GuiConsole method to take a ReplDocument:

  public GuiConsole(ReplDocument rdoc)
  {
    super("Kawa");
    repl.getLanguage(); // In case a new GuiConsole is created from Java.
    init(doc);
  }

public GuiConsole(Language language, Environment penvironment, boolean shared)
{
this(new ReplDocument(language, penvironment, shared));
}


Then the shared action becomes:

    else if (cmd.equals(NEW_SHARED))
      new GuiConsole(new ReplDocument(document));

Could you this approach, and see how it works, both for the
existing GuiConsole, and your application?

I also want to pre-populate the environment with some useful
definitions (such as a pointer back to the Application owning the
REPL). It looks like I can either call env.put( name, value ) for some
environment, or I can call Scheme.getInstance().define( name, value );
what are the pros and cons of each method?

What are the Java equivalents of (require some.compiled.module) and
(load "some-uncompiled-file.scm")? Are there public equivalents of the
Language.def*StFld() methods?

Let me get back to about these. -- --Per Bothner per@bothner.com http://per.bothner.com/


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