Re: Optimizing JDBC code
Hi guys, I just want to learn using databases in Clojure, can you suggest where to start? by looking at source code of clojure.java.jdbc/ clojure.contrib.sql or there's some tutorial/document that I can start with? Thanks, Jaime On Aug 7, 1:51 pm, Shoeb Bhinderwala shoeb.bhinderw...@gmail.com wrote: I switched to clojure.java.jdbc. Found no difference at all. It is still about 10 times slower than java. On Aug 6, 8:54 pm, Sean Corfield seancorfi...@gmail.com wrote: On Sat, Aug 6, 2011 at 4:51 PM, Shoeb Bhinderwala shoeb.bhinderw...@gmail.com wrote: In one test case, I loaded 69,099 records. The Java code took 5 seconds to execute the query and create as many objects. Clojure code took 50.43 seconds. Try using clojure.java.jdbc instead of clojure.contrib.sql. c.j.j is the maintained version of c.c.sql and has had a number of enhancements such as removing all the Java reflection that was being done. -- Sean A Corfield -- (904) 302-SEAN An Architect's View --http://corfield.org/ World Singles, LLC. --http://worldsingles.com/ Railo Technologies, Inc. --http://www.getrailo.com/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) -- 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: Optimizing JDBC code
On Aug 7, 10:51 am, Shoeb Bhinderwala shoeb.bhinderw...@gmail.com wrote: I switched to clojure.java.jdbc. Found no difference at all. It is still about 10 times slower than java. I guess you can now get c.j.jdbc and put (time ...) wrappers in the call path in it to see where is the time mostly spent. Do share your findings on this list. Regards, Shantanu -- 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: Optimizing JDBC code
On Sat, Aug 6, 2011 at 10:51 PM, Shoeb Bhinderwala shoeb.bhinderw...@gmail.com wrote: I switched to clojure.java.jdbc. Found no difference at all. It is still about 10 times slower than java. Thanx. I wanted to eliminate reflection as the potential culprit. Have you tried Clojure 1.3, just to eliminate that variable as well? Then we can start to look at code within c.j.j... -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ Railo Technologies, Inc. -- http://www.getrailo.com/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) -- 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: Optimizing JDBC code
On Sat, Aug 6, 2011 at 11:04 PM, jaime xiejianm...@gmail.com wrote: Hi guys, I just want to learn using databases in Clojure, can you suggest where to start? by looking at source code of clojure.java.jdbc/ clojure.contrib.sql or there's some tutorial/document that I can start with? The tests in c.j.j are probably the closest to examples of use (in the test_jdbc.clj file). Then there's the autodoc: http://clojure.github.com/java.jdbc/ (it's a little out of date - I need to nudge Tom about that - and there are some formatting problems in the related docs). You might also consider Chas Emerick's book Clojure Programming, available in rough cuts, which has a whole chapter on database access in Clojure. An upcoming 2nd edition of Programming Clojure will also cover database access in Clojure. Not sure when the early access versions of that will be available. I'm also happy to chat with you about this off-list since I maintain c.j.j these days - s...@corfield.org. -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ Railo Technologies, Inc. -- http://www.getrailo.com/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) -- 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
ClojureScript broken
After introducing clojure to co-workers on Friday, one of them tried the ClojureScript quick start. He got this far: $ bin/cljsc hello.cljs '{:optimizations :advanced}' hello.js Exception in thread main java.lang.NullPointerException at clojure.java.io$as_relative_path.invoke(io.clj:391) at clojure.java.io$file.invoke(io.clj:403) at cljs.closure$compile_file.invoke(closure.clj:279) at cljs.closure$eval1164$fn__1165.invoke(closure.clj:322) at cljs.closure$eval1095$fn__1096$G__1086__1103.invoke(closure.clj:202) at cljs.closure$eval1151$fn__1152.invoke(closure.clj:335) at cljs.closure$eval1095$fn__1096$G__1086__1103.invoke(closure.clj:202) at cljs.closure$build.invoke(closure.clj:725) at user$eval1293.invoke(cljsc.clj:21) at clojure.lang.Compiler.eval(Compiler.java:6406) at clojure.lang.Compiler.load(Compiler.java:6843) at clojure.lang.Compiler.loadFile(Compiler.java:6804) at clojure.main$load_script.invoke(main.clj:282) at clojure.main$script_opt.invoke(main.clj:342) at clojure.main$main.doInvoke(main.clj:426) at clojure.lang.RestFn.invoke(RestFn.java:457) at clojure.lang.Var.invoke(Var.java:413) at clojure.lang.AFn.applyToHelper(AFn.java:172) at clojure.lang.Var.applyTo(Var.java:518) at clojure.main.main(main.java:37) That was embarrassing. Looks like a null check was dropped in this commit be81580202ba2347ba1fea1535118b8131cfab15https://github.com/clojure/clojurescript/commit/be81580202ba2347ba1fea1535118b8131cfab15#L0L222 . So, I step back one revision to 7f70ce1e07fd36b3dbf1696807e5b7a83f7283cf and try again... $ bin/cljsc hello.cljs '{:optimizations :advanced}' hello.js Exception in thread main java.lang.RuntimeException: No such var: comp/dependency-order-visit, compiling:(cljs/closure.clj:373) at clojure.lang.Compiler.analyze(Compiler.java:6176) at clojure.lang.Compiler.analyze(Compiler.java:6118) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3444) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6352) at clojure.lang.Compiler.analyze(Compiler.java:6157) at clojure.lang.Compiler.analyze(Compiler.java:6118) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3437) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6352) at clojure.lang.Compiler.analyze(Compiler.java:6157) at clojure.lang.Compiler.analyze(Compiler.java:6118) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3444) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6352) at clojure.lang.Compiler.analyze(Compiler.java:6157) at clojure.lang.Compiler.analyze(Compiler.java:6118) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5513) at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:5814) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6350) at clojure.lang.Compiler.analyze(Compiler.java:6157) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6338) at clojure.lang.Compiler.analyze(Compiler.java:6157) at clojure.lang.Compiler.analyze(Compiler.java:6118) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5513) at clojure.lang.Compiler$FnMethod.parse(Compiler.java:4949) at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3570) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6348) at clojure.lang.Compiler.analyze(Compiler.java:6157) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6338) at clojure.lang.Compiler.analyze(Compiler.java:6157) at clojure.lang.Compiler.access$100(Compiler.java:37) at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:492) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6350) at clojure.lang.Compiler.analyze(Compiler.java:6157) at clojure.lang.Compiler.analyze(Compiler.java:6118) at clojure.lang.Compiler.eval(Compiler.java:6410) at clojure.lang.Compiler.load(Compiler.java:6843) at clojure.lang.RT.loadResourceScript(RT.java:357) at clojure.lang.RT.loadResourceScript(RT.java:348) at clojure.lang.RT.load(RT.java:427) at clojure.lang.RT.load(RT.java:398) at clojure.core$load$fn__4636.invoke(core.clj:5377) at clojure.core$load.doInvoke(core.clj:5376) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invoke(core.clj:5191) at clojure.core$load_lib.doInvoke(core.clj:5228) at clojure.lang.RestFn.applyTo(RestFn.java:142) at clojure.core$apply.invoke(core.clj:602) at clojure.core$load_libs.doInvoke(core.clj:5262) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.core$apply.invoke(core.clj:602) at clojure.core$require.doInvoke(core.clj:5343) at clojure.lang.RestFn.invoke(RestFn.java:408) at user$eval1.invoke(cljsc.clj:9) at clojure.lang.Compiler.eval(Compiler.java:6406) at clojure.lang.Compiler.load(Compiler.java:6843) at clojure.lang.Compiler.loadFile(Compiler.java:6804) at clojure.main$load_script.invoke(main.clj:282) at clojure.main$script_opt.invoke(main.clj:342) at clojure.main$main.doInvoke(main.clj:426) at clojure.lang.RestFn.invoke(RestFn.java:457) at clojure.lang.Var.invoke(Var.java:413) at clojure.lang.AFn.applyToHelper(AFn.java:172) at clojure.lang.Var.applyTo(Var.java:518) at clojure.main.main(main.java:37) Caused
Re: clojurescript advanced compile error
So I'm assuming that the problem is in the use of .strobj, and there is some better way to convert the clojure map to a javascript map that outputs symbol style keys rather than string style keys - is there a simple way to do that? Would that fix the problem? Yeah, outputting symbol style keys fixes the problem. I use a simple macro that converts key/value pairs into code that constructs a JavaScript object: (js-object :akey avalue, :anotherkey 123) Implementation: (defmacro js-object [ kvs] (let [objname (gensym) setter (fn [[k v]] `(set! (. ~objname ~(- k name symbol)) ~v))] `(let [~objname (cljs.core/js-obj)] ~@(map setter (partition 2 kvs)) ~objname))) This works as long as all keys are known at compile time. When you're dealing with dynamic data, such as serverside generated ClojureScript data structures, the situation is a bit more problematic and you may need to use the workaround I mentioned in my previous post. On a related note, I've been working on a ClojureScript port of Hiccup, which provides an arguably more Clojure friendly API for generating HTML than Closure templates: https://github.com/teropa/hiccups -- 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: ClojureScript broken
The problem existed from Friday at about 10AM until Saturday morning when it was found and fixed. It only occurred when compiling something in advanced mode for the first time, which is probably why it was missed. There are some tests in place but we haven't yet got to the point where everything is automated. We are working toward that goal. On Aug 7, 4:03 am, ataggart alexclojuregr...@gmail.com wrote: After introducing clojure to co-workers on Friday, one of them tried the ClojureScript quick start. He got this far: $ bin/cljsc hello.cljs '{:optimizations :advanced}' hello.js Exception in thread main java.lang.NullPointerException at clojure.java.io$as_relative_path.invoke(io.clj:391) at clojure.java.io$file.invoke(io.clj:403) at cljs.closure$compile_file.invoke(closure.clj:279) at cljs.closure$eval1164$fn__1165.invoke(closure.clj:322) at cljs.closure$eval1095$fn__1096$G__1086__1103.invoke(closure.clj:202) at cljs.closure$eval1151$fn__1152.invoke(closure.clj:335) at cljs.closure$eval1095$fn__1096$G__1086__1103.invoke(closure.clj:202) at cljs.closure$build.invoke(closure.clj:725) at user$eval1293.invoke(cljsc.clj:21) at clojure.lang.Compiler.eval(Compiler.java:6406) at clojure.lang.Compiler.load(Compiler.java:6843) at clojure.lang.Compiler.loadFile(Compiler.java:6804) at clojure.main$load_script.invoke(main.clj:282) at clojure.main$script_opt.invoke(main.clj:342) at clojure.main$main.doInvoke(main.clj:426) at clojure.lang.RestFn.invoke(RestFn.java:457) at clojure.lang.Var.invoke(Var.java:413) at clojure.lang.AFn.applyToHelper(AFn.java:172) at clojure.lang.Var.applyTo(Var.java:518) at clojure.main.main(main.java:37) That was embarrassing. Looks like a null check was dropped in this commit be81580202ba2347ba1fea1535118b8131cfab15https://github.com/clojure/clojurescript/commit/be81580202ba2347ba1fe... . So, I step back one revision to 7f70ce1e07fd36b3dbf1696807e5b7a83f7283cf and try again... $ bin/cljsc hello.cljs '{:optimizations :advanced}' hello.js Exception in thread main java.lang.RuntimeException: No such var: comp/dependency-order-visit, compiling:(cljs/closure.clj:373) at clojure.lang.Compiler.analyze(Compiler.java:6176) at clojure.lang.Compiler.analyze(Compiler.java:6118) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3444) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6352) at clojure.lang.Compiler.analyze(Compiler.java:6157) at clojure.lang.Compiler.analyze(Compiler.java:6118) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3437) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6352) at clojure.lang.Compiler.analyze(Compiler.java:6157) at clojure.lang.Compiler.analyze(Compiler.java:6118) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3444) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6352) at clojure.lang.Compiler.analyze(Compiler.java:6157) at clojure.lang.Compiler.analyze(Compiler.java:6118) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5513) at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:5814) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6350) at clojure.lang.Compiler.analyze(Compiler.java:6157) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6338) at clojure.lang.Compiler.analyze(Compiler.java:6157) at clojure.lang.Compiler.analyze(Compiler.java:6118) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5513) at clojure.lang.Compiler$FnMethod.parse(Compiler.java:4949) at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3570) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6348) at clojure.lang.Compiler.analyze(Compiler.java:6157) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6338) at clojure.lang.Compiler.analyze(Compiler.java:6157) at clojure.lang.Compiler.access$100(Compiler.java:37) at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:492) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6350) at clojure.lang.Compiler.analyze(Compiler.java:6157) at clojure.lang.Compiler.analyze(Compiler.java:6118) at clojure.lang.Compiler.eval(Compiler.java:6410) at clojure.lang.Compiler.load(Compiler.java:6843) at clojure.lang.RT.loadResourceScript(RT.java:357) at clojure.lang.RT.loadResourceScript(RT.java:348) at clojure.lang.RT.load(RT.java:427) at clojure.lang.RT.load(RT.java:398) at clojure.core$load$fn__4636.invoke(core.clj:5377) at clojure.core$load.doInvoke(core.clj:5376) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invoke(core.clj:5191) at clojure.core$load_lib.doInvoke(core.clj:5228) at clojure.lang.RestFn.applyTo(RestFn.java:142) at clojure.core$apply.invoke(core.clj:602) at clojure.core$load_libs.doInvoke(core.clj:5262) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.core$apply.invoke(core.clj:602) at clojure.core$require.doInvoke(core.clj:5343) at clojure.lang.RestFn.invoke(RestFn.java:408) at user$eval1.invoke(cljsc.clj:9) at
Re: JSON library for clojure 1.3
Hi Arthur, I think thos would make a reasonable addition. If you'll make a JIRA ticket in the backlog, I'll see if I can push it forward. Ultimately, it will be Rich's decision, of course. Thanks, -Stuart Sierra clojure.com -- 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: (:key map) lookup vs accessor functions in large applications
Hi Martin, It's definitely a concern, keeping track of map keys and finding mis-typed names. I always use keywords instead of accessor functions, though. If there were functions, it's just one more thing to rename when refactoring. Pre/post conditions are your friend here. Write a validator function that checks the set of keys in a data structure, and you can use that on functions that have to deal with that structure. You can use the same function in your tests. -S -- 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: Optimizing JDBC code
Hi Shoeb, At this point, we probably need more data to give a meaningful answer. Different core data structures and different coding conventions can mean that the same code in Clojure and Java will behave quite differently. Try profiling your Clojure code with a Java profiler such as VisualVM (free) or YourKit (commercial). That will show you exactly which functions are taking the most time. Then we may be able to recommend ways to eliminate the most expensive calls in the Clojure version. -Stuart Sierra clojure.com -- 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
standalone indentation tool
hi! Is there a tool available that does indentation of clojure code and does not depend on an editor/IDE? we work on the same code together with different editors (eclipse+counterclockwise and emacs). We often reindent the other's code what leads to changes when we merge our commits with git. one way to fix this would be to reindent all source files with an indepedent tool before commiting. Does anybody have similar problems? Thanks in advance -- 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: ClojureScript broken
Alas, the current bug is in the head of master, and is unrelated to either advanced-mode or the absence of the destination file. Rather it appears to be due to the fact that the quick start doesn't pass an output file to cljsc, but rather redirects stdout to the destination file. When that occurs, compile-file is called, output-file is null. The previous version had an (if outputfile ...) check, the current one does not. -- 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: (:key map) lookup vs accessor functions in large applications
I have suffered the exact same problem in large projects. Clojure's associative style is extremely powerful and simple, together with powerful sequence handling functions you could hurt yourself. The fact that it's really easy to put together nested maps to represent your models, shouldn't be an excuse for lack of abstraction. In particular I have found that the Law of Demeter can be applied to a certain degree to nested clojure maps: (- car :wheels first :tire :pressure) This probably lacks abstraction, calling code needs to know every details about how to get the pressure starting from a car model. If at some point you decide to change your implementation and turn :wheels into a map instead of a list/vector, your code is broken. As always, it's a compromise between easy of use and resilience to change. One of the most important things you loose when you use accessor functions is map destructuring. I'm still learning in my large clojure projects the art of deciding when some code is too short to be true. I'd love to hear other opinions on the subject. -- 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: standalone indentation tool
The pprint function in the Clojure standard library indents Clojure source code. http://richhickey.github.com/clojure/clojure.pprint-api.html To get the result you are looking for, a tool would need to walk through all the *.clj files in your source directory and, for each file, read in the contents and pprint them back into the same file. Bonus points for careful error checking - printing into an intermediate buffer and reading it back in to check that nothing went wrong before overwriting the original file. This would make a good Leiningen plug-in, and doesn't sound too difficult to write. On Sun, Aug 7, 2011 at 9:17 AM, Philipp Steinwender philipp.a.steinwen...@gmail.com wrote: hi! Is there a tool available that does indentation of clojure code and does not depend on an editor/IDE? we work on the same code together with different editors (eclipse+counterclockwise and emacs). We often reindent the other's code what leads to changes when we merge our commits with git. one way to fix this would be to reindent all source files with an indepedent tool before commiting. Does anybody have similar problems? Thanks in advance -- 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: standalone indentation tool
On Sun, Aug 7, 2011 at 1:44 PM, Eric Lavigne lavigne.e...@gmail.com wrote: The pprint function in the Clojure standard library indents Clojure source code. http://richhickey.github.com/clojure/clojure.pprint-api.html To get the result you are looking for, a tool would need to walk through all the *.clj files in your source directory and, for each file, read in the contents and pprint them back into the same file. Bonus points for careful error checking - printing into an intermediate buffer and reading it back in to check that nothing went wrong before overwriting the original file. This would make a good Leiningen plug-in, and doesn't sound too difficult to write. Er, won't you lose all comments and have reader macros expanded if you use read/pprint to do the transformation? -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language of a true hacker. Not as clumsy or random as C++; a language for a more civilized age. -- 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: standalone indentation tool
The pprint function in the Clojure standard library indents Clojure source code. http://richhickey.github.com/clojure/clojure.pprint-api.html Er, won't you lose all comments and have reader macros expanded if you use read/pprint to do the transformation? Oops. I think I could live without comments (Docstrings all the way!), but I don't want #(+ % 1) turning into (fn* [p1__945#] (+ p1___945# 1)) -- 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: ClojureScript broken
Sorry. I didn't notice that you were compiling a single file. That is a different problem from the one I was referring to. You were right about the cause as well. That particular problem is now fixed. Thank you for reporting it. On Aug 7, 11:52 am, ataggart alexclojuregr...@gmail.com wrote: Alas, the current bug is in the head of master, and is unrelated to either advanced-mode or the absence of the destination file. Rather it appears to be due to the fact that the quick start doesn't pass an output file to cljsc, but rather redirects stdout to the destination file. When that occurs, compile-file is called, output-file is null. The previous version had an (if outputfile ...) check, the current one does not. -- 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: JSON library for clojure 1.3
Perhaps we can put these in core.incubator for now so they have a place to live in the 1.3 world. The function for this library is the staging of things that are destined for core itself, so it might not be a bad idea. Cheers, Aaron Bedra -- Clojure/core http://clojure.com On 08/07/2011 10:19 AM, Stuart Sierra wrote: Hi Arthur, I think thos would make a reasonable addition. If you'll make a JIRA ticket in the backlog, I'll see if I can push it forward. Ultimately, it will be Rich's decision, of course. Thanks, -Stuart Sierra clojure.com -- 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
ClojureScript macro import
Is it possible to use macros within ClojureScript without having to fully reference them? Right now I have (ns hack.cljs.hello (:require-macros [d3-macros :as d3m])) and have to use the form (d3m/my-macro ...) Ideally I could just say (my-macro ...) Is this possible? Bonus question: the macro I want to use is for extending a native js library that uses jQuery-style chained calls. In particular, my macro expands a map into individual function calls so that instead of obj.attr(a, 1) .attr(b, 2) I can write in ClojureScript (- obj (.attr {a 1 b 2})) So, the bonus question is: can I import a macro with a . prefix so all of the magic is behind the scenes and I don't have to think about whether I need to use (.attr obj a 1) or (my-attr obj {a 1 b 2}) -- 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: ClojureScript broken
Great. BTW, are these warnings expected: $ cat hello.cljs (ns hello) (defn ^:export greet [n] (str Hello n)) $ bin/cljsc hello.cljs '{:optimizations :advanced}' hello.js Aug 7, 2011 12:17:42 PM com.google.javascript.jscomp.LoggerErrorManager println WARNING: /Users/ataggart/projects/clojurescript/out/cljs/core.js:3564: WARNING - dangerous use of the global this object {return this.call(null,(args[0])); ^ Aug 7, 2011 12:17:42 PM com.google.javascript.jscomp.LoggerErrorManager println WARNING: /Users/ataggart/projects/clojurescript/out/cljs/core.js:3566: WARNING - dangerous use of the global this object {return this.call(null,(args[0]),(args[1])); ^ Aug 7, 2011 12:17:42 PM com.google.javascript.jscomp.LoggerErrorManager printSummary WARNING: 0 error(s), 2 warning(s) If so, it might be worth noting that in the quick start documentation lest someone get worried. -- 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: ClojureScript broken
Those warnings have been around for a couple of weeks now. In that sense they are expected. I will see what I can find out about them. On Aug 7, 3:19 pm, ataggart alexclojuregr...@gmail.com wrote: Great. BTW, are these warnings expected: $ cat hello.cljs (ns hello) (defn ^:export greet [n] (str Hello n)) $ bin/cljsc hello.cljs '{:optimizations :advanced}' hello.js Aug 7, 2011 12:17:42 PM com.google.javascript.jscomp.LoggerErrorManager println WARNING: /Users/ataggart/projects/clojurescript/out/cljs/core.js:3564: WARNING - dangerous use of the global this object {return this.call(null,(args[0])); ^ Aug 7, 2011 12:17:42 PM com.google.javascript.jscomp.LoggerErrorManager println WARNING: /Users/ataggart/projects/clojurescript/out/cljs/core.js:3566: WARNING - dangerous use of the global this object {return this.call(null,(args[0]),(args[1])); ^ Aug 7, 2011 12:17:42 PM com.google.javascript.jscomp.LoggerErrorManager printSummary WARNING: 0 error(s), 2 warning(s) If so, it might be worth noting that in the quick start documentation lest someone get worried. -- 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: standalone indentation tool
On Aug 7, 11:10 am, Eric Lavigne lavigne.e...@gmail.com wrote: The pprint function in the Clojure standard library indents Clojure source code. http://richhickey.github.com/clojure/clojure.pprint-api.html Er, won't you lose all comments and have reader macros expanded if you use read/pprint to do the transformation? Oops. I think I could live without comments (Docstrings all the way!), but I don't want #(+ % 1) turning into (fn* [p1__945#] (+ p1___945# 1)) You would also lose all the newlines, and there's no way pprint would put them in places as intelligent as you would. -- 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: standalone indentation tool
On Sun, Aug 7, 2011 at 6:17 AM, Philipp Steinwender philipp.a.steinwen...@gmail.com wrote: Is there a tool available that does indentation of clojure code and does not depend on an editor/IDE? we work on the same code together with different editors (eclipse+counterclockwise and emacs). We often reindent the other's code what leads to changes when we merge our commits with git. one way to fix this would be to reindent all source files with an indepedent tool before commiting. I've tried pprint and found it lacking as it inserts newlines in awkward places apart from the medatada/comments issue mentioned. I think your best bet is to use Emacs from the command-line. Even if people edit outside Emacs, it's easy to invoke for indentation purposes: $ emacs --eval (progn (find-file \badly_indented.clj\) (indent-region (point-min) (point-max)) (untabify (point-min) (point-max)) (save-buffer) (kill-emacs)) -Phil -- 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: JSON library for clojure 1.3
Wouldn't string.incubator be better, for possible inclusion in clojure.string (rather than core.incubator for clojure.core). Seems more consistent... Otherwise things will be moving from c.contrib.foo to c.core.incubator and then (possibly) to c.foo... On Sun, Aug 7, 2011 at 12:17 PM, Aaron Bedra aaron.be...@gmail.com wrote: Perhaps we can put these in core.incubator for now so they have a place to live in the 1.3 world. The function for this library is the staging -- 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: ClojureScript broken
WARNING - dangerous use of the global this object These warnings should now be gone (thanks to Fogus). On Aug 7, 3:19 pm, ataggart alexclojuregr...@gmail.com wrote: Great. BTW, are these warnings expected: $ cat hello.cljs (ns hello) (defn ^:export greet [n] (str Hello n)) $ bin/cljsc hello.cljs '{:optimizations :advanced}' hello.js Aug 7, 2011 12:17:42 PM com.google.javascript.jscomp.LoggerErrorManager println WARNING: /Users/ataggart/projects/clojurescript/out/cljs/core.js:3564: WARNING - dangerous use of the global this object {return this.call(null,(args[0])); ^ Aug 7, 2011 12:17:42 PM com.google.javascript.jscomp.LoggerErrorManager println WARNING: /Users/ataggart/projects/clojurescript/out/cljs/core.js:3566: WARNING - dangerous use of the global this object {return this.call(null,(args[0]),(args[1])); ^ Aug 7, 2011 12:17:42 PM com.google.javascript.jscomp.LoggerErrorManager printSummary WARNING: 0 error(s), 2 warning(s) If so, it might be worth noting that in the quick start documentation lest someone get worried. -- 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: (:key map) lookup vs accessor functions in large applications
2011/8/7 Sebastián Galkin paras...@gmail.com (- car :wheels first :tire :pressure) This probably lacks abstraction, calling code needs to know every details about how to get the pressure starting from a car model. If at some point you decide to change your implementation and turn :wheels into a map instead of a list/vector, your code is broken. I think this is a bit of a straw man: if you want the pressure of a tire, you have to know how to describe which wheel/tire you want out of the four (or more) on a vehicle. Whatever model you decide for that has an API and that API has to be public to be useful and therefore code will come to depend on it. Complaining that you can't change your implementation in this case is really complaining that you can't change the _API_. If you use keywords, you can always choose to modify the model to implement ILookup so you have control over what (:key model) does - including supporting keyword name changes etc. If you use a vector, I guess it's a bit harder to swap it out depending on what API you really use on it. -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ Railo Technologies, Inc. -- http://www.getrailo.com/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) -- 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