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]

Embedding a REPL in a Java application


I am embedding a REPL in a Java program (actually an application
framework used by several programs). I've created a subclass of JFrame
containing a ReplPane backed by a ReplDocument, a la
kawa.GuiConsole. (I can't use GuiConsole itself because I want to set
up my own menus and otherwise configure the JFrame before setting it
visible.)

I would like to have the behavior of GuiConsole/ReplDocument's shared
environment option, where code executing in one REPL window can see
definitions made in another. However, it appears that the way
GuiConsole achieves this requires access to ReplDocument.environment
(or ReplDocument.thread), which is only package-visible. It also seems
to require that the first instance of ReplDocument created have
shared=false: a long stream of exceptions occurs if you try
  new ReplDocument(Language.getDefaultLanguage(),
                   Environment.getCurrent(), true);

Is there a way to construct two instances of ReplDocument which share an environment, without having access to package-visible fields?

As a test, I tried this, which also failed:
  Language lang = Language.getDefaultLanguage();
  Environment env = Environment.make( "TEST_ENV",
                                      Environment.getGlobal() );
  new kawa.GuiConsole(lang, env, true);
so as far as I can tell, "new ReplDocument(language,penvironment,true)"
will only work if penvironment comes from another ReplDocument. Am I
missing something, or will I have to reinvent ReplDocument (and
ReplPane) to get this to work?

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?

Thanks,
Jamie Hope

--
Jamison Hope
The PTR Group
www.theptrgroup.com




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