Re: Calling Clojure *from* Java

2019-06-10 Thread Howard Lewis Ship
You can have your cake and eat it too. I haven't touched this code in years, but there's no reason it shouldn't still work with the current version of Clojure. https://github.com/apache/tapestry-5/tree/master/tapestry-clojure Essentially, you provide an interface and map it to a Clojure namespac

Re: Calling Clojure from Java and classloader

2012-06-15 Thread Warren Lynn
> It's not really a good idea to AOT your code and then directly try to > use it from java. The generated java bytecode isn't guaranteed to be > stable across versions of clojure, and you're depending on > implementation details. > > One way to use your clojure code from java is through RT

Re: Calling Clojure from Java and classloader

2012-06-15 Thread Aaron Cohen
On Wed, Jun 13, 2012 at 11:48 PM, Warren Lynn wrote: > Ok, I hit a wall and really did not see this coming. > > Based on what I have read, its really easy for Clojure and Java to > work together. So I wrote some test Clojure code with a very simple > defrecord (say named as "testrec") and AOT comp

Re: Calling clojure from java.

2011-07-28 Thread Ken Wesson
On Thu, Jul 28, 2011 at 1:58 PM, Meikel Brandmeyer wrote: > If the thing you want to call is a macro, you have to hope that the library > other provided the logic as star function (as in Nicolas' case). If there is > no function containing the actual logic, you have to re-implement the macro >

Re: Calling clojure from java.

2011-07-28 Thread Meikel Brandmeyer
Hi, Am 28.07.2011 um 19:43 schrieb mmwaikar: > Thanks again Meikel. Where can I read about things like bindRoot, intern or > to be precise java-clojure interop? There are only a few things you must know: - RT.var to get a variable from a namespace - v.invoke to invoke a function stored in a Va

Re: Calling clojure from java.

2011-07-28 Thread .Bill Smith
It may also be useful to read up on primitives, since primitive support is often a source of impedance mismatch when software in one language talks to software in another. Would someone mind supplying a link to a description of how Clojure works with Java primitives in the 1.2.1 and 1.3 release

Re: Calling clojure from java.

2011-07-28 Thread mmwaikar
Thanks again Meikel. Where can I read about things like bindRoot, intern or to be precise java-clojure interop? -- 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 mem

Re: Calling clojure from java.

2011-07-26 Thread Meikel Brandmeyer
Hi, Am 26.07.2011 um 19:48 schrieb mmwaikar: > RT.load("lobos/core", true); > RT.load("lobos/schema", true); You should go through require.invoke(). Not RT.load(). > and called wrapper.createTable() then I get - (# lobos.core$create_STAR_@49431028> (quote {:classname "or

Re: Calling clojure from java.

2011-07-25 Thread Petr Gladkikh
On Tue, Jul 26, 2011 at 12:43 PM, mmwaikar wrote: > Hi, > > I am using the Lobos library - https://github.com/budu/lobos > In it there's a function create, which is called like this - (create db > (table :some-name)), where db is earlier defined as - (def db > {:classname "org.postgresql.Driv

Re: Calling Clojure from Java: unbound function

2011-03-28 Thread Mark Meyer
Nope. I moved the main code to ns hexadoku.core (generating package hexadoku, class core) and did the deftype in hexadoku (generating package hexadoku, class HexSolver). The error remains Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: Var hexadoku.core/search is unbound. a

Re: Calling Clojure from Java: unbound function

2011-03-28 Thread Ken Wesson
On Mon, Mar 28, 2011 at 8:46 AM, Mark Meyer wrote: > Hi. > I'm having problems calling clojure code from Java. Basically I deftype'd > (deftype HexSolver [] >   Solver >   (solve [this grid] (search (process-grid grid > and somewhere near the top of that file file > (defn search [foo] ...) > t

Re: Calling Clojure from Java

2010-12-22 Thread Laurent PETIT
2010/12/22 Mark Engelberg > I've decided to go with the old gen-class approach (mainly so I can > take advantage of the "state" option). > I'm running into a problem implementing Iterable. > The following lines in gen-class create a conflict: > :implements [java.lang.Iterable] > :methods [[it

Re: Calling Clojure from Java

2010-12-22 Thread Mark Engelberg
I've decided to go with the old gen-class approach (mainly so I can take advantage of the "state" option). I'm running into a problem implementing Iterable. The following lines in gen-class create a conflict: :implements [java.lang.Iterable] :methods [[iterator [] java.util.Iterator]] It com

Re: Calling Clojure from Java

2010-12-22 Thread Laurent PETIT
2010/12/22 Chas Emerick > > On Dec 22, 2010, at 4:58 AM, Laurent PETIT wrote: > > > There's also this issue raised in the bug tracker (by Chas Emerick I > presume ?) which is about adding a nice java facade for this kind of interop > (and thus also ensuring some independance towards clojure inter

Re: Calling Clojure from Java

2010-12-22 Thread Chas Emerick
On Dec 22, 2010, at 4:58 AM, Laurent PETIT wrote: > There's also this issue raised in the bug tracker (by Chas Emerick I presume > ?) which is about adding a nice java facade for this kind of interop (and > thus also ensuring some independance towards clojure internals). > > What about bringin

Re: Calling Clojure from Java

2010-12-22 Thread Alex Osborne
Mark Engelberg writes: > Looks easy, but your dance and speak methods don't return a value > which leaves a question in my mind... > > If the protocol implementation actually returns a value, do you have > to explicitly typecast it in Java from Object into the desired type? Yep, certainly. A Cl

Re: Calling Clojure from Java

2010-12-22 Thread Laurent PETIT
2010/12/22 Mark Engelberg > Looks easy, but your dance and speak methods don't return a value > which leaves a question in my mind... > > If the protocol implementation actually returns a value, do you have > to explicitly typecast it in Java from Object into the desired type? > Yes -- You rec

Re: Calling Clojure from Java

2010-12-22 Thread Mark Engelberg
Looks easy, but your dance and speak methods don't return a value which leaves a question in my mind... If the protocol implementation actually returns a value, do you have to explicitly typecast it in Java from Object into the desired type? Thanks, Mark -- You received this message because yo

Re: Calling Clojure from Java

2010-12-22 Thread Alex Osborne
Mark Engelberg writes: > Are there any examples available of creating a compiled > class/interface with deftype and defprotocol, and using these from > Java? It's pretty straightforward and works exactly how you might expect it to. Create a new project: $ lein new interop Define a type and

Re: Calling Clojure from Java

2010-12-22 Thread Meikel Brandmeyer
Hi, Am 22.12.2010 um 11:15 schrieb Mark Engelberg: > Are there any examples available of creating a compiled > class/interface with deftype and defprotocol, and using these from > Java? Protocols also define an interface which can be implemented by classes. For deftype this happens when you spe

Re: Calling Clojure from Java

2010-12-22 Thread Mark Engelberg
Are there any examples available of creating a compiled class/interface with deftype and defprotocol, and using these from Java? -- 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 po

Re: Calling Clojure from Java

2010-12-22 Thread Meikel Brandmeyer
Hi, Am 22.12.2010 um 10:56 schrieb Mark Engelberg: > On Wed, Dec 22, 2010 at 1:52 AM, Meikel Brandmeyer wrote: >> It is a little ugly, but works with any function, in particular static and >> protocol functions. If you want a less rough interface, you can still go the >> gen-class route from t

Re: Calling Clojure from Java

2010-12-22 Thread Laurent PETIT
2010/12/22 Mark Engelberg > On Wed, Dec 22, 2010 at 1:52 AM, Meikel Brandmeyer wrote: > > It is a little ugly, but works with any function, in particular static > and protocol functions. If you want a less rough interface, you can still go > the gen-class route from the article. But this will co

Re: Calling Clojure from Java

2010-12-22 Thread Laurent PETIT
2010/12/22 Meikel Brandmeyer > Hi, > > Am 22.12.2010 um 10:13 schrieb Mark Engelberg: > > > I'm trying to figure out how to bundle up some Clojure code into a jar > > to be accessed by someone in Java. > > > > My google search turned up this link: > > http://java.dzone.com/articles/java-clojure-i

Re: Calling Clojure from Java

2010-12-22 Thread Mark Engelberg
On Wed, Dec 22, 2010 at 1:52 AM, Meikel Brandmeyer wrote: > It is a little ugly, but works with any function, in particular static and > protocol functions. If you want a less rough interface, you can still go the > gen-class route from the article. But this will come at the cost of one level >

Re: Calling Clojure from Java

2010-12-22 Thread Meikel Brandmeyer
Hi, Am 22.12.2010 um 10:13 schrieb Mark Engelberg: > I'm trying to figure out how to bundle up some Clojure code into a jar > to be accessed by someone in Java. > > My google search turned up this link: > http://java.dzone.com/articles/java-clojure-interop-calling > which dates back to Clojure 1

Re: Calling Clojure from Java (again)

2009-01-23 Thread lpetit
On 23 jan, 03:00, Stuart Sierra wrote: > On Jan 22, 6:51 pm, Peter Wolf wrote: > > > However, if there is only one Clojure image used for references and the > > like, what happens if someone calls an infinite loop, or infinite > > recursion, in a file.  Does the Clojure server hang/blow up?   >

Re: Calling Clojure from Java (again)

2009-01-23 Thread lpetit
Hi, On 23 jan, 01:43, Peter Wolf wrote: > Hi Laurent, > 1) Does Eclipse use the server for resolving references? Currently, the only resolved references are those that come from a clojure environment launched by the user. So yes. When time comes to resolve references for the needs of the editor

Re: Calling Clojure from Java (again)

2009-01-22 Thread Peter Wolf
Thanks for the explanation Stuart, So it seems that all the Swank Clojure IDEs rely on files only containing "safe" code. I guess that's OK provided everyone understands this. Is is any way to only process the def's? For example processing the following would only define the symbol "foo", b

Re: Calling Clojure from Java (again)

2009-01-22 Thread Stuart Sierra
On Jan 22, 6:51 pm, Peter Wolf wrote: > However, if there is only one Clojure image used for references and the > like, what happens if someone calls an infinite loop, or infinite > recursion, in a file.  Does the Clojure server hang/blow up?   If you code an infinite loop, the SWANK server will

Re: Calling Clojure from Java (again)

2009-01-22 Thread Peter Wolf
Hi Laurent, My questions and current beliefs are: 1) Does Eclipse use the server for resolving references? 2) Is the server visible to the user, or hidden inside Eclipse? 3) Does the server call load-file? 4) Can the user break the server with bogus code in a file? 5) What happens if a file has

Re: Calling Clojure from Java (again)

2009-01-22 Thread lpetit
I'll also reply inline ... -> On 23 jan, 00:51, Peter Wolf wrote: > Thanks for the lengthy reply Laurent,  Replies in-line > > lpetit wrote: > > Peter, > > > We asked us the same question some weeks ago, on clojuredev. > > > We took the path to follow how eclipse launches a java application > >

Re: Calling Clojure from Java (again)

2009-01-22 Thread Peter Wolf
Thanks for the lengthy reply Laurent, Replies in-line lpetit wrote: > Peter, > > We asked us the same question some weeks ago, on clojuredev. > > We took the path to follow how eclipse launches a java application > when the user requires it to test it. > So we created a customized "launch config

Re: Calling Clojure from Java (again)

2009-01-22 Thread lpetit
Peter, We asked us the same question some weeks ago, on clojuredev. We took the path to follow how eclipse launches a java application when the user requires it to test it. So we created a customized "launch configuration" (sorry, eclipse jargon), that is just a classical eclipse java launcher w

Re: Calling Clojure from Java (again)

2009-01-22 Thread Michael Reid
On Thu, Jan 22, 2009 at 4:43 PM, Peter Wolf 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

Re: calling Clojure from Java

2009-01-04 Thread Stuart Sierra
On Jan 3, 8:13 pm, "Mark Volkmann" wrote: > I'd like to learn how to invoke Clojure code from a Java application. > I see at least two options. > > 1) From a Java application, read a text file containing Clojure code > and invoke specific functions it defines from Java code. Here's how I do it: