On Thu, Jan 22, 2009 at 4:43 PM, Peter Wolf <opus...@gmail.com> wrote:
>
> This is a rejuvenation of the old "calling Java from Clojure" thread
>
> I have been looking at the solutions from Mark
> /
>   1) From a Java application, read a text file containing Clojure code
>   and invoke specific functions it defines from Java code.
>   2) Compile Clojure code to bytecode and use it from a Java application
>   just like any other Java code.
>
>   An example of the first option is provided at
>
> http://markmail.org/message/tx23zaxf77b6widh#query:%22calling%20Clojure%22%20%22from%20Java%22+page:1+mid:tx23zaxf77b6widh+state:results.
>
>  /
>
> and Stuart
> /
>   Here's how I do it:
>
>   import clojure.lang.RT;
>   import clojure.lang.Var;
>   ...
>   RT.loadResourceScript("source/file/on/classpath/here.clj");
>   Var myfunction = RT.var("my-namespace", "my-function");
>   myfunction.invoke("arg 1", "arg 2", ...); /
>
>
> Where is the documentation on this Java API?  In particular, all these
> functions seem to side-effect a single Clojure image.
>
> Can I create several disjoint images?  Can I stop or destroy an image
> that has run amok?
>
> I want to use this for the IntelliJ plugin, and I don't want bogus user
> code to clobber the IDE.  I also want the defined symbols for a file to
> be a function just of the code in that file, not all the files that
> happen to be loaded by the IDE at the moment.  How does Swank handle this?
>

Clojure has no notion of an "environment". Its environment is the JVM
in which it is running, just like Java.

There was a thread about this awhile back, its long, but it goes over
some the issues I think you're getting at:

  
http://groups.google.com/group/clojure/browse_thread/thread/d98cedb860f16a34/18c930d1c76aa31c

The bottom line is that you can only isolate Clojure within a single
JVM in the same you that you can isolate Java in a single
JVM--ClassLoaders.

The other heavy-weight option is to run multiple JVMs.

I don't think you need to worry about user code hijacking the IntelliJ
IDE--Clojure cannot redefine Java classes which have already been
loaded. It is however possible for Clojure code to clobber previously
compiled Clojure code, so if you are worried about that, then I think
you'll need to look at an isolation mechanism like ClassLoaders or
launching a new JVM.

I don't think Swank really deals with the issue at all. I just checked
and it is entirely possible to re-def swank functions from the Emacs
SLIME repl.

/mike.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to