2010-08-16
| 00:00 | technomancy | mmarczyk: that's a lot of text for a forum post; have you thought about submitting it as part of the official docs? |
| 00:00 | mmarczyk | technomancy: I've only just finished writing it |
| 00:00 | mmarczyk | turns out to be just under 10 KiB of text |
| 00:01 | Raynes | technomancy: You haven't seen many of his answers on stackoverflow, have you? |
| 00:01 | Raynes | ;) |
| 00:01 | mmarczyk | not exactly my first estimate for an SO answer, so I'm at a loss as to what to do with it |
| 00:01 | Raynes | The only way I can ever get an accepted Clojure answer on SO is if I manage to beat him to the punch. I literally set my feed reader to update the Clojure SO feed every 5 minutes just for that purpose. |
| 00:01 | Raynes | ._. |
| 00:02 | Raynes | He's a beast. |
| 00:03 | mmarczyk | :-) |
| 00:03 | mmarczyk | funny, I always check it manually :-) |
| 00:04 | Raynes | You're a stronger man than I. |
| 00:24 | notsonerdysunny | Exception in thread "main" java.lang.ClassNotFoundException: com.jcraft.jsch.JSch (push.clj:1) at clojure.lang.Compiler.eval(Compiler.java:5435) I tried to do a lein push on the lein-clojars repo I cloned from github .. and I got the above error .. I am having trouble pushing my jar files to the clojars repo via "lein push" .. can anybody help? |
| 00:25 | technomancy | grrr... I've been blocked for 3 days fighting the maven API for this one remaining lein 1.3 feature, and I just realized it's really easy to do in the ant API |
| 00:25 | notsonerdysunny | technomancy are you responding to me? |
| 00:26 | technomancy | notsonerdysunny: oh, no |
| 00:26 | notsonerdysunny | sorry .. I just logged in .. |
| 00:26 | technomancy | notsonerdysunny: I recommend against "lein push"; the java SSH libraries are not compatible with all key types. |
| 00:27 | technomancy | just make a shell alias for "lein pom && lein jar && scp pom.xml myproject.jar clojars@clojars.org" |
| 00:27 | notsonerdysunny | oh ok |
| 00:28 | notsonerdysunny | I found a clojars@clojars.org: on the website .. (note the trailing ':') .. so am I not supposed to have that ':' |
| 00:28 | technomancy | oh right; I should have put on a : |
| 00:28 | technomancy | my bad |
| 00:29 | notsonerdysunny | Is this how one would do it if I want to to upload it to my group? |
| 00:29 | technomancy | you need to set the group in project.clj to org.clojars.notsonerdysunny before you do anything |
| 00:30 | technomancy | unless you are a maintainer |
| 00:33 | technomancy | notsonerdysunny: actually I'm curious why you are trying to publish your own version of that library to begin with |
| 00:42 | notsonerdysunny | technomancy .. the reason is I have the jar files for jReality ... I didnot find it on any repositories .. I wanted to have a easily reproducible builds .. do you have a suggestion? |
| 00:42 | notsonerdysunny | jReality also has native-lib dependencies... |
| 00:42 | technomancy | notsonerdysunny: oh, I thought you said you were pushing the lein-clojars project |
| 00:42 | technomancy | never mind; carry on |
| 00:46 | notsonerdysunny | technomancy .. I was just trying to get it working on lein-clojars before I tried the jReality |
| 01:04 | technomancy | leiningen 1.3 RC1 tomorrow |
| 01:04 | technomancy | it'll be HEAD from right now, I'm just too lazy to tag it and update NEWS tonight =) |
| 01:06 | notsonerdysunny | these are the basic jars I want to upload .. |
| 01:06 | notsonerdysunny | |-- jReality.jar |
| 01:06 | notsonerdysunny | `-- jni |
| 01:06 | notsonerdysunny | |-- jReality-jni-linux32.zip |
| 01:06 | notsonerdysunny | |-- jReality-jni-linux64.zip |
| 01:06 | notsonerdysunny | |-- jReality-jni-macosx.zip |
| 01:06 | notsonerdysunny | |-- jReality-jni-win32.zip |
| 01:06 | notsonerdysunny | `-- jReality-jni-win64.zip |
| 01:06 | notsonerdysunny | can anybody give me a starting point for writing a project file for this? |
| 01:15 | amalloy | is there a builtin function for this? (zipmap my-keys (map f my-keys)) |
| 01:16 | amalloy | still learning clojure, and this seems useful/general enough that it must exist, but i don't know where to look |
| 01:23 | notsonerdysunny | all the zip files contain .so/.dll/.jnilib files.. |
| 01:48 | amalloy | notsonerdysunny: not a clojure expert here but maybe i can help. what problem are you having with your library files? |
| 01:50 | notsonerdysunny | amalloy I want to juse jReality in my project .. and jReality is not available in any public repositories.. it is available for download though .. so, i would like to upload the jar to my group in clojars.org |
| 01:50 | notsonerdysunny | and also, this library has native dependency files... |
| 01:50 | amalloy | ah. way above my level of competence so far, i'm afraid |
| 01:50 | amalloy | come back in a few months and i'll know how :) |
| 02:01 | notsonerdysunny | :) thanks |
| 02:56 | LauJensen | Good morning all |
| 03:08 | amalloy | morning laugensen |
| 03:08 | amalloy | btw laujensen i asked this earlier but nobody seemed to be around: is there a builtin function for this? (zipmap my-keys (map f my-keys)) |
| 03:09 | LauJensen | Not that Im aware |
| 03:09 | LauJensen | but if there was, it would certainly be written like that, so grep the src/ of clojure |
| 03:10 | amalloy | hah, good point |
| 03:12 | amalloy | hm, i don't see it. i'm surprised, since it seems so useful (avoids repeating my-keys) and generic. am i wrong about its usefulness? (fairly new to clj so expecting to be wrong a lot) |
| 03:13 | notsonerdysunny | for those of you interested in jReality (visualization and realtime graphics and scenegraph library.. ) you can use [org.clojars.sunilnandihalli/jreality-native-deps "current"] |
| 03:13 | LauJensen | amalloy: I think its useful, so Im guessing a few people have a variant lying around in their local projects |
| 03:15 | amalloy | okay. i'll put it on the google group, ask if someone wants to add it to one of their c.contrib packages or if i should learn how to write my own |
| 03:15 | amalloy | (and try to think of another useful thing or two, so that my package is more than two lines long!) |
| 03:27 | LauJensen | amalloy: Have a look http://clojure.org/contributing |
| 03:33 | amalloy | thanks Laujensen |
| 03:39 | LauJensen | np |
| 05:45 | esj | Morning All. |
| 05:49 | LauJensen | Morning |
| 08:41 | bartj | how do I go about investigating/improving the performance of a system written in Clojure ? |
| 08:42 | LauJensen | bartj: There are a few things to be mindful of, depending a little on the system. Since you're functional, keep allocation low, avoid reflection at all costs, tweak heavy math to work with primitives |
| 08:43 | bartj | like which function is taking the maximum time/number of objects allocated in the function, etc. |
| 08:44 | bartj | the system is extremely heavy in math and computes a lot of scores for two records in a database |
| 08:46 | AWizzArd | rhickey: any chance that http://www.assembla.com/spaces/clojure/tickets/394 will go into 1.2? |
| 08:47 | LauJensen | bartj: sequence of map, filter, remove etc can be sped up by switching to 'for' instead. But what you need to do is profile and find out where you're spending time, then fix those hotspots |
| 08:47 | rhickey | AWizzArd: no |
| 08:47 | LauJensen | bartj: You can check out my blogpost on fluid dynamics for a reference |
| 08:48 | LauJensen | rhickey: How about the work you did on statics/primitives, is that going in ? |
| 08:48 | rhickey | LauJensen: not in 1.2, betas are 'feature complete', so no features not in the betas/rcs |
| 08:48 | LauJensen | alright |
| 08:49 | rhickey | is there a way to get github to show you the source tree as of a commit (i.e. not the commit diffs)? |
| 08:50 | bartj | LauJensen, thanks a lot - will have a look at this - http://www.bestinclass.dk/index.clj/2010/03/functional-fluid-dynamics-in-clojure.html |
| 08:50 | LauJensen | rhickey: Dont know about github, but if you use Magit locally, just move the cursor down to that commit and hit 'o', then do what you want to do, and when you're done, hit 'o master' to switch back, IIRC |
| 08:50 | AWizzArd | rhickey: when I click on http://github.com/richhickey/clojure/commits/master/ I see the history. On the right side it offers me "commit", "tree" and "parent". Try to click on "tree" |
| 08:51 | LauJensen | s/master/HEAD/ |
| 08:51 | sexpbot | rhickey: Dont know about github, but if you use Magit locally, just move the cursor down to that commit and hit 'o', then do what you want to do, and when you're done, hit 'o HEAD' to switch back, IIRC |
| 08:53 | rhickey | AWizzArd: thanks |
| 08:56 | rhickey | fogus_: the past is immutable :) http://github.com/clojure/clojure/tree/da14d89c1936e9de6eacb9c12dd9e6a0d68a0829/src |
| 08:57 | rhickey | fogus_: see the 'lisp' dir |
| 08:57 | rhickey | fogus_: the first Clojure compiler was in CL and generated Java/C# source |
| 08:58 | fogus_ | rhickey: Great! Thank you for that. I should have known. :-) |
| 08:59 | rhickey | fogus_: there was work that preceded sourceforge that is only on my machines |
| 08:59 | fogus_ | rhickey: Does that (your machine) include the predicate dispatch code? |
| 09:00 | rhickey | fogus_: yes |
| 09:00 | AWizzArd | oho, a CL compiler |
| 09:00 | fogus_ | rhickey: Any plans to revisit that? |
| 09:00 | rhickey | and a version of the compiler that used more CLOS |
| 09:01 | LauJensen | rhickey: You opening a museum ? :) |
| 09:02 | rhickey | fogus_: I didn't prefer the CLOS version to the one with more ccase |
| 09:02 | AWizzArd | I remember there was this jfly tool |
| 09:03 | rhickey | fogus_: It was just a prototype based on Chambers/Chen. I've invited people to implement Chambers/Chen (http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.47.4553) several times, but no takers |
| 09:03 | rhickey | fogus_: mine added a mini-prolog to do implication |
| 09:03 | fogus_ | rhickey: Interesting. I think I missed that invitation. |
| 09:05 | rhickey | http://groups.google.com/group/clojure/msg/e03f9874ccab7f0f |
| 09:05 | rhickey | http://groups.google.com/group/clojure/msg/fd7022af9c1b4891 |
| 09:07 | fogus_ | rhickey: I've done a (simplified) pred-dispatch implementation in grad school, but it's been quite a while. Maybe I can dig that up and see where it takes me. |
| 09:08 | rhickey | fogus_: Chambers/Chen is pretty easy, but hardwires a few things. The trick is to make it open |
| 09:08 | fogus_ | Noted. |
| 09:09 | rhickey | but a fully open dispatch system would include a little logic engine, and thus an unavoidable amount of overhead. The flexibility would be fantastic though |
| 09:10 | fogus_ | I'm working on a unification lib at the moment that I was hoping to use as the basis for a little logic engine, so I suppose I'm on that path already. |
| 09:12 | rhickey | fogus_: so, the next trick is, does your logic engine have clause order dependence (like Prolog)? If so, not a good match for open predicate dispatch. occurs check/tabling, more overhead |
| 09:14 | fogus_ | rhickey: Nice points. I will make sure that it does not. |
| 09:28 | chouser | I sure do pick the mornings to be out. :-P |
| 09:31 | LauJensen | hehe |
| 10:01 | arkh | I want to use named arguments in a function - is it idiomatic to use Maps with Keywords (w/ destructuring) or is there a better way? |
| 10:03 | AWizzArd | arkh: that is okay, but you can also say & args and do an apply hash-map on that. And in Contrib there is also something. |
| 10:03 | arkh | AWizzArd: thank you |
| 10:03 | raek | it is possible to use map destructuring in & args nowadays |
| 10:05 | raek | something like [a b & {:keys [foo bar], :as opts, :or {:foo 1, :bar 2}}] |
| 10:05 | raek | s/{:foo 1, :bar 2 |
| 10:05 | raek | ahem |
| 10:06 | raek | replace :or {:foo 1, :bar 2} with :or {foo 1, bar 2} |
| 10:07 | arkh | I'll look into that, too; thanks raek |
| 10:09 | fogus_ | arkh: http://gist.github.com/526993 |
| 10:12 | esj | fogus_: I object. All of this makes life too easy. Where's the sense of accomplishment ?! :P |
| 10:14 | arkh | thanks fogus_ :) I also look forward to the wood pulp version of your book. |
| 10:26 | bartj | LauJensen, are macros faster than functions ? |
| 10:28 | chouser | macros run at compile time not runtime |
| 10:28 | chouser | so in a sense, by the time your runtime code is running, macros take no time at all |
| 10:29 | bartj | so if I needed to speed up something, I should probably just convert all the (anonymous?) functions to macros ? |
| 10:29 | bartj | though I know this will be severely criticised |
| 10:32 | bartj | no, the above question is not a troll :( |
| 10:33 | chouser | well, the code *generated* by a macro still runs at runtime. |
| 10:33 | chouser | if all your macro does is produce the same code that you would have written by hand, it won't improve your performance at all. |
| 10:35 | chouser | the way to use macros to improve performances is: first, improve performance other ways -- this is a corollary to the first rule of writing a macro (don't write a macro) |
| 10:36 | chouser | second, find things that are being computed at runtime that could be computed at compile time instead, and implement those at compile time. |
| 10:37 | bartj | chouser, is there any performance related tips in "Joy of Clojure" ? |
| 10:37 | bartj | s/is/are |
| 10:38 | bartj | esj, which chapter ? |
| 10:39 | esj | 11 |
| 10:45 | chouser | reaching peak performance for you clojure program could probably be a whole separate book |
| 10:46 | chouser | and it'd be mostly about java |
| 10:47 | fogus_ | LOL |
| 10:50 | chouser | I'm not even sure I could work up the motivation to read such a book, let alone write it. |
| 10:50 | LauJensen | bartj: The only reason I rely heavily on Macros for that post, is because that way I can avoid the boxing of numbers, since everything passed between functions gets boxed. |
| 10:54 | LauJensen | (hopefully this will change in 1.3, and then I'll probably rewrite the blogpost) |
| 10:55 | bartj | LauJensen, ok |
| 10:55 | bartj | though I don't understand what you mean by "boxing" |
| 10:56 | bartj | you definitely don't mean the sporting kind... |
| 10:57 | AWizzArd | bartj: putting numbers into a container, a box. |
| 10:57 | AWizzArd | Instead of reaching around numbers, you reach around that box which contains the number. |
| 10:59 | LauJensen | bartj: We want to work with java primitives like 'Integer', but thanks to the compiler that int gets wrapped in an Object, slowing the computations down by a factor 10x or so |
| 11:00 | bartj | LauJensen, ok and the way around that problem is to avoid reflection - am I right ? |
| 11:02 | kensho | I have a problem with leiningen. When I run "lein repl" I want it to use the clojure version which I specified as dependency in my project.clj. Out of the box it launches with 1.2.0-beta1. I modified the classpath so that the specified clojure dep comes first and it works as expected. However when I now change the version in project.clj and then run "lein deps" I get an IOException about not being able to delete the clojure jars in |
| 11:02 | kensho | lib. When I manually delete them it works fine. What am I missing? |
| 11:06 | LauJensen | bartj: wrong. Reflection is for guessing types, not for working with primitives. Reflection is also a huge performance hit, but its easily avoided by compiling your code with (set! *warn-on-reflection* true), and then adding ^Integer hints where appropriate |
| 11:13 | arohner | bartj: when working with primitives, the values are pushed onto the stack. When java does arithmetic on them, it copies the value from the stack, pushes into a hardware register, and then calls the native math instruction. Very fast. |
| 11:13 | arohner | bartj: when a number is "boxed", that means the value is stored in an instance of a class, in main memory. To do arithmetic, it has to read from main memory rather than the stack, so it's much slower |
| 11:15 | bartj | arohner, LauJensen thanks a lot |
| 11:15 | LauJensen | bartj: np |
| 11:17 | AWizzArd | There are several fns in core.clj that forward a call to a java method, for example keys and vals. Is there a good reason why those are not definlines but defns instead? |
| 11:28 | slyrus | rhickey: I see you were talking about your earlier clojure in CL efforts. I've been wishing I could just say (cl:defpackage foo (:use "CLOJURE") ...) and get clojure (minus the java interop stuff) in an (otherwise-)CL environment. |
| 11:28 | AWizzArd | slyrus: Do you have a CL code base? |
| 11:28 | slyrus | yes |
| 11:28 | AWizzArd | Maybe you can go the other way around and get your code running under ABCL. |
| 11:29 | AWizzArd | And then you could call it from Clojure. |
| 11:29 | AWizzArd | slyrus: http://common-lisp.net/project/armedbear/ |
| 11:29 | AWizzArd | It is a CL implementation for Java. |
| 11:29 | slyrus | yeah, yeah, yeah... |
| 11:29 | AWizzArd | but? |
| 11:29 | AWizzArd | Already tried that? |
| 11:30 | slyrus | no, but I've thought about it. |
| 11:30 | bartj | to remove the reflection warning on: (map #(String. % "UTF-8") byte-array) |
| 11:30 | AWizzArd | In theory it is just a 7 MB .jar file that you can put into your CP and that's the way to get your CL sources run with your Clojure code. |
| 11:30 | bartj | I did this: (map #(String. #^String % "UTF-8") byte-array) |
| 11:30 | slyrus | a clojure that compiled to native code using something like SBCLs compiler infrastructure would be ... interesting. |
| 11:31 | slyrus | more so than, say, CLR as far as I'm concerned |
| 11:31 | AWizzArd | bartj: looks good, but do you mean maybe byte-arrays instead, ending in "s"? Cause otherwise map would not be the right solution.. |
| 11:31 | AWizzArd | slyrus: yes, only that the JVM often outperforms sbcl. |
| 11:32 | AWizzArd | I can't say how efficient ABCL compiled CL is, but in general Clojure has the potential to outperform SBCL. |
| 11:32 | bartj | AWizzArd, Yes. I mean byte-arrays |
| 11:32 | AWizzArd | Though it is quite possible that when Clojure gets rewritten in Clojure then someone will port that implementation to a CL. |
| 11:32 | AWizzArd | Ports for JavaScript and .NET are already being worked on. |
| 11:33 | slyrus | AWizzArd: I would bet there are many cases where SBCL beats the JVM too |
| 11:33 | AWizzArd | bartj: then this is good. But if you plan to use Clojure 1.2 soon, then instead of saying #^String you could say just ^String |
| 11:33 | AWizzArd | slyrus: probably |
| 11:34 | bartj | AWizzArd, I am using 1.2 |
| 11:34 | AWizzArd | bartj: then better use ^ for your type hints |
| 11:34 | bartj | AWizzArd, I wonder why I still get the reflection warning |
| 11:35 | AWizzArd | slyrus: have a look at the Computer Language Shootout |
| 11:39 | AWizzArd | slyrus: if you try ABCL please report back to me. I would be interested in the results, that is compatibility with CL, efficiency and how easy it is to call your CL code from Clojure. |
| 11:55 | chouser | Should changes to "our own" contrib libraries get their own assembla tickets now, or are we still allowed to just commit fixes as needed? |
| 12:06 | raek | bartj: could you try (map (fn [^String s] (String. s "UTF-8")) byte-arrays) |
| 12:06 | raek | (or #^String in 1.1) |
| 12:07 | raek | hrm, should the arg relly be type hinted as a String? (was that what you wanted to do?) |
| 12:08 | raek | (for [^bytes ba byte-arrays] (String. ba "UTF-8")) |
| 12:16 | bortreb | ,(str-join "" (repeat 5 \tab)) |
| 12:16 | clojurebot | java.lang.Exception: Unable to resolve symbol: str-join in this context |
| 12:17 | bortreb | produces "\t\t\t\t\t |
| 12:17 | bortreb | is that a bug? |
| 12:18 | bortreb | since \t != \tab |
| 12:19 | bortreb | oh, nevermind, I get it now |
| 12:20 | chouser | it's definitely a quirk |
| 12:27 | chouser | bortreb: http://paste.lisp.org/display/91391 |
| 12:28 | bortreb | hurrr |
| 12:32 | Chousuke | the disparity was pretty much unavoidable. |
| 12:32 | chouser | C has literal syntax for chars without such a disparity |
| 12:33 | Chousuke | the escapes in strings are dictated by the java spec, and it isn't possible to use them and have \ be the character dispatch |
| 12:33 | Chousuke | but C uses '' for characters which is not possible in a lisp :) |
| 12:34 | Chousuke | (or if you do it, people will complain :P) |
| 12:34 | chouser | bah. syntax bikeshedding in a lisp. unacceptable |
| 12:34 | chouser | :-) |
| 12:35 | chouser | \( ), \(\n), \(n) |
| 12:35 | Chousuke | ew :P |
| 12:35 | chouser | \" ", \"\n", \"n" |
| 12:36 | Chousuke | a bit better. Though to get " you'd need \"\"" |
| 12:36 | chouser | hm, yeah. |
| 12:36 | chouser | same with \(\)) I suppose |
| 12:37 | chouser | the only reason to want a trailing marker is for whitespace, but I suppose that could be special-cased? |
| 12:38 | chouser | if "\s" = " ", then you could do \\s, \\n, \n and still be compatible with existing Clojure code |
| 12:54 | hanDerPeder | im trying to implement least common multiplier that works with an arbitrary number of arguments, but not quite there: http://pastebin.com/q4ggi0Za |
| 12:54 | hanDerPeder | can somebody give me some pointers please.. quite new at this |
| 13:14 | kensho | hanDerPeder: (use 'clojure.contrib.math) (reduce lcm [2 3 6 8]) |
| 13:16 | hanDerPeder | kensho: thanks |
| 13:16 | kensho | np |
| 13:18 | hanDerPeder | kensho: my code crashes because nil gets passed to lcm in the last step, how does one generally avoid this in clojure? should I check for nil? |
| 13:20 | Chousuke | hanDerPeder: in general you should try to write code using "nil-resistant" functions |
| 13:20 | kensho | hanDerPeder: That should certainly work but I'm a new to this myself so I don't know if there's a better way |
| 13:22 | hanDerPeder | Chousuke: how would that work with, say: (foo (rest coll)) |
| 13:22 | Chousuke | you would check for (if (seq coll) ...) in foo |
| 13:22 | pdk | ,(seq nil) |
| 13:22 | clojurebot | nil |
| 13:22 | pdk | ,(if (seq nil) :yes :no) |
| 13:22 | clojurebot | :no |
| 13:23 | Chousuke | but in this case using reduce is better as it already handles the case when the sequence ends |
| 13:23 | hanDerPeder | okay, thanks |
| 13:25 | Chousuke | note: (seq coll) is one of the core idioms when working with sequences. it basically checks whether the collection has items |
| 13:25 | Chousuke | it might not be obvious but it's one of those things you just need to know :) |
| 13:26 | pdk | (doc apply) |
| 13:26 | clojurebot | "([f args* argseq]); Applies fn f to the argument list formed by prepending args to argseq." |
| 13:26 | pdk | (doc reduce) |
| 13:26 | clojurebot | "; " |
| 13:26 | pdk | thanks clojurebot |
| 13:27 | pdk | (doc reduce) |
| 13:27 | clojurebot | "; " |
| 13:27 | pdk | :| |
| 13:27 | raek | ,(if () :yes :no) |
| 13:27 | clojurebot | :yes |
| 13:27 | raek | ,(if (seq ()) :yes :no) |
| 13:27 | clojurebot | :no |
| 13:29 | raek | ,(let [ls (lazy-seq (if (zero? (rand-int 2)) nil [1 2 3])] [(if ls :yes :no) (if (seq ls) :yes :no)]) |
| 13:29 | clojurebot | Unmatched delimiter: ] |
| 13:29 | raek | ,(let [ls (lazy-seq (if (zero? (rand-int 2)) nil [1 2 3]))] [(if ls :yes :no) (if (seq ls) :yes :no)]) |
| 13:29 | clojurebot | [:yes :no] |
| 13:29 | raek | ,(let [ls (lazy-seq (if (zero? (rand-int 2)) nil [1 2 3]))] [(if ls :yes :no) (if (seq ls) :yes :no)]) |
| 13:29 | clojurebot | [:yes :yes] |
| 13:30 | raek | one could say that the lazy-seq has not decided if it's gonna be nil or not... :) |
| 13:30 | raek | seq forces that |
| 14:13 | bortreb | why doesn't doc return more info when you use it on special forms like def? |
| 14:14 | hiredman | special forms like def don't have a var to hang doc metadata on |
| 14:14 | chouser | special forms generally need a lot more information to understand how to use them correctly, and there's not very many of them. |
| 14:15 | chouser | it's probably worth sitting down and learning them all at once. |
| 14:16 | technomancy | still, saying "Here's a web page you should read" is a little tacky imo |
| 14:17 | bortreb | that is true. but it does violate the principle of least surprise: the way it works now is jarring to a beginner |
| 14:17 | hiredman | fn gets around it by being a macro |
| 14:18 | bortreb | it's quite startling and you almost feel like you've done something wrong |
| 14:18 | pdk | no real harm to adding special cases to doc to provide docstrings hard coded into the function for special forms |
| 14:20 | bortreb | yeah ~ maybe an example and a short blurb, with the whole "you should master special forms" recommendation, would be better received? |
| 14:26 | lyle | I am just beginning to learn Clojure from Stu Halloway's book, but am curious about where to look for good "real world" examples of Clojure code. |
| 14:27 | lyle | Interested in how folks structure large Clojure apps and libraries, as well as what idiomatic Clojure looks like. |
| 14:27 | lyle | Any pointers? |
| 14:30 | fogus_ | lyle: What specific real-world-like applications are you interested in? |
| 14:31 | technomancy | Clojure apps tend to not get large. =) |
| 14:33 | arkh | lyle: try looking at the source of leiningen. technomancy just isn't plugging his own ;) |
| 14:33 | pdk | lyle you may want to pick up some books on traditional lisp as well since a lot of the principles carry over here |
| 14:34 | pdk | ansi common lisp, on lisp, let over lambda etc |
| 14:34 | pdk | especially since on lisp is free as a pdf/html document now |
| 14:58 | boorad | cemerick: is ashafa ever in here? |
| 14:59 | fogus_ | This needs to be in core.somewhere: (defn available-processors [] (.availableProcessors (Runtime/getRuntime))) -- I see it in so many projects... maybe (def *available-processors* (.availableProcessors (Runtime/getRuntime))) is better. |
| 15:07 | hiredman | ping? |
| 15:07 | clojurebot | PONG! |
| 15:11 | hugod | has anyone else seen instance? return incorrect results on a deftype instance? |
| 15:29 | arkh | how would I do type hints with a :keys directive? i.e. this doesn't work: (defn create-udp-server [& {:keys [^String local-ip local-port ^String remote-ip remote-port]}] nil ) |
| 15:32 | chouser | hugod: not in 1.2 RC3 |
| 15:33 | chouser | arkh: oh, interesting. |
| 15:35 | chouser | hm, looks like that ought to work. |
| 15:35 | arkh | I'm using 1.1 still - maybe that's my problem :( |
| 15:38 | chouser | ,(binding [*print-meta* true] (pr-str (macroexpand '(let [{:keys [^String a ^Integer b]} c ^Float d 1.0])))) |
| 15:38 | clojurebot | "(let* [map__502832 c map__502832 (if (clojure.core/seq? map__502832) (clojure.core/apply clojure.core/hash-map map__502832) map__502832) ^Integer b (clojure.core/get map__502832 :b) ^String a (clojure.core/get map__502832 :a) ^Float d 1.0])" |
| 15:38 | hugod | chouser: #424 still fails for me in RC3 |
| 15:39 | chouser | if you run that and see hints on b, a, and d then it should mork. |
| 15:39 | chouser | hugod: hm, I haven't tested that one at all. |
| 15:40 | arkh | chouser: thank you |
| 15:40 | bortreb | arkh: your method does work, I just tested it, but remember that if you don't actually use anything in the function body that requires a string, it will still work for non-string arguments |
| 15:40 | chouser | hehe. "mork" |
| 15:42 | arkh | bortreb: the String type hints are used later when passing to (InetAddress/getByName local-ip) |
| 15:46 | arkh | I don't even know if it reflects without it - and maybe I shouldn't put type hints in unless running it warns on reflection? Not sure what's best practice there. |
| 15:53 | edbond | I have a function (with side-effects) that returns a vector. How to make infinite lazy seq from it? |
| 16:01 | kencausey | edbond: why not 'lazy-seq ? |
| 16:01 | tomoj | edbond: not enough information |
| 16:02 | bortreb | edbond: can you describe it a little more? do you want an infinite sequence of vectors? |
| 16:12 | ninjudd | dnolen: the proposed 0.4.0 release of cake is on github in the duplex-refactor branch if you want to test it out with textmate-clojure. all the bound vars are in the cake namespace now |
| 16:13 | dnolen | ninjudd: cool, thx for the heads up, will check it out later |
| 16:14 | ninjudd | dnolen: it also has more reasonable handling of stdin. it should work with run and eval now |
| 16:16 | edbond | nevemind, I found repeatedly to constant call my func that return list |
| 16:16 | edbond | now I have (lazy-seq (flatten (repeatedly f))) |
| 16:18 | technomancy | would anyone use an option for allowing deps to be kept in ~/.m2/repository rather than being copied into lib/? turning it on would break M-x swank-clojure-project and perhaps some other tools with that assumption. |
| 16:18 | kencausey | so 'repeatedly includes a promise of executing the function only one like lazy-seq? |
| 16:18 | kencausey | s/only one/only once/ |
| 16:18 | technomancy | just trying to decide if it should be in lein 1.3 or later |
| 16:18 | sexpbot | so 'repeatedly includes a promise of executing the function only once like lazy-seq? |
| 16:19 | kencausey | technomancy: the value being no multiple copies among projects? |
| 16:19 | technomancy | kencausey: yeah, save a bit of disk space |
| 16:19 | kencausey | I guess links are out of the question |
| 16:20 | nickik | can anybody help me to get the new Emacs auto-complete plugin to work |
| 16:20 | nickik | = |
| 16:20 | nickik | ? |
| 16:20 | technomancy | kencausey: eh; symlinks are already supported on unix |
| 16:20 | technomancy | but there's really no need for a lib/ dir at all, technically |
| 16:21 | nickik | i have no idea how to get that working |
| 16:21 | kencausey | why does it break any functionality? |
| 16:21 | nickik | i just cloned it into the .emacs folder |
| 16:21 | kencausey | because they assume /lib and are not part of lein? |
| 16:21 | technomancy | kencausey: yeah, because M-x swank-clojure-project is implemented in elisp. |
| 16:21 | kencausey | so can be fixed given time? |
| 16:22 | kencausey | seems reasonable to me then |
| 16:22 | technomancy | kencausey: it can't, but swank-clojure-project is deprecated in favour of lein swank. |
| 16:22 | kencausey | well, fixed for anyone who cares ;) |
| 16:22 | technomancy | I'm going to add it, it's just a question of now or later, so I'm trying to gauge interest |
| 16:22 | edbond | ,(take 10 (repeatedly 5)) |
| 16:22 | clojurebot | java.lang.RuntimeException: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn |
| 16:23 | nickik | repeatedly calls the arg |
| 16:23 | kotarak | ,(take 10 (repeatedly (constantly 5))) |
| 16:23 | clojurebot | (5 5 5 5 5 5 5 5 5 5) |
| 16:23 | nickik | if you want a stream of 5s you need to make (repeat 5) |
| 16:23 | dnolen | technomancy: I've kind of come to consider the location of lib in the project directory to be a feature, it's easy to see what .jars are a part of your project. |
| 16:24 | dnolen | technomancy: you don't have to hunt for the path. |
| 16:24 | kotarak | ,(repeat 10 5) |
| 16:24 | clojurebot | (5 5 5 5 5 5 5 5 5 5) |
| 16:25 | technomancy | dnolen: right; leaving out lib/ will not be the default in the forseeable future, just an option. |
| 16:25 | technomancy | dnolen: are there other tools you know of that use that assumption though? |
| 16:30 | dnolen | technomancy: not that I'm aware of, but it's such a standard layout that I wouldn't be surprised if plugins, etc. assumes it's there. |
| 16:36 | raek | edbond: could cycle be a possible solution? |
| 16:37 | raek | hrm, just read about the side-effects... |
| 16:37 | raek | nevermind |
| 16:38 | raek | (defn foo (lazy-cat (f) (foo))) could work too |
| 16:38 | raek | flatten is recursive, I think |
| 17:02 | kencausey | Should I be able to ctrl-C ctrl-C a defn in emacs with a lein swank and slime-connect? This is winxp/cygwin. I guess a No such namespace: [Thrown class java.lang.Exception\ |
| 17:03 | kencausey | s/guess/get/ |
| 17:03 | sexpbot | Should I be able to ctrl-C ctrl-C a defn in emacs with a lein swank and slime-connect? This is winxp/cygwin. I get a No such namespace: [Thrown class java.lang.Exception\ |
| 17:06 | ska2342 | kencausey: do you have a call to ns at the beginning of your file? |
| 17:06 | phaer | kencausey: C-c C-c? I can't find such keybinding in C-h m. Do you mean C-c C-e? Then i guess you should be able to do it... |
| 17:07 | amalloy | C-c C-c should work, but it shouldn't hurt to C-c C-k to make sure the rest of the file is loaded first |
| 17:10 | kencausey | C-c C-k works, but still not C-c C-c |
| 17:11 | ska2342 | kencausey: I've had the same problem when I was editing files without a namespace definition at the top. Do you have one? |
| 17:11 | kencausey | no I guess that's it |
| 17:11 | kencausey | but it doesn't make sense if it's only paying attention to the form near the cursor |
| 17:15 | amalloy | phaer: the binding is listed in C-h m, under the Slime minor mode |
| 17:17 | phaer | amalloy: right, my bad. |
| 17:26 | kencausey | ok, it seems I have to C-c C-k the file once anyway to create the namespace |
| 17:26 | kencausey | after that C-c C-c seems to work |
| 17:26 | kencausey | makes sense I suppose |
| 17:26 | raek | auto-complete-mode for clojure is awesome... |
| 17:27 | raek | C-c C-e puts things in the user namespace if the ns declaration hasn't been evaled |
| 17:27 | raek | this might be related |
| 17:28 | scottj | Is there a more concise version of this? (if (symbol? (first expr)) (first expr) nil) |
| 17:28 | AWizzArd | scottj: when |
| 17:29 | AWizzArd | (if x y nil) ==> (when x y) |
| 17:29 | raek | (if x y) works too... |
| 17:29 | AWizzArd | This is considered bad style, while when documents exactly this. |
| 17:30 | raek | is it? |
| 17:30 | raek | ,(doc when) |
| 17:30 | clojurebot | "([test & body]); Evaluates test. If logical true, evaluates body in an implicit do." |
| 17:30 | AWizzArd | yes |
| 17:30 | raek | I've heard this been debated before |
| 17:30 | AWizzArd | raek: rhickey explained (in 2008) or so that using the nil return value of when is idiomatic in Clojure. |
| 17:30 | ska2342 | reak: it tells the reader: "Don't go searching for an else, there is none." |
| 17:31 | AWizzArd | Plus if IF only has one branch you don't know if it was intended or accidently forgotten. |
| 17:31 | raek | yes, I know |
| 17:31 | AWizzArd | thus IF should always have two branches, while when makes the intentions of the author totally clear |
| 17:32 | raek | I just didn't know about rich's utterance |
| 17:32 | scottj | Is there a shortcut for not duplicating the (first expr) other than this (let [a (first expr)] (when (symbol? a) a)) |
| 17:32 | AWizzArd | raek: I asked him 2008 or early 2009 |
| 17:32 | raek | scottj: I don't think so, no |
| 17:32 | raek | AWizzArd: ok. I trust you :) |
| 17:33 | AWizzArd | raek: you can also try to find it online, all (well, most) logs of this are available online |
| 17:33 | arohner | scottj: if-let |
| 17:34 | arohner | scottj: and when-let |
| 17:34 | arohner | ,(doc when-let) |
| 17:34 | clojurebot | "([bindings & body]); bindings => binding-form test When test is true, evaluates body with binding-form bound to the value of test" |
| 17:34 | raek | but when-let will bind the value of (symbol? ...) in that case |
| 17:36 | raek | http://github.com/Kaali/pour/blob/master/src/pour/core.clj#L24 |
| 17:36 | raek | I know Kaali ended up with this for a predicate to validator function |
| 17:37 | raek | (where a "validator" is a fn either returning the value or nil, depending on whether a predicate returned true for it) |
| 17:38 | raek | (def maybe-symbol (pred-to-validator symbol?)) |
| 17:38 | raek | (maybe-symbol (first expr)) |
| 17:39 | raek | that is what I can come up with right now |
| 17:39 | raek | functions making functions can be very neat |
| 17:40 | hanDerPeder | how can i cast a huge number as string, ie "1234..." to a vector of digits? |
| 17:40 | scottj | Does something like (ensure [] '(1 2 3)) -> [1 2 3], (ensure #{} 1) -> #{1} exist? (I've written it as a wrapper around into but not sure if there's already something like that in contrib or core |
| 17:41 | hanDerPeder | or can you use a string as a vector of characters? |
| 17:41 | raek | the special cases for vectors and sets are available as the vec and set functions |
| 17:41 | raek | hanDerPeder: strings can be used as a sequence of characters |
| 17:42 | raek | you can turn it into a vector (if you need to) with vec |
| 17:42 | raek | ,(vec "foo") |
| 17:42 | clojurebot | [\f \o \o] |
| 17:42 | raek | clojure's sequence functions call seq on their arguments |
| 17:42 | raek | ,(seq "foo") |
| 17:42 | clojurebot | (\f \o \o) |
| 17:43 | raek | scottj: into |
| 17:44 | raek | ,(into [] '(1 2 3)) |
| 17:44 | clojurebot | [1 2 3] |
| 17:44 | raek | ,(into #{} '(1)) |
| 17:44 | clojurebot | #{1} |
| 17:44 | hanDerPeder | raek: trying to do something like (map Integer. (vec "123")), don't know if there is a better way of doing it.. |
| 17:45 | raek | you'll have to do #(Integer. %), but otherways that looks resonable |
| 17:45 | raek | there might be a numerical value method of the character class |
| 17:46 | ska2342 | Hello. May I humbly ask, if there is already a release date for 1.2, in case there are no more reports on the latest RC? |
| 17:47 | scottj | raek: almost. the point of ensure is the second arg doesn't have to be a collection |
| 17:48 | raek | I see |
| 17:48 | scottj | Is there a single function in core to make one item into a collection iff the something's not already a collection? |
| 17:48 | raek | then ensure could be as a composition of two functions: into and "make-coll" |
| 17:49 | raek | not what I know of |
| 17:49 | raek | (defn make-coll [x] (if (coll? x) x (list x))) |
| 17:50 | hanDerPeder | raek: what can i google to learn more about what in the world the #(Integer. %) syntax is all about? |
| 17:50 | scottj | I realize it's easy :) |
| 17:50 | dnolen | ska2342: probably nothing more accurate than "soon". |
| 17:50 | scottj | hanDerPeder: do you know what #() is about? |
| 17:51 | raek | hanDerPeder: #(foo a % b) is a short form for (fn [x] a x b) |
| 17:51 | raek | *ahem* |
| 17:51 | ska2342 | dnolen: just thought, maybe someone mentioned it here (and I've not been here lately). Thanks. |
| 17:51 | raek | (fn [x] (foo a x b)) |
| 17:52 | raek | hanDerPeder: the java constructor syntax Integer. is not a function |
| 17:52 | raek | so you have to make it one... |
| 17:52 | hanDerPeder | raek: okay, thanks |
| 17:53 | raek | the syntax is described at http://clojure.org/reader |
| 17:53 | raek | the java interop is described at http://clojure.org/java_interop |
| 17:56 | raek | ,(map #(Character/getNumericValue %) "123") |
| 17:56 | clojurebot | (1 2 3) |
| 17:56 | raek | ,(map #(Character/getNumericValue %) "٠١٢٣٤٥٦٧٨٩") |
| 17:56 | clojurebot | (0 1 2 3 4 5 6 7 8 9) |
| 17:57 | raek | as a bonus, that works for any unicode numeral |
| 17:57 | hanDerPeder | thanks, makes a lot more sense now :) |
| 18:00 | wolfjb | does leiningen-war work for anyone? I'm getting a Exception in thread "main" java.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V (war.clj:1) |
| 18:01 | raek | that message is usually a result of using two AOT compiled libraries that was compiled with different clojure versions |
| 18:02 | raek | http://github.com/technomancy/leiningen has a point about it |
| 18:03 | raek | (clojure versions are not binary compatible with each other) |
| 18:15 | AWizzArd | when I want to make a proxy in which I list two interfaces, and both include a method with the identical name foo, how can I implement those? |
| 18:20 | raek | hrm, do they have the same signature? |
| 18:20 | AWizzArd | Let's talk about both situations. |
| 18:21 | raek | in the jvm, methods of classes don't "know" which interface they come from |
| 18:21 | Joreji | AWizzard: The same way you would do with only one interface I'd say. At least it works for me: http://pastebin.com/KftuZEyG |
| 18:22 | AWizzArd | So, if the signatures are different, then I could simply list both (or even 18, if I want maany Interfaces) of them. Otherwise it will be forbidden? |
| 18:22 | hiredman | AWizzArd: you write a proxy body, just make sure it can handle both signatures |
| 18:22 | hiredman | no |
| 18:22 | hiredman | you can't just list both, because proxy doesn't do method selection by types |
| 18:22 | hiredman | it does it by name |
| 18:24 | raek | reify can do this: "If a method is overloaded in a protocol/interface, multiple independent method definitions must be supplied. If overloaded with same arity in an interface you must specify complete hints to disambiguate - a missing hint implies Object. |
| 18:24 | raek | " |
| 18:24 | hiredman | clojurebot: proxy is not reify |
| 18:24 | clojurebot | Alles klar |
| 18:25 | AWizzArd | So if two interfaces have the same signature, then we can't disambiguate between them? |
| 18:25 | AWizzArd | even in reify |
| 18:25 | hiredman | you can, but proxy can't |
| 18:26 | hiredman | oh |
| 18:26 | hiredman | if they have the same signature, no |
| 18:26 | AWizzArd | okay, so, different signatures is okay with reify |
| 18:26 | AWizzArd | identical signatures - forbidden |
| 18:27 | hiredman | no |
| 18:27 | hiredman | you can use them, you just have to do dispatch yourself |
| 18:27 | AWizzArd | yes |
| 18:27 | AWizzArd | but not with reify, right? |
| 18:28 | hiredman | depends on the signature |
| 18:36 | AWizzArd | identical |
| 18:36 | AWizzArd | 4 interfaces, all offer int foo(int) |
| 18:37 | rhudson | AWizzArd, it's (not) just a Clojure issue, it's how Java works |
| 18:37 | AWizzArd | yes, I am not saying that it is Clojure |
| 18:37 | AWizzArd | I am just curious if/how this is solved. |
| 18:38 | rhudson | By rewriting your interfaces :) |
| 18:39 | rhudson | Java methods within a class are distinguished by name and signature, and not by which interface they implement |
| 18:39 | rhudson | The various Clojure interop facilities build on that machinery |
| 18:41 | rhudson | So in your hypothetical, you could provide an int foo(int) but it would satisfy all 4 interfaces |
| 18:43 | AWizzArd | oki, thx |
| 19:04 | nickik | do sets keep order? |
| 19:07 | AWizzArd | nickik: nein |
| 19:07 | AWizzArd | but SortedSets do |
| 19:07 | ninjudd | nickik: do you mean insertion order? |
| 19:08 | AWizzArd | ,(sorted-set 30 20 10 5 6 7 2) |
| 19:08 | clojurebot | #{2 5 6 7 10 20 30} |
| 19:09 | ninjudd | right, insertion order would be #{30 20 10 5 6 7 2} |
| 19:13 | nickik | i ment insertion order |
| 19:13 | AWizzArd | not trivially possible |
| 19:13 | ninjudd | http://github.com/ninjudd/ordered-set |
| 19:14 | AWizzArd | yes, you best would use some existing class/deftype for that |
| 19:15 | nickik | something else can i get the name of a record? |
| 19:16 | nickik | i do (defrecord test []) |
| 19:17 | nickik | how do i go from (test. ) to test |
| 19:19 | nickik | i have to remember the orderd set could come in handy at onepoint |
| 19:21 | AWizzArd | ninjudd: useful! |
| 19:39 | dpro | hi |
| 19:40 | dpro | dumb noob q., is there an existing function to get a random element from a vector or list ? (I'm just trying to find my way around the docs) |
| 19:40 | hiredman | ,(doc rand-nth) |
| 19:40 | clojurebot | "([coll]); Return a random element of the (sequential) collection. Will have the same performance characteristics as nth for the given collection." |
| 19:41 | dpro | hiredman: cheers |
| 19:41 | dpro | clojurebot: cheers to you too of course :) |
| 19:41 | clojurebot | hip hip, hooray! hip hip, hooray! hip hip, hooray! |
| 19:41 | dpro | hehe |
| 19:43 | AWizzArd | a useful tool when you think you have an interesting keyword: (find-doc "random") |
| 20:00 | nickik | does pmap still only use 2 cores= |
| 20:00 | nickik | ? |
| 20:01 | dnolen | nickik: pmap happens to use the number of cores on your system plus 2 i believe. |
| 20:02 | nickik | ah ok very good |
| 20:22 | nickik | how can I init a record from a other namespace? |
| 20:24 | mefesto | nickik: did you import the classname? |
| 20:26 | nickik | (ns titfortat.main.core (:use [main.core] :reload-all) (:use [clojure.test])) |
| 20:26 | nickik | (ns main.test.core (:use [main.core] :reload-all) (:use [clojure.test])) |
| 20:27 | nickik | @mefest for testing i need a record from the main ns |
| 20:27 | hiredman | defrecord produces a named class |
| 20:27 | mefesto | nickik: perform a java import (import 'titfortat.main.core.MyRecord) |
| 20:27 | hiredman | (ns foo.bar) (defrecord Baz) |
| 20:28 | hiredman | (foo.bar.Baz.) |
| 20:28 | hiredman | (ns foo.bar) (defrecord Baz []) |
| 20:32 | wolfjb | I have installed clojure 1.1.0, running clojure says 1.1.0, I have set clojure and clojure-contrib in my project.clj to 1.1.0 but lein war still give me this: Exception in thread "main" java.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V (war.clj:1) |
| 20:32 | wolfjb | what else can I check? |
| 20:32 | hiredman | did you run lein clean and lein deps afterwards? |
| 20:32 | wolfjb | yes |
| 20:32 | hiredman | what do you mean by installed? |
| 20:33 | wolfjb | I downloaded clojure and clojure-contrib version 1.1.0 from clojure download site and pointed my launcher script to them |
| 20:33 | hiredman | uh |
| 20:34 | hiredman | that has nothing to do with lein and project.clj |
| 20:34 | hiredman | what versions of clojure and contrib is your project.clj pulling in? |
| 20:34 | wolfjb | 1.1.0 is what I set in my project.clj |
| 20:34 | hiredman | for which? |
| 20:34 | wolfjb | in the lib directory is clojure-1.1.0 |
| 20:34 | wolfjb | um |
| 20:35 | hiredman | contrib and clojure both? |
| 20:35 | wolfjb | well, I just downloaded the script on the leiningen github site |
| 20:35 | wolfjb | let me look at that, maybe I missed something |
| 20:35 | nickik | look at this |
| 20:35 | hiredman | uh |
| 20:35 | nickik | (ns titfortat.test.core (:use [titfortat.core] :reload-all) (:use [clojure.test]) (:import [titfortat.core.nice]) (:import [titfortat.core.asshole])) |
| 20:35 | hiredman | where did you get your project.clj? |
| 20:36 | wolfjb | lein new cabinet |
| 20:36 | hiredman | ok |
| 20:36 | nickik | is this right? |
| 20:36 | hiredman | and what does your project.clj say? |
| 20:36 | wolfjb | following this tutorial http://mmcgrana.github.com/2010/08/clojure-rest-api.html |
| 20:36 | mefesto | nickik: what is the name of your record? |
| 20:37 | hiredman | the tutorial on that site doesn't use 1.1.0 |
| 20:37 | wolfjb | true, but I changed it to say 1.1.0. |
| 20:37 | nickik | @mefesto nce and asshole |
| 20:37 | nickik | *nice |
| 20:37 | hiredman | wolfjb: it being what? |
| 20:37 | mefesto | nickik: remove the last dot in your import |
| 20:38 | mefesto | replace with a space |
| 20:38 | hiredman | clojure and clojure contrib are seperate things, and you need to having matching versions in your project.clj |
| 20:38 | wolfjb | sorry, I changed my project.clj for the cabinet project to have 1.1.0 for the clojure and clojure-contrib version |
| 20:38 | nickik | ah ok |
| 20:38 | mefesto | nickik: it would work the way you have it if it was not in [] |
| 20:38 | nickik | i haven't worked with java interop much so i leak that a bit |
| 20:38 | hiredman | wolfjb: and you only have 1.1.0 jars for both in lib? |
| 20:39 | wolfjb | yes |
| 20:39 | nickik | *lack :) |
| 20:39 | wolfjb | http://pastebin.com/QK1mX36B |
| 20:39 | wolfjb | is project.clj |
| 20:40 | hiredman | wolfjb: so most likely some other library you are using is incompatible with 1.1 |
| 20:40 | nickik | @mefesto ah ok thx |
| 20:42 | wolfjb | So, I was originally using 1.2.0-master-SNAPSHOT for clojure and 1.2.0-SNAPSHOT for clojure-contrib, but in lib/dev clojure-1.1.0 and clojure-contrib-1.1.0 were showing up after lein deps |
| 20:42 | wolfjb | which is why I changed the project.clj to 1.1.0 for both clojure and contrib |
| 20:44 | hiredman | right, so you are mixing libraries that require different versions of clojure |
| 20:44 | hiredman | don't do that |
| 20:44 | wolfjb | trying not to |
| 20:44 | wolfjb | :-) |
| 20:44 | technomancy | lein pom && mvn dependency:tree # to spot the offenders |
| 20:44 | technomancy | wolfjb: ^ |
| 20:44 | wolfjb | ah |
| 20:44 | wolfjb | I'll try that |
| 20:50 | wolfjb | so, that didn't seem to work, it doesn't seem to show the dev-dependencies in the tree |
| 20:51 | wolfjb | I'm guessing this has to do with the dev-dependencies |
| 20:51 | wolfjb | lein run run.clj works, but lein war doesn't |
| 20:51 | wolfjb | but that's only true when I switch back to clojure 1.2.0 |
| 20:51 | wolfjb | in the project.clj |
| 20:52 | wolfjb | with 1.1.0 in the project.clj, neither of those work |
| 20:52 | wolfjb | but lein puts 1.1.0 jars in lib/dev |
| 20:54 | wolfjb | ok so the dev-dependency which seems to be bringing in the 1.1.0 version is lein-run plugin |
| 21:05 | bobbytek | what's the difference between a form and an expression? |
| 21:05 | technomancy | wolfjb: that's definitely a lein-run bug |
| 21:06 | wolfjb | ah |
| 21:09 | bobbytek | And how is a symbol different than a reference? |
| 21:17 | arbscht | bobbytek: the first is a general question whose answer may be better documented in other lisps; for example, the Common Lisp HyperSpec defines 'form' and 'expression' in its glossary, and the general idea applies to Clojure |
| 21:17 | bobbytek | I'm pretty new to lisps... |
| 21:18 | bobbytek | is caml a lisp? I've used that a long time ago |
| 21:18 | arbscht | bobbytek: I don't understand what you mean by reference. do you mean the STM ref type, or some other general reference? |
| 21:18 | bobbytek | java reference |
| 21:18 | bobbytek | or pointer |
| 21:18 | arbscht | bobbytek: caml is not a lisp |
| 21:20 | arbscht | bobbytek: a symbol is a particular type of object whose name is used to identify other things. it's not the same as a java reference |
| 21:20 | bobbytek | a reference in java identifies an object |
| 21:20 | bobbytek | how is it different? |
| 21:20 | scottj | ,'symbol |
| 21:20 | clojurebot | symbol |
| 21:21 | scottj | ,symbol |
| 21:21 | clojurebot | #<core$symbol clojure.core$symbol@1f5a0f0> |
| 21:21 | bobbytek | it is effectively an indirection mechanism that also establishes identity |
| 21:22 | scottj | symbols can be used for their own sake kind of like keywords, or they can be evaluated in which case they point to a var, which in turn points to an object |
| 21:23 | tomoj | ,(let [a 1] #'a) |
| 21:23 | clojurebot | java.lang.Exception: Unable to resolve var: a in this context |
| 21:23 | bobbytek | heh, maybe I should read more of my practical closure book |
| 21:23 | bobbytek | (just getting started) |
| 21:24 | arbscht | bobbytek: symbols are first-class, can be interned in namespaces, and so on. the use case of naming a binding is one similarity with references, but symbols do more |
| 21:24 | chouser | (let [map 1] map) |
| 21:24 | chouser | ,(let [map 1] map) |
| 21:24 | clojurebot | 1 |
| 21:24 | chouser | ,(let [map 1] #'map) |
| 21:24 | clojurebot | #'clojure.core/map |
| 21:33 | hiredman | vars are often overlooked |
| 21:33 | hiredman | they can be tricky, e.g. if you are conditionally import or loading code |
| 21:34 | hiredman | importing |
| 21:35 | hiredman | aot compiled code can end with references to the wrong var |
| 21:35 | hiredman | and then you end up digging through javap output |
| 21:39 | spewn | What steps are necessary between lein install and being able to (use 'foo)? |
| 22:28 | bmaddy | Hi all. Anyone have an idea as to why this returns nil? (use 'clojure.contrib.pprint) |
| 22:28 | bmaddy | That should just work, shouldn't it? |
| 22:29 | cemerick | use, require, and import all return nil |
| 22:29 | bmaddy | Heh, clearly I'm new. Thanks! :) |
| 22:29 | cemerick | welcome :-) |
| 22:33 | kotrin | can anyone help me debug the NullPointerException i'm getting in this code? not sure what i'm doing wrong...nor do i know how to debug clojure :) http://pastie.org/1096855 |
| 22:33 | kotrin | or maybe even some code improvement tips while your staring at it? <3 |
| 22:34 | kotrin | you're* |
| 22:34 | cemerick | kotrin: use records instead of structs (http://clojure.org/datatypes) |
| 22:34 | kotrin | i'll look into it...thanks cemerick |
| 22:35 | cemerick | kotrin: there's an NPE because t is a sequence of rest args |
| 22:35 | cemerick | remove the & and it should work. |
| 22:36 | cemerick | (or, at the very least, (:key t) won't return nil anymore) |
| 22:37 | kotrin | alright, thanks for the help! |
| 23:22 | seangrove | Hey all, is there an example in clojure of interacting with a webcam? |
| 23:25 | dnolen | seangrove: I think ztellman had some luck with OpenCV for Processing/Java, but I don't know of any Clojure source that you can actually look at. |
| 23:26 | seangrove | Yeah, I saw that, but I've had a very, very difficult time getting it to work |
| 23:26 | seangrove | OpenCV is actually where I'd like to get to, but I'm not sure how to get a setup that runs his source |
| 23:27 | dnolen | seangrove: there's also http://www.xuggle.com/ |
| 23:27 | seangrove | I'll take a look |
| 23:27 | seangrove | Afraid I'm very new to clojure |
| 23:27 | seangrove | Much more of a scheme guy, heh |
| 23:27 | dnolen | seangrove: it's a bit complex, and there are not bindings to Clojure, but also powerful. |
| 23:28 | seangrove | I'll start by trying to get the smallest example working first, I think |
| 23:28 | dnolen | seangrove: yeah, if you're getting into media stuff, you need to have the Java basics down. |
| 23:29 | seangrove | I have an opengl clojure app I made |
| 23:29 | seangrove | But I certainly don't have java basics by any means |
| 23:29 | dnolen | seangrove: by basic I really just mean, jars, classpath, compiling Java source, and maybe some about where to put native files. |
| 23:30 | seangrove | Ah, yes, I'm ok with that |
| 23:30 | seangrove | It's been about 6 months though |
| 23:30 | seangrove | So we'll see how this goes :) |
| 23:31 | dnolen | seangrove: Xuggle source seems pretty easy to run, next step would be running it from Clojure, next step a binding, and finally a idioamtic library that we can all use :D |
| 23:38 | seangrove | Looks like incanter has processing, which I believe has opencv |
| 23:38 | technomancy | seangrove: yeah, processing would be my recommendation |
| 23:42 | dnolen | seangrove: technomancy: I agree as well. far simpler that's for sure. |
| 23:49 | seangrove | Wow, incanter is quite impressive |
| 23:54 | seangrove | user=> (import 'hypermedia.video.OpenCV) |
| 23:54 | seangrove | java.lang.ClassNotFoundException: hypermedia.video.OpenCV (NO_SOURCE_FILE:17) |
| 23:54 | seangrove | I'm supposing this means I haven't put the jar in the right file, or I haven't set the classpath correctly |
| 23:54 | seangrove | That seem about right? |
| 23:54 | dnolen | seangrove: yeah |
| 23:55 | seangrove | Got some japanese blog, hehe: http://e-arrows.sakura.ne.jp/2010/01/clojure-opencv.html |
| 23:56 | dnolen | seangrove: I think OpenCV also relies on native libs, so you'll need to set your library path as well. |
| 23:56 | seangrove | Not sure how to set that in the slime repl |
| 23:56 | seangrove | I'll try it frm the cli for now |
| 23:59 | dnolen | seangrove: yeah you can't do it from the repl, has to be at startup time. lein will do this for you if you have the proper project layout - http://github.com/swannodette/native-deps |