Help: Some AOT-compiled classes can't be required
I have a testing tool called midje. Here's the project file for a trivial use of it: (defproject midje-aot "1.0.0-SNAPSHOT" :description "FIXME: write" :dependencies [[org.clojure/clojure "1.2.0"] [org.clojure/clojure-contrib "1.2.0"] [midje "1.2-alpha3"]] :dev-dependencies [[swank-clojure "1.2.1"]] :aot [midje-aot.core]) Here's the code: (ns midje-aot.core (:use midje.sweet)) (defn do-something [n] (inc n)) I compile the project like this, under either Clojure 1.2.0 or 1.2.1: 923 $ lein compile Compiling midje-aot.core 924 $ This creates a classes/midje/ directory full of class files. (QUESTION: Why create a bunch of class files when Midje is in lib/ as a jar file?) When I run the repl in this project, I can load some but not all of the Midje classes: 503 $ lein repl REPL started; server listening on localhost:32259. user=> (require 'midje.checkers.simple) nil user=> (require 'midje.fakes) java.lang.ExceptionInInitializerError (NO_SOURCE_FILE:0) user=> (require 'midje.fakes) java.lang.NoClassDefFoundError: Could not initialize class midje.fakes__init (NO_SOURCE_FILE:0) user=> Note that the identical `require` statement failed in two different ways. I can't see any obvious differences between the class files generated from the two Clojure source files. (They both have *__init.class and *__4410__auto__.class) You can see the list of files here: https://gist.github.com/1040887 The two files both look pretty ordinary to me: https://github.com/marick/Midje/blob/v.1.2-alpha3/src/midje/checkers/simple.clj https://github.com/marick/Midje/blob/v.1.2-alpha3/src/midje/fakes.clj Any ideas for either preventing AOT compiling for the jar file or fixing this problem some other way? - Brian Marick, Artisanal Labrador Contract programming in Ruby and Clojure Occasional consulting on Agile www.exampler.com, www.twitter.com/marick -- 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
Re: User.clj and set!
On Jun 19, 5:11 pm, Andreas Liljeqvist wrote: > Thanks for the answer. > Would there be any problems associated with changing the root bindings? > It means that every thread in the whole JVM would get that value, but that's probably what you want. It also means that if someone else changed the root value to a different value, all the threads would get that new value, instead of the one you want. In the case of this particular var none of this may be an issue. Paul -- 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
Re: Generating API docs for clojure 1.3 projects
Hi Tom, Autodoc is superb! However having run into dependency issues with Autodoc myself, I think it would be cool if you can specify Clojure and Contrib JARs as only dev-dependencies so that they don't clash with the ones the user depends on too. Just an idea. Regards, Shantanu On Jun 22, 5:55 am, Tom Faulhaber wrote: > Hi Tassilo, > > Autodoc is usually the tool you want, I think. I'm the author of that > tool and I've been very busy on other stuff lately, so I haven't but > together a 1.3 release. > > I'll try to get to that pretty soon so that you'll have something to > use. I don't know why one you built should fail, but I haven't tried > it myself. At first look, maybe it's the new numeric stuff or maybe it > still has a bad dependency chain in it's project.clj. > > Tom > > On Jun 20, 11:22 pm, Tassilo Horn wrote: > > > > > > > > > Hi all, > > > I'd like to generate some API docs for my clojure 1.3 lib. The way to > > go seems to be autodoc. However, with version 0.7.1 (the stable > > release), my leiningen fails to fetch the required dependencies. > > > On clojars, there are several other forks/versions, but for all of them > > including a self-built autodoc git checkout, "lein autodoc" fails with > > > java.lang.NoSuchMethodError: clojure.lang.Numbers.lt(II)Z > > > I also had a look at the contrib libs, which also has some gen-html-docs > > library. But for clojure 1.3, one should use the new modular contrib > > library, which doesn't contain that anymore... > > > So my question: does anyone have a working setup for generating HTML API > > docs for a project using clojure 1.3 that he wants to share with me? I > > really don't need anything fancy, just some browsable, linked HTML > > pages. > > > Bye, > > Tassilo -- 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
Re: clojure.contrib.sql and multiple connections
Naturally, a connection pool is to clojure database programming what baked beans are to ham and egg. I am thinking that the size of the connection pool must be determined by the number of workers that may simultaneously work in the connected database, but that's a detail. thank you very much for the enligthenment. On 21 June 2011 13:09, Shantanu Kumar wrote: > The canonical way to use databases with JDBC is to have connection- > pooled DataSource (instead of Connection) instances. That will make > sure connections are not created unnecessarily are are re-used across > operations. This may help create those: > > https://bitbucket.org/kumarshantanu/clj-dbcp/src/tip/README > > Even when you are using DataSource, executing SQL involves creating > Statement or PreparedStatement instances and ResultSet instances which > is expensive. When you are performing batch operations (as it sounds > like you are doing) you may need to create lazy sequences and keep > fetching data from them so that you don't exhaust all of the heap. > `resultset-seq` creates a lazy sequence that you can keep reading > from. > > (sql/with-connection source-conn > (with-query-results source ["SELECT id FROM emp WHERE salary > ?" > 1000] > ... > ;; here `source` contains a lazy seq (from ResultSet) that won't > blow the heap > ;; read from `source` sequentially and write results to target > ... > )) > > Hope that helps. > > Regards, > Shantanu > > On Jun 21, 3:18 pm, Matthias Cords wrote: >> thank you, this sounds very reasonable. very often there >> is more than one piece of data to copy back and forth. so >> typically i do a sql select, then put that to destination >> data store, do another sql select and put to destination, >> ... and so forth. from my understanding >> (sql/with-connection ...) opens a connection and closes it >> when finished. this would mean that either i load the entire >> source data set into memory at once (impossible), or the >> connection to the target database is being repeatedly >> opened/closed - right? these two situations are what i am >> looking to avoid. >> >> On 20 June 2011 19:07, Shantanu Kumar wrote: >> >> >> >> >> >> >> >> > Write different functions for source and target? >> >> > (declare source-conn) >> > (declare target-conn) >> >> > (defn get-source-data >> > [] >> > (sql/with-connection source-conn >> > ...)) >> >> > (defn put-target-data >> > [data] >> > (sql/with-connection target-conn >> > ...)) >> >> > (defn data-transfer >> > [] >> > (let [source (get-source-data)] >> > (put-target-data source) >> > ...)) >> >> > This approach may also save against concurrency issues just in case >> > (`binding` isolates on a ThreadLocal basis and isn't propagated across >> > threads.) >> >> > Regards, >> > Shantanu >> >> > On Jun 20, 5:48 pm, MattC wrote: >> >> Hi, >> >> >> I am writing a lot of programs shuffling data between databases and >> >> would like to use Clojure for some of it. >> >> >> While investigating the sql contrib library I was wondering whether >> >> there is a supported way to have more than one database connection >> >> open at any one time. >> >> >> My initial approach was >> >> >> (use '[clojure.contrib.sql :as sql]) >> >> >> (sql/with-connection {...} >> >> (let [source-connection (sql/connection)] >> >> (sql/with-connection {...} >> >> (let [target-connection (sql/connection)] >> >> (put-some-data (binding [sql/* source-connection] (get- >> >> some-data >> >> >> well, roughly. but i am basically having a hard time switching >> >> between two open connections. >> >> >> is there a way ? >> >> > -- >> > 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 > > -- > 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 -- 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
Re: Re: eval and load-string behavior
Yes, unless you wrap it in another macro. (defmacro a [] (vec (map (fn [x] `(load-string-here ~x)) ["1" "2" "3" "4"]))) => (a) [1 2 3 4] But it's still pretty useless, unless macros are to replace functions... Jonathan On Wed, Jun 22, 2011 at 8:20 AM, Meikel Brandmeyer wrote: > Hi, > > note that this breaks down as soon as you don't provide a literal string. > And if you provide a literal string, you can provide the form directly > anyway... > > 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 > -- 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