#clojure logs

2010-08-03

00:31notsonerdysunnyI was looking around for sexp like serialization this morning and found
00:31notsonerdysunnyhttp://en.wikipedia.org/wiki/Canonical_S-expressions
00:32notsonerdysunnyhttp://people.csail.mit.edu/rivest/sexp.html
00:32notsonerdysunnyit would be nice to have clojure-based interface for it ..
00:48notsonerdysunnywhats a good way to do clojure and java native stuff ?
00:49qbgJNI?
00:50notsonerdysunnyyea I know there is JNI and JNA(supposedly newer stuff) .. but I also found a couple of clojure jn[ai] stuff on the clojars .. I was wondering if anybody had any input on which is a good one to use
02:50slyrushrm... one of the differences between flet and labels in common lisp is that in the bodies of flet'ed functions, the function name isn't bound to the local function. is there a way to do similar in clojure?
02:51slyrusan enclosing let to squirrel away the old binding?
02:51slyrusworks, but I don't suppose there's a more flet-y form I'm missing?
02:55Chousukeslyrus: can't you do just (let [foo (fn ...)] ...)
02:56tomojslyrus: why does it matter? just curious, not saying it doesn't
02:56slyrusI sure can Chousuke, thanks!
02:57slyrustomoj: if I want to locally rebind a function and be able to call the original function from the new function body, I can't using letfn.
02:57tomojdo you often want to do that?
02:58tomojoh, I think I see
02:58slyrus(defn foo [x] (+ 17 x)) (let [foo (fn [x] (+ 33 (foo x)))] (foo 3))
02:58tomojright
02:58slyrussure, I'm adding 33 and 17 to numbers all the time!
02:58slyrus:)
02:58tomojjust never wanted to shadow like that before
02:58tomojbut I think I can imagine situations where it would be useful
02:59Chousukeslyrus: I'd rather do (let [orig-foo foo] ...). Shadowing like that is pretty confusing
02:59brehautwould letfn be closer ?
03:00slyrusbrehaut: letfn doesn't work as it would just recursively call foo
03:00brehautoh right
03:06slyrusand my nasty little hack is foiled by the fact that I can't let a qualified name. oh well, it was probably a bad idea anyway.
03:29raekgood morning
03:30brehauthi raek
03:43brehautparedit bindings in counterclockwise have made my day
03:47esjmorning all
04:04LauJensenGood morning all
04:05LauJensen(incl. esj)
04:05brehautevening
04:11sid3kmorning guys
04:12LauJensenMorning sid3k :)
04:14esjyo
04:14xkbyoyo
05:28cais2002how do I convert a str to a number ?
05:31AWizzArdcais2002: use the wrapper classes Integer, Long, Byte, etc.
05:31AWizzArd,(Integer/parseInt "55")
05:31clojurebot55
05:32cais2002-> (Integer. "55")
05:32sexpbot=> 55
05:32cais2002is there a simpler way?
05:32cais2002,(str 55)
05:32clojurebot"55"
05:32tomojthere's (read-string "55"), but...
05:33AWizzArdthis is less efficient, but if you are not in a tight loop it might be okay
05:34tomojhow exactly is (Integer. "55") complicated?
05:34AWizzArdcais2002: a pretty safe way for conversion is instantiating a BigDecimal, as this can eat all your numbers
05:35cais2002tomoj: i thought there is some "native" function to do it
05:35tomojjava hater? :)
05:35zmila,(type (load-string "1234"))
05:35clojurebotDENIED
05:36zmila,(load-string "1234")
05:36clojurebotDENIED
05:37tomoj-> (class (read-string "1234"))
05:37sexpbot=> java.lang.Integer
05:37AWizzArdload-string is about the most inefficient way to do this
05:38tomojsomething like (read-string "{}") will work fine until you try to use it as a number, (Integer. "{}") will properly blow up
05:38zmilai supose so too :) but i think it's the way, when you don't know which datatype is there in the string
05:38zmilait's like (eval ) ?
05:39AWizzArdconverting 10000 strings to a number via load-string: 400 msecs, read-string: 14 msecs, BigDecimal.: 5.8 msecs, Integer/parseInt: 3.6 msecs
05:39tomojhuh
05:39tomojwhy does it take so long for a number to eval to itself?
05:40tomojoh, load-string isn't (comp eval read-string)
05:41AWizzArdright
05:42tomoj.. (load-string "1.234 (launch-the-nukes)")
05:42AWizzArdReally, if it is an int, just call Integer. on it.
05:44cais2002yeah, I will just use Integer/parseInt
05:44zmilaand wrap into (catch NumberFormatExc)
05:45cais2002ah yes
06:26LauJensenAWizzArd: Did you bench Integer. vs Integer/parseInt ?
06:29LauJensen,(time (dotimes [_ 1e6] (Integer. "55")))
06:29clojurebot"Elapsed time: 157.381 msecs"
06:29LauJensen,(time (dotimes [_ 1e6] (Integer/parseInt "55")))
06:29clojurebot"Elapsed time: 106.514 msecs"
06:33tomojthat's odd
06:34bobo_LauJensen: hows the plans for next round of conj-labs going? saw something about trouble finding a venue?
06:35LauJensenbobo_: Germany has proven to be a challenge in terms of finding a good venue. We're teamed up with InnoQ who have been doing a lot of ground work, so I hope to be able to release a venue and date before long - hopefully no longer than 1 week from today
06:35bobo_great!
06:37LauJensenYea we're really putting in some work to ensure that it indeed becomes 'great' :)
06:37bobo_:-)
06:37esjLauJensen: where is the content going to be aimed ?
06:38LauJensenesj: We'll aim it at the attendants :9
06:38LauJensenWhat do you mean?
06:38esjhahahahah
06:38esji mean are you giving 1). An introduction to Clojure, 2). An exploration of certain ideas in Clojure 3). Advanced concurrency coding etc etc ?
06:39AWizzArdLauJensen: yes, I tried Integer. vs. Integer/parseInt, and they are virtually equally efficient
06:40LauJensenIts a little early to say, but I think the level will not be as high as the Brussels session (which was über advanced), but it will be more catering to people looking to acquire the skills for professional use. Since we work 'lab style' we accomodate the individual attendants though, so everybody gets challenged (a little more than they hoped for) :)
06:40tomojparseInt does seem to be reliably a little tiny bit faster to me, wonder why
06:40LauJensenAWizzArd: I always found parseInt to be about 30% faster
06:41tomojI'm seeing more like 3%
06:42AWizzArdLauJensen: please try (time (dotimes [i 10000000] (Integer. (str i ))))
06:42tomojit must be that new is slower than . ?
06:43AWizzArdand (time (dotimes [i 10000000] (Integer/parseInt (str i))))
06:43AWizzArd,(time (dotimes [i 100000] (Integer. (str i ))))
06:43clojurebot"Elapsed time: 58.767 msecs"
06:43AWizzArd,(time (dotimes [i 100000] (Integer/parseInt (str i ))))
06:43clojurebot"Elapsed time: 58.959 msecs"
06:44BahmanHi all!
06:44LauJensenBahman: yo
06:44BahmanHi there LauJensen!
06:44tomojstill ~3% faster it seems
06:45LauJensenYea also a little faster locally
06:45tomojwonder what new does
06:45LauJensen(defn new [i] (Thread/sleep 30) (Integer/parseInt i))
06:46LauJensenBut yea, its a good question
06:46tomojNewExpr has a whole lot inside
06:47tomojHostExpr does too, though
07:20javeI'm trying to do the conjure ajax tutorial, but I'm failing. are the src for the tutorial up somewhere?
07:26LauJensenjave if by conjure you mean Clojure, then I am not aware of any ajax tutorial, got a link?
07:27javeno I mean the conjure web framework that uses clojure
07:27javehttp://github.com/macourtney/Conjure
07:28javeit seems neat, but I have aparently missed to perform some step when I tried the ajax tutorial
07:29LauJensenAh ok, sorry then Im blank, have never tried it
07:29javenp
07:29LauJensenThough I think your the 2nd guy this week to come in here and complain about it
07:30javeoh
07:30javeI'm not complaining mind you
07:30LauJensenalright - Im just saying, I dont think you're the first guy to have trouble with it
07:31javeyep
07:32javeI always wanted to do web coding in lisp, the goal is close at hand, yet far...
07:32tomojevery time I see that "A Rails like framework for Clojure" I get a little crazy
07:33LauJensenjave: A ton of us are doing web coding in Clojure, just not using Conjur
07:33somniumI think there's a tutorial for sproutcore + compojure somewhere
07:33javecool
07:33lenwhttp://wiki.sproutcore.com/Todos+06-Building+with+Compojure+and+MongoDB
07:33LauJensenjave: http://bestinclass.dk/index.clj/2009/12/dynamic-interactive-webdevelopment.html
07:33bobo_i have some ajax stuff i made in compojure/ring/hiccup, if thats to any help. been meening to write something about it but havent yet
07:33LauJensenI did that a while ago, which is a pretty decent intro to webdev
07:34LauJensenjave: http://bestinclass.dk/index.clj/2009/12/beating-the-arc-challenge-in-clojure.html that also shows off some compojure, though its a little outdated. If you want some up to date code, you could check out the source for bestinclass.dk
07:35bobo_is bestinclass written with compojure?
07:35LauJensenbobo_: Not, Enlive and Moustache
07:35LauJensens/Not/No
07:35LauJensenI used to use Compojure only for webdev, but when they stripped out all the guts and implemented it as ring middleware, I went with Moustache - Though I think both a fun to work with
07:38javeso, most of the framework uses "ring" then?
07:38LauJensenyes
07:39javeand compojure, does it have some jsquery bindings?
07:39LauJensenjsquery?
07:39javejquery, sorry
07:40bobo_jave: no not realy
07:40bobo_not that ive found atleast.
07:40bobo_but you can still use it
07:40LauJensenIm not sure. But for one thing, jquery is pretty concise in its own right, and 2nd, it would be easy to wrap some of the syntax
07:40bobo_i wrote my javascript in javascript
07:40tomojbobo_: hurrah
07:40bobo_jquery is imho great as it is.
07:40somniumjavascript doesnt get enough love
07:41javeI'm a bit rusty with web dev
07:41javedid used cocoon a lot before
07:41javeI liked the continuations aproach
07:41lenwLauJensen: is there a good intro on using Enlive and Moustache together ?
07:41LauJensenlenw: I wouldn't say 'good', but I talked about it some on my site when I relaunched it
07:42lenwthanks checking it out now
07:42somniumhttp://box2d-js.sourceforge.net/
07:42somnium^^ just saw this today, is there anything like this for swing/awt?
07:42LauJensenlenw: http://bestinclass.dk/blog.html, post #2 and #3 talk about some of the work that went into converting a wordpress blog and relaunching it on Moustache
07:42LauJensen(all source is open)
07:43lenwLauJensen: thanks
07:43LauJensennp
07:43somniumah, jbox2d
09:11mister_mdoes clojure support tail call optimization?
09:16dnolen_mister_m: http://groups.google.com/group/clojure/msg/0de2afb8995c77b5
09:20mister_mso due to the JVM, the answer is no; use recur
09:24LauJensenyup
09:24LauJensenwhich works out to be quite painless
09:25fogusCall me crazy, but I like the explicit recur over the implicit recursive self-call
09:25mister_mI could do either personally, but the explicit recur does remove any ambiguity I suppose
09:25LauJensenfogus: thats crazy talk
09:26mister_moff to work I go, thanks for the link to that discussion
09:27fogusif we ever get generalized TCO in the JVM, then maybe we should have another special form (tail-to ...) for the tail call ;-)
09:27fogusmister_m: Yeah, the non-tail error is a win IMO
11:38Bootvishow can I manipulate array maps?
11:40lpetitBootvis: I don't understand the question
11:42BootvisI understand, say I get an clojure.lang.PersistentArrayMap from some API and I want to no the first element
11:42Bootviswhat should I do
11:42Bootvisthis doesn't work
11:42Bootvis,(first {"foo" "bar"})
11:42clojurebot["foo" "bar"]
11:43nipra,(seq {"foo" "bar"})
11:43clojurebot(["foo" "bar"])
11:43lpetitBootvis: sure, Maps (in general) are not sequential
11:43LauJensen,(vals {"one" "two"})
11:43clojurebot("two")
11:44LauJensenlike lpetit said, its a different thing, its key/val based
11:44lpetitBootvis: PersistentArrayMap, though, will preserve the order of the keys, based on insertion, but it's dangerous to rely on it, I think
11:44LauJensen,(assoc {:one 1 :two 2} :two 3)
11:44clojurebot{:one 1, :two 3}
11:45lpetitBootvis: since the assoc, etc. functions on maps will "promote" array maps to hash-maps depending on their size
11:45LauJensenlpetit: Hi Laurent, hows it going?
11:46lpetit(LauJensen: hi ! Good, and you ?
11:46Bootvisok I'm experimenting with compojure and if I POST a form it returns an array map with the name and content of the fields paired
11:46LauJensenYea Im doing good thanks. Hows your path-finding in Lyon coming along?
11:46Bootvisso I sure hope that ordering is preserved
11:46LauJensenBootvis: IIRC thats also a key value pair
11:47lpetitBootvis: do you really need to know the order the pairs were inserted in ?
11:48BootvisI guess so, I should know which field has which value
11:48lpetitBootvis: I think you don't get what maps are. They are associative data structures: they associate a key with a value: { "key1" "val1", "key2" "val2" } .
11:49lpetitBootvis: array maps are not different in this area, it's just an implementation detail that they are based on arrays internally
11:49Bootvisok so that is preserved
11:50lpetitBootvis: so you just call seq on your map and you'll get a seq of pairs of key/value, (the pair will be in a vector) :
11:50lpetit,(seq {"k1" "v1" "k2" "v2"})
11:50clojurebot(["k1" "v1"] ["k2" "v2"])
11:50Bootvisok I thought that maybe I could access it directly
11:51Bootvisthanks for your time
11:51lpetitBootvis: why in first place did you know that you got an array map ?
11:52BootvisI used (class object)
11:53lpetithmm
11:53lpetit,(type {"k" "v"})
11:53clojurebotclojure.lang.PersistentArrayMap
11:53AWizzArd,shuffle
11:53clojurebot#<core$shuffle clojure.core$shuffle@1ae3e6d>
11:53arkhis it convention to use defn for java methods even if you don't expect the return value to change? E.g. (defn localhost [] (. InetAddress getLocalHost)) could just as easily be (def localhost (. InetAddress getLocalHost))
11:54lpetitBootvis: hint = use type instead of class. It will behave the same as class for pure java objects, but it will get you the clojure type which is a more interesting value in some cases
11:55lpetitarkh: not necessarily, what made you think so ?
11:55arkhhttp://github.com/aberant/clojure-networking/blob/master/server/udp.clj
11:56Bootvislpetit: thanks
11:56arkhlpetit: aberant's usage wraps methods with defn and values-only with def
11:57lpetitarkh: I do not have strong opinions on this. Don't know of any convention rule 'bout this
11:57arkhlpetit: ok - thank you for looking it over
12:30lpetitarkh: np
13:46tnksnew to clojure, is there a decent date/time implementation, or should I use Jota (sp?)
13:47tnksI guess it's JodaTime.
13:48technomancyyes, don't use java.util.Date for any nontrivial calculation.
13:53danlarkinthat's right... use chrono!!!11
13:57tnksdanlarkin: thanks, just what we were looking for
13:58danlarkinoh, I was actually being facetious, I don't think chrono has seen much effort
14:34dnolentnks: you should checkout clj-time, it's built on joda http://github.com/clj-sys/clj-time
14:35technomancywhich is really just chrono with a crappier name, innit?
14:37LauJensentechnomancy: sure, but just go with my fork instead then "timejure"
15:05technomancyoh snap
15:31homiehulloo
15:31homiecan someone help me setup clojure for emacs ?
15:31homiei repeated the steps in the movie to set it up
15:32homiei put the clojure script in my .emacs.d folder which is on a laod-path
15:32homieand the script runs itself from console
15:32homiethe part of my .emacs which tells (require 'clojure-autoload) fails though
15:33homiesorry i meant (require 'clojure-auto)
15:34LauJensenhomie: which movie?
15:37rbehi
15:38homiei get this here http://paste.lisp.org/+2FAP
15:38rbei tried to use an auto-gensym in a macro like this: `(let [x# '(1 2 3)] (first x#)) but i can just access x# without a function call… why?
15:38homieclojure on blip.tv
15:39LauJensenhomie: I havent seen that. I have a video on my blog as well you can check if, it you reach a dead end
15:39LauJensen,`(let [x# [1 2 3]] x#)
15:39clojurebot(clojure.core/let [x__501420__auto__ [1 2 3]] x__501420__auto__)
15:40LauJensenrbe: try (defmacro mac [] `(let [x# [1 2 3]] (first x#)))
15:40LauJensenthen run (mac)
15:41rbelaujensen: thanks… i am using a list not a vector… then i get 'unable to resolve symbol x# in this context'
15:42rbethe list is a list of forms and i want to evaluate the first
15:42LauJensenrbe: also with this (defmacro mac [] `(let [x# '(1 2 3)] (first x#))) ?
15:42rbeworks also… hm
15:46arkhwhat is the difference between nil and NIL?
15:47cemerickThere is no NIL in clojure.
15:48arkhsorry ... I was reading the code for fill-queue (and seque) and didn't see this: "NIL (Object.) ;nil sentinel since LBQ doesn't support nils"
15:48rbelaujensen: this works but does not evaluate the form: (defmacro mac [& a] `(loop [forms# '~a] (let [f# (first forms#)] f#))) .. (mac (+ 1 1) (+ 2 2)) == (+ 1 1)
15:48rbeadding ~ gives unresolved symbol:
15:48rbeuser=> (defmacro mac [& a] `(loop [forms# '~a] (let [f# ~(first forms#)] f#)))
15:48rbejava.lang.Exception: Unable to resolve symbol: forms# in this context (NO_SOURCE_FILE:217)
15:49LauJensenrbe: ~'a is a symbol defined in that namespace, ~a is your argument
15:50rbebut i used '~a as i want the quoted list so not all forms get evaluated
15:50rbeusing ~a gives same error
15:51raeka symbol# can only be used within the syntax-quote
15:51rbeseems that ~(first forms#) causes the error
15:51raekit doesn't make sense to mix compile-time and run-time this way
15:51rberaek: my macro starts with `
15:52LauJensenrbe: ~(first...) kills the `
15:52raekyes, but the second occurance is in the unquoted (compile time) section
15:52raekI just joined, so I did not catch what the macro should do
15:52LauJensenrbe: Keep in mind. Macros should be at a minimum in your code. Anything which doesnt require dynamic evaluation should be in an fn
15:53LauJensenraek will take it from here :)
15:53raekLauJensen: if you say so... :)
15:53Chousukeyou probably want to loop over the forms in the macro, not in the generated code
15:53LauJensenraek well since you jumped in the middle of it, I'll assume you have more time on your hands than I :)
15:54rbei just tried to implement a macro evaluating any given forms so i can play around with debugging or statistics… log any form and its execution time
15:54Chousukeie, something like (defmacro foo [& forms] `(do ~@(for [form forms] `(frobnicate form))))
15:54rbelooks interesting chosuke
15:55Chousukeand if the autogensyms don't work for you, you can always use manual gensyms :P
15:55raekrbe: evaluate when? compile-time? run-time?
15:56rberun-time
15:56raekif you just want to wrap some code, try making a function taking a function first
15:56kiemdoderwhat is the difference between (nth 2 [1 2 3]) and ([1 2 3] 2) ?
15:56rberaek: i wanted to print the form, its result and the time … so i think it must be macro?
15:56raek([1 2 3] 2] <=> (get [1 2 3] 2), iirc
15:56Chousukekiemdoder: no real difference.
15:57raekget and nth behave differently when the index is out of bounds
15:57Chousukekiemdoder: however, if it's (nth x somevar) vs (somevar x) there is an obvious difference :)
15:57raekif you want to print the form, I would have to
16:00raek(defmacro time-and-print [& forms] `(do (prn '~forms) (time (do ~@forms))))
16:00raekmaybe something like that
16:01rbeok and now for every form… not the total result
16:01rbe;)
16:01raekuser=> (time-and-print (+ 1 2 3))
16:01raek((+ 1 2 3))
16:01raek"Elapsed time: 0.104762 msecs"
16:01raek6
16:01raekah
16:01Chousukerbe: just add a for
16:02raekmaybe it would be easier to make a macro that does this for one form, and then another that does it for all
16:02Chousukerbe: you can just do something like (defmacro log-form [& forms] `(do ~@(for [form forms] `(do (log '~form) ~form)))))
16:04rbeyes… looks very good
16:04Chousukewhich for (log-form (+ 1 2) (* 2 3)) generates (do (do (log '(+ 1 2)) (+ 1 2)) (do (log '(* 2 3)) (* 2 3)))
16:04Chousukethough that macroexpansion is manual so I make no guarantees :P
16:05rbehad to learn that ` can be used more than once ;)
16:05Chousuke` actually has nothing to do with macros, really
16:05Chousukeit's just a convenient tool when you're writing them :P
16:06Chousukebut all macros are possible to write without `
16:06rbechousuke: why? i just started working with clojure and have to read 3 books i bought recently ;)
16:06Chousukerbe: ` is a way of constructing code structures easily
16:07rbeok.. what does it do?
16:07ChousukeI mean, (let [a 5] `(* 1 2 ~a)) constructs the list (clojure.core/* 1 2 5)
16:07raekuser> (macroexpand-1 '(log-form (+ 1 2) (* 2 3)))
16:07raek(do (do (user/log (quote (+ 1 2))) (+ 1 2)) (do (user/log (quote (* 2 3))) (* 2 3)))
16:08Chousukebut you can do that just as well by doing (let [a 5] (list '* 1 2 a))
16:08Chousukewell, except hm
16:08rbeah… something like a short form?
16:08Chousukethe symbol won't get namespace qualified
16:08rbewhen i do `(+ 1 1) i get (clojure.core/+ 1 1)
16:09Chousukeyeah, it does namespace resolution
16:09raekthe symbols gets namespace qualified
16:09raekthis is to avoid symbol capture
16:09Chousukerbe: you can think of it as a convenient template syntax
16:09Chousukerbe: but remember that clojure code is made of data structures, not text, so it's a template for a data structure
16:10Chousukeand where you need such a data structure, you can use `
16:10rbe8-)
16:10rbethanks
16:10Chousukeit works with all clojure data structures too, not just lists
16:11Chousuke,(let [a 5] `[a b ~a])
16:11clojurebot[sandbox/a sandbox/b 5]
16:12raek,`(let [a 1] a)
16:12clojurebot(clojure.core/let [sandbox/a 1] sandbox/a)
16:12raekah
16:12Chousukethat would actually not work if you emitted that from a macro :)
16:12raek...and then the compiler refuses to do that let
16:12raekyes
16:13Chousukeyeah. It's a nice solution for the name capture problem.
16:13raekI was thinking if that logic was built in into syntax-quote
16:13raekbut i see now that it does not have too
16:13raekvery.
16:13raekhas this been implemented in another lisp?
16:14ChousukeI don't think so
16:15raekso rich solved this ancient problem as well by himself?
16:15raekman, he
16:16ChousukeI don't know. Maybe he was inspired by something
16:16raek's smart
16:16raekclojure sure has *a lot* of goodies in it
16:16ChousukeI don't know of other lisps implementing Clojure's solution, but that doesn't mean they don't exist somewhere :D
16:17fogus_Let Over Lambda has a macro defmacro! (I think that was the name, I do not have my copy here) that works in a similar way
16:17ChousukeYeah, that's what I like most about it.
16:17Chousukelots of small things that by themselves are nothing special
16:17Chousukebut then it just kind of works together
16:18ChousukeThere are warts too but every language has those :P
16:19callen-nycChousuke: the first/last/nth/rest stuff can be a wee inconsistent in nomenclature.
16:19callen-nycthat's my only real complaint of lae.
16:19callen-nyclate
16:20rbeso long … thanks a lot guys… i've got to sleep now
16:20rbesee you
16:26kiemdodercallen-nyc, I agree there often seem to be more than one way to do the same thing which can make it a bit challenging to learn
16:27kiemdoderit being clojure
16:39triyoDoes anyone else think this is cool http://hackage.haskell.org/package/DSTM-0.1.1 a framework for using STM within distributed systems?
16:40callen-nyckiemdoder: yedah.
16:40callen-nycer, yeah.
16:40callen-nyckiemdoder: you get past it, but it's kind of *_* compared to [listy, list][slicey]
16:40callen-nycor object[slice]
16:48eckrothhow do I import/use/whatever a record (from defrecord) into another namespace?
16:55eckrothanswer to my question: http://tech.puredanger.com/2010/06/30/using-records-from-a-different-namespace-in-clojure/
17:00hoecktriyo: yes!
17:02triyohoeck: came across it earler today and thought that it might be something nice to see in Clojure in the future for satisfying distributed models.
17:06cemerickI remember suggesting a while back that require be invoked for the namespaces corresponding to each imported class. That was back when gen-class was the only game in town, so now I'd suggest adding the namespaces corresponding to the package of imported classes. Then (import 'some.package.YourRecord) would automatically attempt to require some.package.
17:25eckrothany opinions? is enclojure better than emacs/slime for larger projects? is enclojure stable, fast?
17:29eckrothenclojure does not have a paredit equivalent, I'm assuming
17:32dnoleneckroth: enclojure certainly seems featureful and stable. tho because of the Java GUI I don't find it particularly fast on my machine.
17:33dnoleneckroth: seems more compelling when you want to integrate with lots of Java libraries.
17:33eckrothdnolen: thanks. that's basically what I feared. I've had painful experiences with Eclipse crashing, so I generalize that to "all big IDEs crash too much"
17:33eckrothdnolen: ah, that could be useful; at the moment, I'm mostly thinking "big clojure project", as in, lots of namespaces and files
17:34dnoleneckroth: I've never had Enclojure crash on me but again I don't use it much. Overall Netbeans seems nicer to me to me than Eclipse.
17:35dnoleneckroth: one thing that I like about Enclojure is excellent symbol navigation
17:35eckrothdnolen: unfortunately, I basically use one IDE for each separate development language; I use Qt Creator for C++ projects, Eclipse for Android projects, Vim for PHP projects (on the server), and Emacs for Clojure projects
17:35eckrothdnolen: I noticed that in the screenshots
17:36dnoleneckroth: that doesn't seem that weird to me :) go with the best tools for the platform.
17:37eckrothdnolen: yeah but they each have their own style (key combinations, for example); keeps me multifunctional (I get to avoid the Vim vs. Emacs debate, for example) but seems a bit of a shame that I can't customize just one environment and be happy
17:37dnoleneckroth: three things that would make Enclojure more compelling to me: 1) eval last sexpr, 2) macroexpand last sexpr, 3) paredit
17:38eckrothdnolen: besides key combinations, each have their own git integration :) magit seems the best so far
17:38eckrothdnolen: yeah I use (1) and (3) all the time; too bad for enclojure
17:39dnoleneckroth: yeah magit is great. I keep meaning to learn some elisp to try my hand at improving Emacs/Clojure. too little time in the day.
17:51flintfI haven't been able to get enclojure working
17:52flintfWell I did awhile ago, but when I tried to use it recently it wouldn't work...
17:53eckrothflintf: that's the kind of annoyance that I want to avoid
18:04defnim so firmly embedded in emacs that another IDE wouldnt probably entice me
18:04technomancynot even Genera?
18:05Raynesdefn: Didn't we argue over this a while back where you said that I would be silly to not jump at a nice Clojure IDE just because I liked emacs?
18:07defnyes we did
18:07defni concede
18:07defni play devil's advocate on that topic though
18:07defnsimply because...well...diff'rent strokes for diff'rent folks
18:08rhudsonflintf: at some point it seemed enclojure worked with netbeans 6.8 but not 6.9 -- I don't know if that's been addressed yet
18:08defntechnomancy: should i know that reference? I'm not familiar
18:09qbgGenera might be awesome if it worked with Clojure
18:09defnlink please?
18:09technomancyit was before your (and my) time: http://en.wikipedia.org/wiki/Genera_(operating_system)
18:09defnoh!
18:10defnwell color me young
18:39defnhttp://bigthink.com/davidheinemeierhansson
18:39defnoops
19:19slyrusyay. SMILES parsing support completed.
19:29gfrlogis it possible to eval code within a different namespace?
19:29gfrlogparticularly one created at runtime
19:45danielfmgfrlog: if you syntax quoted (with a backquote) the piece of code, I think should be possible because it expands the symbol names
19:46danielfm, `map
19:46clojurebotclojure.core/map
19:46gfrloghuh?
19:47danielfm, `(reduce + (range 10))
19:47clojurebot(clojure.core/reduce clojure.core/+ (clojure.core/range 10))
19:47gfrlogso you mean the code would have to be created in the namespace?
19:47danielfmsee how it expanede the name of the symbols?
19:48danielfmfor example, let's say that you have a namespace with a few functions in it
19:49dsopif I use (multimethod foo class), how cna I check against Seq?
19:49danielfmif you generate the form with this backquote thing, the symbols will also include the namespace that they belong to, e.g. my-ns/my-function
19:50danielfmthat way you won't have to (use ..) that namespace in order to (eval ..) that form
19:51gfrlogthe code and the namespace are both loaded at runtime though
19:54danielfmgfrlog: I think it doesn't matter since they can be resolved by the compiler
19:55danielfmgfrlog: can you share some code in http://gist.github.com/ or something?
19:57gfrlogyeah, one second
19:59dnolentechnomancy: erg it's been so long since I hacked on leiningen, if I want to use leiningen from source can I just symlink the lein script in the repo and that will use the .clj files in the repo?
20:00dnolenI'm seeing an issue with my nativedeps plugin and need to investigate
20:03tomojI noticed the readme for lein no longer explains how to do that, I think it used to
20:03technomancydnolen: that should work. you can bootstrap self-install on snapshots now fwiw.
20:03gfrlogdanielfm: here you go http://gist.github.com/507413
20:03dnolenactually, the problem isn't really nativedeps as far as I can tell but that the native path is no longer set in the latest version of leiningen
20:04gfrlogI decided it can work if I convert the code to a string, preface it with a (ns) call, and use (load-string)
20:04gfrlogbut I don't know if that's the nicest way or not
20:06gfrlogI think I've always thought of the load functions as being just for loading definitions, not for evaluating code. But I can't think of any reason why it shouldn't be used for evaluation
20:07dnolentechnomancy: hmm, getting could not find file classpath errors, how does the bootstrap self-install work is that documented anywhere ?
20:08dnolensorry classpath errors when symlinking lein script into my path
20:09danielfmgfrlog: okay, I'm looking into it
20:09gfrlogthanks!
20:12danielfmgfrlog: the first thing I think it can be improved here is the way you generate the code
20:12danielfmgfrlog: why not generate a plain list instead of a string?
20:13gfrlogthey're both strings actually
20:13gfrlogsent over http
20:13clojurebotmake a note of http://scienceblogs.com/goodmath/2006/11/the_c_is_efficient_language_fa.php it is yet another article about picking c or c++ for performance being naive
20:13gfrlogso they have to be strings at some point
20:16tomojwhere does this "Overriding previous definition of reference to" thing even come from?
20:16tomojcan't find it in clojure or leiningen
20:16danielfmgfrlog: well, without change much what you did in the gist, the eval will work if you replace the (def code ..) with (def code '(my-ns/x 12))
20:17danielfmgfrlog: or you can just use that namespace before the eval
20:17gfrlogthe first idea is what I'm trying to avoid
20:17gfrlogthe second idea makes it hard to get the return value and change the namespace back
20:21danielfmgfrlog: well, you have to tell the compiler somehow how to find that function if it's another namespace... so I don't see a way out of this
20:23gfrlogif there were an (eval-in-ns) macro, that'd be fantastic
20:38danielfmgfrlog: something like (eval-in-ns code 'my-ns) ?
20:46technomancydnolen: the self-install implementation is like seven lines, it's probably clearer than any docs on it could be.
20:46dnolentechnomancy: swank-clojure just calls leiningen's eval-in-project correct?
20:46technomancyyeah
20:46technomancywell, lein swank does.
20:48dnolentechnomancy: is leiningen-1.3.0 going to coincide with Clojure 1.2?
20:51technomancydnolen: probably not, but lein 1.3.1 should.
20:54dnolentechnomancy: it's still not clear to me what exactly I have to do to run leiningen from source, are you talking about self-install inside lein.sh ?
20:55lancepantzdnolen: it's actually really easy to bootstrap lein with cake
20:56dnolenlancepantz: how is that done?
20:56technomancydnolen: there's like three ways to build from source now; check "Building" in the readme.
20:56lancepantzjust do cake deps from your lein checkout and symlink the bin
20:56technomancybin/lein self-install is just the easiest.
20:58dnolentechnomancy: sorry, I'm being slow here. I haven't really messed with lein since 1.1.0
20:58dnolenI just needed to run lein deps
20:58dnoleninside the repo
20:58dnolenlancepantz: yeah I had basically done that
20:58dnolenlancepantz: technomancy: thx much
20:59technomancyaight; cool.
21:00dnolenhmmm
21:00dnolenlein-dev clean works, but lein-dev deps -> null pointer exception
21:03gfrlogdanielfm: yes, that's the sort of thing I'd like
21:07danielfmgfrlog: take a look at your gist
21:13gfrlogdanielfm: will that work without polluting the current namespace? i.e., are the effects of "use" temporary?
21:14danielfmgfrlog: unfortunately no, that (use ..) will do exactly what it does when used elsewhere
21:16danielfmgfrlog: but if you don't do that, you'd need to fully qualify the symbols in your expressions, e.g. (my-ns/my-fn ...), and also require it for eval-in-ns to work
21:20bortrebanyone here a paredit master?
21:21bortrebI'm wondering, let's say you have something like
21:21bortrebprintln 1 2 3
21:21bortrebhow do you turn it into (println 1 2 3) in paredit-mode?
21:22lancepantzput your point at the start then type: (, C->, C->, C->, C->
21:22danielfmbortreb: select the whole thing and press M-(
21:22tomoj`huh, C-> is unbound for me
21:23tomoj`I'd use M-(, C-), C-), C-)
21:23lancepantzthat should be C-->
21:23lancepantzas in right arrow
21:24gfrlogdanielfm: I think load-string will do what I want, as long as I prefix a "(ns)" declaration
21:24tomoj`arrow keys are the devil :P
21:25bortrebno dice for either C-> or C-) for me, maybe you both have special bindings?
21:25gfrloghow can I check if a var has been defined/bound?
21:26lancepantzbortreb: they both work for me, are you sure your in paredit mode?
21:26danielfmhere it works if I put the cursor before 'println', then M-(, then C--> 3x
21:26danielfmno special bindings here
21:26danielfmnice tip btw
21:27tomojno special bindings here either, and both work
21:32danielfma nice paredit cheat sheet: http://mumble.net/~campbell/emacs/paredit.html
21:32bortrebfor some reason they don't work for me at all
21:33bortrebis there a way to see to what C-) is bound for me?
21:33lancepantz^C, ^H
21:34tomojC-h k C-)
21:35tomojbortreb: what's your C-h v paredit-version ?
21:36bortreb20
21:36tomojfrom ELPA?
21:36bortrebyeah
21:37tomojget rid of it, grab http://mumble.net/~campbell/emacs/paredit-beta.el
21:37bortrebah ok
21:37nollidjanyone here try to use with maven and penumbra together? i think i'm missing a little thing in my pom.xml that's preventing the native deps from being incorporated properly
21:37lancepantzfwiw, i'm on 20 as well
21:37danielfmtomoj, bortreb: in any case, I'm using the ELPA one and those key bindings work fine
21:37tomojcool
21:38tomojdon't you have curly problems with 20?
21:38danielfmtomoj: I don't even know whatta hell is it.. :)
21:38tomojclojure-mode detects paredit 21 or greater and fixes {}
21:38lancepantzmy curlies don't work
21:38lancepantzand quotes are a pita too
21:38tomojget the beta then
21:39lancepantzyeah, i'm going to try it out
21:39lancepantzi'm actually slowly trying to migrate off of elpa
21:39yonatan_gfrlog: i think it's (bound? foo)
21:39bortrebI've remapped my keys so that "9" and "(" are switched, and whenever I try to do C-h k C-), it just gives me the help as if I had typed C-h k C-)
21:39danielfmahh yeah
21:39gfrlog'(bound? x)
21:39gfrlog,(bound? x)
21:39clojurebotjava.lang.Exception: Unable to resolve symbol: x in this context
21:39bortrebit's like it can't see the Ctrl modifier
21:39gfrlog,bound?
21:39clojurebot#<core$bound_QMARK_ clojure.core$bound_QMARK_@18598b6>
21:39gfrlogI must have an old clojure
21:40gfrlogmine doesn't work
21:40gfrlogI'll use a try-catch
21:40bortrebin the latest clojure bound? doesn't work like that either
21:40bortrebit tries to evaulate the dubious symbol
21:40lancepantzbortreb: does it catch the npe now?
21:40gfrlogapparently it doesn't in clojure-bot either
21:41gfrlog,(clojure-version)
21:41clojurebot"1.2.0-master-SNAPSHOT"
21:41tomojhere's my bit from init.el for paredit: https://gist.github.com/d426a96b5f5a5fca6cd6
21:42yonatan_,(bound? (var bound?))
21:42clojurebottrue
21:42yonatan_,(bound? (var foo))
21:42clojurebottrue
21:42mister_mclojure code looks a lot scarier than perl code I think.
21:43danielfmtomoj: thanks!
21:44rhudsonmister_m: It gets a lot less scary once you get used to it. (Perl code stays scary, in my view)
21:50pdkthe funky indentation style you see in a lot of lisp code is there to help deemphasize all the parens
21:51mister_mit's not the parens that bother me really
21:52mister_mall the extra symbols are what distract me, but as rhudson said, it just takes getting used to
21:52mister_mI'm still in the 'getting used to' period
21:52pdkby the by for folks using vimclojure here is there a command to reindent a whole block like in emacs
21:56mister_mI should try to start a project so I can do some actual coding with clojure
21:56mister_minstead of fooling with the REPL
21:57rhudsonGood idea, except I would recommend "in addition to" in place of "instead of"
21:57mister_mrhudson, yes, that is certainly better
21:58rhudsonOne of the great things about using Clojure is you get to keep playing with the repl!
22:04mister_mI'm not sure if I like the Programming Clojure book very much though.
22:04mister_myet
22:04rhudsonWhy not?
22:04lancepantzmister_m: the joy of clojure is much much better
22:05lancepantzi didn't like programming clojure either
22:06mister_mrhudson, it seems really very rushed
22:06rhudsonI thought it was a very good intro book.
22:07lancepantz,(def *foo* (atom 0))(binding [*foo* (swap! *foo* inc)](println *foo*))
22:07clojurebotDENIED
22:08rhudsonmister_m: what other languages do you know?
22:08lancepantzguess i can't def vars
22:08mister_mrhudson, I've used java before
22:08tomojlancepantz: sexpbot will let you
22:08lancepantzanyways, in that above, why do i not have to dereference *foo* to print it?
22:08lancepantzsexpbot: (def *foo* (atom 0))(binding [*foo* (swap! *foo* inc)](println *foo*))
22:08sexpbotThis command is old. Use -> now. It's a hook, so it can evaluate anything, even stuff that doesn't start with parentheses.
22:09lancepantzshouldn't i have to (println @*foo*)?
22:10tomoj-> (let [x (atom 0) y (swap! x inc)] (class y))
22:10sexpbot=> java.lang.Integer
22:10rhudsonmister_m: I had a lot more languages, including some functional ones, before I got to Clojure, so our experience of the book is undoubtedly different.
22:11lancepantzso atom doesn't turn ints into refs?
22:11tomojhuh?
22:11rhudson,(println (atom 0))
22:11tomojit's just that swap! returns the value, not the atom
22:11clojurebot#<Atom@c73a54: 0>
22:11lancepantzah
22:11rhudson,(println @(atom 0)))
22:11lancepantzi see
22:11clojurebot0
22:12lancepantzright, i was misunderstanding swap
22:13mister_mrhudson, I'm sure that is true. I'm pretty green.
22:13mister_mso to speak
22:13rhudsonmister_m: you have a lot of fun ahead of you
22:27bortrebhow do you translate this into clojure? HttpZipLocator.class.getName()
22:28rhudson(.getName HttpZipLocator)
22:28mefesto(.getName (class HttpZipLocator))
22:29bortrebthose are different though
22:29bortreb,String
22:29clojurebotjava.lang.String
22:29rhudson,(.getName String)
22:29clojurebot"java.lang.String"
22:29tomojis .class a way to get the Class object of a class? never saw that before
22:29bortreb,(.getName (class String))
22:29clojurebot"java.lang.Class"
22:29wwmorganhow can I do (apply concat colls) lazily?
22:30bortrebso which is it>?
22:30mefestobortreb: rhudson is the right way to go :)
22:30bortrebI'll never get java and it's random bloat....
22:31pdktesting
22:31mister_mrhudson, one thing specifically I don't like about the Programming Clojure book so far, is the invocation of Java string methods while trying to teach the core language
22:31pdk(doc apply)
22:31clojurebot"([f args* argseq]); Applies fn f to the argument list formed by prepending args to argseq."
22:31pdkmaybe you could wrap your apply form in a lazy-seq call?
22:31pdk(lazy-seq (apply ...
22:32rhudsonor use lazy-cat maybe
22:32pdk(doc lazy-cat)
22:32clojurebot"([& colls]); Expands to code which yields a lazy sequence of the concatenation of the supplied colls. Each coll expr is not evaluated until it is needed. (lazy-cat xs ys zs) === (concat (lazy-seq xs) (lazy-seq ys) (lazy-seq zs))"
22:32pdk(doc cat)
22:32clojurebotPardon?
22:32pdk(doc concat)
22:32clojurebot"([] [x] [x y] [x y & zs]); Returns a lazy seq representing the concatenation of the elements in the supplied colls."
22:32rhudson... lazy-cat is a macro though, so apply won't work with it.
22:33pdkgod damn kitty
22:33wwmorganyes. And apply isn't lazy, so (lazy-seq (apply concat colls)) won't work
22:33pdkcan't apply its talents to any work
22:35tomojisn't (apply concat colls) already lazy?
22:35tomoj-> (take 3 (apply concat (repeatedly #(iterate inc 0))))
22:35sexpbot=> (0 1 2)
22:35wwmorgantomoj: very interesting. I didn't know that worked :-)
22:37tomojmaybe that's not the laziness you're looking for?
22:38wwmorganno, it's exactly right. I don't know why I thought apply couldn't be lazy
22:39rhudsonmister_m: I don't remember that. Like where? (i have the book at hand)
22:42tomoj`was the lazy apply concat question answered while I was away?
22:42tomoj-> (first (apply concat (repeatedly #(do (println "foo") (iterate inc 0)))))
22:43sexpbot=> foo foo foo foo 0
22:43tomojwhy 4 of them?
22:43pdkit's laughing at you
22:44pdkthat's why it's going foo foo foo
22:44tomojoh, it's because the last def for apply is ([f a b c d & args])
22:44pdkthough im curious why this bot is different from clojurebot
22:45tomojbut:
22:45tomoj-> (first (apply concat (repeatedly (fn [] (do (println "foo") (iterate #(do (println %) (inc %)) 0))))))
22:45sexpbot=> foo foo foo foo 0
22:45mister_mrhudson, page 58 sticks out
22:45tomojso isn't it already lazy enough?
23:13mister_mshould I make some orange chicken at 10:12 at night?
23:13mister_mI'm tempted
23:14mister_mreaaaaally tempted
23:58pdkoh snap
23:58pdkhow come you guys had to be meanies and not tell me about defn- earlier
23:58pdki'm telling mommy
23:59Raynespdk: You should just *know*. ;P