Hi,

You can also do it the other way around, use gen-class
and write yourself a static entry point callable from Java.

You get all the Clojure runtime init stuff done and you can define your 
dependencies in 
the clojure file (require or use). Then you can dive into the Clojure world for 
as long as you need it
and return some Javaish value directly usable by your Java code.

You can write a single routine to pass clojure expressions as strings or 
several ones depending how your
code is structured.

Of course you need to AOT the clojure files you want to call. If you are in 
a Java centric world this is not an alien concept at all.

If you need an example, look at the top of this file (gen-class) and the bottom 
for fns starting with -.

https://github.com/lprefontaine/Boing/blob/master/src/boing/bean.clj

The wiki describes also the Java API so you can link the Java API code versus 
its use.
https://github.com/lprefontaine/Boing/wiki/Using-Boing-from-java

Luc P.

On Sun, 18 Sep 2011 18:46:29 -0500
Kevin Downey <redc...@gmail.com> wrote:

> Just skimming this on the phone, has no one mentioned RT.map?
> On Sep 18, 2011 5:58 PM, "Eamonn" <odon...@gmail.com> wrote:
> > Hi Meikel,Ken
> > Thank you so much for taking the time to reply to my question.
> > Meikel Thanks for the code. I will implement as described above.
> >
> > On Sep 18, 6:28 pm, Meikel Brandmeyer <m...@kotka.de> wrote:
> >> Hi Eamonn,
> >>
> >> if you find this too tedious to write and use it quite often, then
> >> there
> is always the possibility to hide things a little bit behind a facade.
> >>
> >> class Clj {
> >>     static final Var seqVar = RT.var("clojure.core", "seq");
> >>     static final Var keywordVar = RT.var("clojure.core",
> >> "keyword"); static final Var hashMapVar = RT.var("clojure.core",
> >> "hash-map");
> >>
> >>     static Object seq(Object x) { return seqVar.invoke(x); }
> >>     static Object kw(String n) { return keywordVar.invoke(n); }
> >>     static Object kw(String n1, String n2) { return
> >> keywordVar.invoke(n1,
> n2); }
> >>     static Object hashMap(Object... args) { return
> hashMapVar.applyTo((clojure.lang.ISeq)seq(args)); }
> >>
> >> }
> >>
> >> This would make names a little bit more meaningful (less
> >> “invoke”s) for
> the functions you use most. And you might use your own function
> names. Of course this won't reach the sugar you get from Clojure
> itself.
> >>
> >> theMap = Clj.hashMap(Clj.kw("a"), 1, Clj.kw("b"), 2);
> >> foo.invoke(Clj.kw("a"), theMap);
> >>
> >> This translates directly into:
> >>
> >> (let [the-map (hash-map :a 1 :b 2)]
> >>   (foo :a the-map))
> >>
> >> It should be easy to understand what's going on despite the noise.
> >> I
> believe Java devs are used to noise.
> >>
> >> And FWIW: Not quoting "13rabc" by accident in the other scenario
> >> will not
> result in the Reader complaining but puzzled looks where this magical
> value came from. I personally don't particular like these moments.
> >>
> >> My 0,02€. YMMV.
> >>
> >> Sincerely
> >> Meikel
> >
> > --
> > 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
> > Note that posts from new members are moderated - please be patient
> > with
> your first post.
> > 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
> 



-- 
Luc P.

================
The rabid Muppet

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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