2009/10/15 Manuel Woelker <manuel.woel...@gmail.com> > > On Thu, Oct 15, 2009 at 5:48 AM, jng27 <jgran...@gmail.com> wrote: > > > > The following seems like it could be a common scenario when attempting > > to re-write parts of an existing Java application in Clojure. > > > > Let's say there exists Clojure code and Java code in the same > > 'project'. > > The Clojure code depends on the Java code in one direction and then > > the same is true in the opposite direction. > > Given that compiling Java and Clojure require separate and different > > compilation steps, how would circular dependencies be resolved ? > > e.g. A class is defined in the Clojure code that references Java > > classes(yet to be compiled) and the same is true for the Java code > > referencing classes defined in Clojure(yet to be compiled). It doesn't > > seem like compiling one before the other would solve this issue. > > > One possible solution that could be feasible is a two pass compilation > for clojure. The first compilation pass would basically just generate > the skeletons for the classes, i.e. just the method "heads" with each > method body being ignored and replaced with 'throw new > IllegalStateExccpetion("You are using first pass compilation > results")' or something along those lines. After this compilation pass > the Java classes can be compiled just fine, since all method calls can > be resolved. Finally the second pass of the clojure compilation fills > in the real method bodies, now that Java classes have been generated. > This should in theory work for most scenarios. >
But there is still the case of true circular dependencies between definitions, even of interfaces (let's not talk about implementation code) : A java interface JavaInterface with a method of signature "ClojureInterface foo()" A clojure generated interface (via gen-interface) ClojureInterface with a method of signature "JavaInterface bar()" Compiling JavaInterface requires ClojureInterface Compiling ClojureInterface requires JavaInterface chess mat if not done by the same ubiquitous compiler :-( --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---