Re: Clojure embedded in a Java Application

2011-09-19 Thread Meikel Brandmeyer (kotarak)
Hi, It was recommended in the past to go through the clojure side of things. That means for me to call hash-map rather than RT.map. By creating a small helper class one can get one's own Clj.map while still going through the official API as recommended. Hence I didn't mention RT.map.

Re: Clojure embedded in a Java Application

2011-09-19 Thread Laurent PETIT
2011/9/19 Meikel Brandmeyer (kotarak) m...@kotka.de Hi, It was recommended in the past to go through the clojure side of things. That means for me to call hash-map rather than RT.map. By creating a small helper class one can get one's own Clj.map while still going through the official API

Re: Clojure embedded in a Java Application

2011-09-19 Thread Armando Blancas
You can also do it the other way around, use gen-class and write yourself a static entry point callable from Java. That's the right way to do it, IMO. Better yet, write a Java wrapper to offer Javadocs and to hide any interop code. That means extra work on both ends, but in Java shops

Re: Clojure embedded in a Java Application

2011-09-18 Thread Meikel Brandmeyer
Hi, Am 18.09.2011 um 04:58 schrieb Eamonn: I tried the following Var keyword = RT.var(clojure.core, keyword); Var hashMap = RT.var(clojure.core, hash-map); hashMap.invoke(keyword.invoke(a), 1); then I created the following function (defn foo[key paramMap](key paramMap)) Object

Re: Clojure embedded in a Java Application

2011-09-18 Thread Meikel Brandmeyer
Am 18.09.2011 um 05:55 schrieb Ken Wesson: The easiest might be to just pass a map literal (in String form) through the Clojure reader. Variable integers or other simple objects can just be incorporated using the Java String + operator; the concatenation will always start with a string

Re: Clojure embedded in a Java Application

2011-09-18 Thread Ken Wesson
On Sun, Sep 18, 2011 at 4:06 AM, Meikel Brandmeyer m...@kotka.de wrote: Am 18.09.2011 um 05:55 schrieb Ken Wesson: The easiest might be to just pass a map literal (in String form) through the Clojure reader. Variable integers or other simple objects can just be incorporated using the Java

Re: Clojure embedded in a Java Application

2011-09-18 Thread Meikel Brandmeyer
Hi, Am 18.09.2011 um 10:11 schrieb Ken Wesson: Tell me which is simpler: Reader.read({:foo 1 :bar + x + }); String x = 13rabc; Have fun. Var keyword = RT.var(clojure.core, keyword); Var hashMap = RT.var(clojure.core, hash-map); hashMap.invoke(keyword.invoke(foo), 1,

Re: Clojure embedded in a Java Application

2011-09-18 Thread Ken Wesson
On Sun, Sep 18, 2011 at 4:40 AM, Meikel Brandmeyer m...@kotka.de wrote: Hi, Am 18.09.2011 um 10:11 schrieb Ken Wesson: Tell me which is simpler: Reader.read({:foo 1 :bar + x + }); String x = 13rabc; Have fun. Syntactically invalid Clojure code would fail just as much in Clojure source

Re: Clojure embedded in a Java Application

2011-09-18 Thread Meikel Brandmeyer
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);

Re: Clojure embedded in a Java Application

2011-09-18 Thread Eamonn
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

Re: Clojure embedded in a Java Application

2011-09-18 Thread Kevin Downey
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

Re: Clojure embedded in a Java Application

2011-09-18 Thread Luc Prefontaine
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

Re: Clojure embedded in a Java Application

2011-09-18 Thread Sean Corfield
On Sun, Sep 18, 2011 at 3:40 AM, Meikel Brandmeyer m...@kotka.de wrote: Var keyword = RT.var(clojure.core, keyword); Var hashMap = RT.var(clojure.core, hash-map); hashMap.invoke(keyword.invoke(foo), 1, keyword.invoke(bar), x); This one is more simple. This is clojure code. Since I've ended

Re: Clojure embedded in a Java Application

2011-09-17 Thread Eamonn
Hi Meikel Thank you for your reply. Is there a way to populate the HashMap before passing it to the invoke method I tried the following Var keyword = RT.var(clojure.core, keyword); Var hashMap = RT.var(clojure.core, hash-map); hashMap.invoke(keyword.invoke(a), 1); then I created the following

Re: Clojure embedded in a Java Application

2011-09-17 Thread Ken Wesson
On Sat, Sep 17, 2011 at 10:58 PM, Eamonn odon...@gmail.com wrote: Hi Meikel Thank you for your reply.  Is there a way to populate the HashMap before passing it to the invoke method The easiest might be to just pass a map literal (in String form) through the Clojure reader. Variable integers or

Clojure embedded in a Java Application

2011-09-16 Thread Eamonn
Hi I'm new to Clojure so forgive me if this is a dumb question. I want to incorporate some Clojure into a Java application. String rule=(str key val label); String str = (ns test) + (defn foo [key val label] + rule +

Re: Clojure embedded in a Java Application

2011-09-16 Thread Bronsa
The problem could be that #{} in clojure is a set literal, try using clojure.lang.PersistentHashSet/create Hi I'm new to Clojure so forgive me if this is a dumb question. I want to incorporate some Clojure into a Java application. String rule=(str key val label);

Re: Clojure embedded in a Java Application

2011-09-16 Thread Meikel Brandmeyer (kotarak)
Hi, Am Donnerstag, 15. September 2011 23:39:10 UTC+2 schrieb Eamonn: The code works BUT if I try to pass in a map for example like so Object result = foo.invoke( hello,world,#{:a 1 :b 2}); This does not pass a map to the function, but the string #{:a 1 :b 2}. And from your example I