This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: Embedding a REPL in a Java application
- From: Per Bothner <per at bothner dot com>
- To: Jamison Hope <jrh at theptrgroup dot com>
- Cc: kawa at sourceware dot org
- Date: Sat, 14 Nov 2009 09:22:53 -0800
- Subject: Re: Embedding a REPL in a Java application
- References: <937BC5DD-771A-454D-A773-A336AD11D256@theptrgroup.com>
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/