Hi,
At
http://en.wikibooks.org/wiki/Clojure_Programming/Tutorials_and_Tips#Invoking_Clojure_from_Java
, they use this clojure source file, from inside the classpath:
; foo.clj(ns user)
(defn foo [a b]
(str a " " b))
, to demonstrate this code for calling functions in a Clojure source file,
from Java:
// Foo.java
import clojure.lang.RT;import clojure.lang.Var;
public class Foo {
public static void main(String[] args) throws Exception {
// Load the Clojure script -- as a side effect this initializes the
runtime.
RT.loadResourceScript("foo.clj");
// Get a reference to the foo function.
Var foo = RT.var("user", "foo");
// Call it!
Object result = foo.invoke("Hi", "there");
System.out.println(result);
}}
The problem is, that the Var foo = RT.var... assignment already knows that
the namespace is "user", along with the knowledge that "foo" is one of the
functions defined there.
Is there a way to get the default namespace in RT, so you don't have to
specify "user"? I tried replacing "user" with "*ns*", but it didn't work.
I know that ns is a macro. Is the same true for *ns*? Is there some other
function, that you can use, so that the assignment could be something like
Var foo = RT.var( "GetCurrentNameSpace", "foo");
?
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.