#clojure logs

2012-05-31

00:00amalloy(even though it claims to). and you installed 0.3.0, which is the lein2 plugin, not the lein1 plugin
00:01coventryJust a misunderstanding, will give it a go. Thanks.
00:04coventryAh, so that's why adding the plugin to ./lein/project.clj didn't work.
00:32michaelr525morning!
03:01tomojdevn: hey, do you still have the link to that gist about core.logic?
03:02tomojmy laptop conveniently locked up completely right as I was going to click on it, thinking "whoa"
03:02tomojand google custom search seems not to have picked it up yet
03:03tomojoh
03:03tomojdatomic not core.logic
03:03tomojfound it
03:21muhoowhere is it?
03:35muhoooic, i had to do this before i finally understood it: (->> [185 13235209671M 25939708511M 1654794401M 12429901063M 131081 65539] (mapcat #(cons "\n" (next (map {\0 \ , \1 \#} (Long/toBinaryString %))))) (apply str) symbol)
03:35muhooit's a bitmap, clever.
04:35TEttingerhmm
04:35TEttingerI'm trying to make a dead-simple Conway's Game of Life in the console
04:36ordnungswidrigTEttinger: that is a good excercise
04:36TEttingerand I can't figure out how to keep the app going, continually generating new boards
04:36TEttingerit is something to do with Thread/sleep
04:36ordnungswidrigshould it repeateldy print the state in the repl?
04:37TEttingerI just need to know a way to evaluate some function, sleep, eval, sleep, etc.
04:37TEttingerwell it could use a repl?
04:37TEttingeri was just using lein run
04:37TEttingeri used the repl for the development part
04:37ordnungswidrigk
04:38ordnungswidrigcan you show your problem at a pastebin?
04:39clgvTEttinger: you just need an infinite loop that prints one iteration step.
04:40clgvmaybe you should specify in advance how many steps you want to see ;)
04:40clgvTEttinger: e.g.: (dotimes [_ 100] (my-iteration-code))
04:41PeregrinePDX(take 10 (repeatedly game-of-life-function))
04:41PeregrinePDXWould get you 10 iterations.
04:42TEttingerthanks
04:43ordnungswidrigfor a pure implementation you can do like this:
04:43TEttingerI was struggling with ideone having weird syntax highlighting, and that made me think there was a problem with my code
04:43TEttingerhttp://pastie.org/4000414
04:44ordnungswidrig(->> step-fn (repeat num-iters) (reduce #(%2 %1) seed))
04:45TEttinger->> does what now?
04:46ordnungswidrig(->> 5 (+ 1 2 3) (print "result" )) will expand to (print "result" (+ 1 2 3 5)) thus is "inserts" the result as the _last_ argument to the next expression
04:46TEttingerPeregrinePDX, yeah the code i based it off of (mislabeled in there, part of -main is the original code)
04:46ordnungswidrigbut it was overly complicated because iterate will be easier
04:46TEttingeryeah the code originally used iterate
04:47ordnungswidrigso (nth (iterate step seed) num-iters) will be easier
04:47TEttingerI'm sorry, what?
04:48TEttingerwhat is that solving?
04:48ordnungswidrigthis will to the same as the code I showed above using reduce
04:48clgvprobably `take` is better since you want to see the progress of the game, right?
04:48TEttingeryeah
04:48TEttingerbut I need to pause with Thread.sleep between printing the steps
04:49TEttingerideally it would keep going until the user Ctrl-D or Ctrl-C 's it
04:49PeregrinePDXSo remove the take x portion.
04:49ordnungswidrigPeregrinePDX: there is no printing
04:50TEttingeryeah, but how would I sleep
04:50clgv(Thread/sleep 1000)
04:51TEttingersteps it needs to do: run first generation, print, sleep, run second generation, print, sleep...
04:51clgv&(do (println "1") (flush) (Thread/sleep) (println "2") (flush))
04:51lazybotjava.lang.NoSuchFieldException: sleep
04:51TEttinger&(do (println "1") (flush) (Thread/sleep 10) (println "2") (flush))
04:51lazybot⇒ 1 2 nil
04:51clgvah lol^^
04:52TEttingerso how would i handle function calls mixed into taking an element from a lazy sequence
04:52clgvTEttinger: (doseq [board (iterate ...)] (println board) (Thread/sleep 1000))
04:53TEttingeroh! doseq! I always forget about the do??? functions
04:53TEttingerthanks clgv, will try
04:53clgvyou want to have side effects, you should use a `do*` ;)
04:59TEttingerhttp://pastie.org/4000482 for those who want to try, it needs an 80-char-wide terminal
05:45amalloyTEttinger: have you looked at http://www.4clojure.com/problem/94?
06:21openedI'm going to start reading sicp. Any comments on the book, from the clojure perspective?
06:22clgvamalloy: that one is underspecified for the "edge cases" ;)
06:25ejacksonanybody know the equivalent for $(this) is cljs ?
06:26ejackson(using jayq, that is)
06:26clgvejackson: maybe an implizit 'this symbol?
06:27clgv*implicit
06:27ejacksonyeah, I fooled about with ($ "this") and ($ :this) etc
06:28ejackson(js* "this") yields DOM objects in callback, but is a bit wild
06:31clgvejackson: did you examine the js it is compiled to?
06:31ejacksoneep, no I didn't, good call, thanks !
06:34ejacksonlol its 20k lines
06:34ejacksonhence all the fuss about minifiers :)
06:37ejacksonFTR, this works: ($ (js* "this")) in callbacks to get a jquery on that thingie doing the calling
06:37kilonnever liked any of the common lisp / scheme books i read
06:37ejacksona bit wild though
06:37kilonconfused me a lot
06:37kilonfortunately clojure documentation is way better
06:38kiloni find this very helpful
06:38kilonhttp://clojuredocs.org/quickref/Clojure%20Core
06:38clgvejackson: if you are interested you could trace back through jayq where ($ :this) fails. would be worth a patch I guess.
06:39clgvkilon: this is also pretty good: http://clojure.org/cheatsheet - I have the pdf printed on the desk ;)
06:40kilonclgv: indeed this is extremely helpful
06:41kilonthanks , missed that one
06:41kiloni am suprised that such a new language has such good documentation
06:45ejacksonclgv: I'll raise it, but I'm sure there's a reason its not there already :)
06:45ejacksonRaynes: you're a contributor - you still about ?
06:46clgvejackson: which reason would that be?
06:46ejacksonsomething like "yes it works in your instance, but look at this other case where it blows up"
06:46ejacksoni don't know enough about the JS world to say
06:48clgvthen I would start with the premis that this one might have slipped attention so far since cljs and jayq are both pretty young ;)
06:49ejacksonalrighty, I'll raise an issue and see who slaps me up first :)
07:13clgvInstead of having global parameters for the run of an algorithm, which are accessed where needed, one could compile the functions of the algorithm when just before the run and inject the parameters as constants into the code of the functions. One could write a special defn-macro for this. Has anyone tried that yet?
07:15ejacksonsortof like inlining data
07:17clgvejackson: and functions. I'd describe it more as templates for functions
07:17ejacksonwhat's the win ?
07:17clgvThe functions would get cleaner since I dont have to pass the Parameter-Container along and access it to query the parameter values
07:19ejacksonyou can't have the data as argument 0 and partial it in ?
07:19clgvjvm could inline functions (that are given as parameter as well)
07:19clgvejackson: it's distributed through the whole algorithm
07:19ejacksonyeah, I have similar stuff but I like it there :)
07:20ejacksonso I can see its bony ass
07:20clgvI dont like it - I would like more clarity and save the additional parameter access times
07:21clgvI have a single point where I could compile the whole thing
07:22clgvmaybe it could even be dual: if no parameters are bound it compiles normal functions that take the parameter-container
07:23ejacksoni've grown to be frightened of such magics
07:24clgvit needs to be thouroughly tested. thats true. but it can't really cause much pain since it'll explode if no params are bound ;)
07:26clgva pity that the word "template" is so strictly bound to html if you search for "clojure function templates"
07:27clgvhmmm there is clojure.template but thats not sufficient
07:27clgvand not really near the vision I have
07:30michaelr525can i create a non-caching lazy seq using loop recur? I would like to "run over" the rows of a big table, proccesing one at a time.
07:35Chousukemichaelr525: just use a lazy seq and doseq
07:37michaelr525Chousuke: isn't there a potential stack overflow?
07:37Chousukeno?
07:37clojurebotno is tufflax: there was a question somewhere in there, the answer
07:37michaelr525Chousuke: i mean, lazy-seq implies recursive function call which implies stack overflow, no?
07:38Chousukenope
07:38Chousukelaziness prevents the stack growth
07:39michaelr525are you sure? i will eventually force the whole seq
07:40michaelr525say 2M items, means 2M recursions no?
07:40Chousukeths recursive call is done when an element is realised, at which point the previous call will have returned
07:40sjlmichaelr525: as long as you don't hold onto a pointer to the head of that seq, the elements will get garbage collected as you move past them
07:40michaelr525great! :)
07:40Chousukethat is a separate issue
07:41clgvkilon: slow. see solaris ;)
07:41sjlyeah, there's not really any recursion because by the time you actually call the function a second time you're out of the first call
07:41kilonclgv: i dont mean entirely, linux kerner will do
07:42kilonkeep around things in C for speed, is perfectly fine by me
07:43clgvkilon: isnt solaris a unix with only a java desktop?
07:43kilonit is ? sorry i am not that familiar with it
07:43kilonnever used it
07:43clgvI had a demo cd back in 2004 or so ;)
07:44scottjkilon: I don't think clojure dictates much of how a user environment would be. you could imagine the concurrency and database-backed filesystem of BeOS (but with datomic), the interactiveness of smalltalk VM/Symbolics Genera/emacs, but maybe you'd just end up with unity running the speed of libreoffice.
07:45kilonone thing i learned , is making a coder life easier, immediately affects the user
07:47kilonlook how much python boosted the development of linux
07:48kilonpupy linux uses both genie (python clone that runs much faster, with static types) and Vala (C# clone)
07:49kiloncant say either have any noticable slow downs
07:49kilonand python is way way slower than clojure
07:49michaelr525(defn rows [start-at limit]
07:49michaelr525 (lazy-cat (get-rows limit start-at) (rows limit (+ start-at limit))))
07:50michaelr525does this look ok ^^^
07:51michaelr525i mean, it doesn't hold onto it's head, does it? ;)
08:00michaelr525wow
08:00michaelr525it works
08:00michaelr525so cool..
08:02michaelr525err
08:02michaelr525how to stop?
08:02michaelr525hehe
08:04kilonreboot always works :D
08:05michaelr525maybe take-while
08:09michaelr525if lazy seq doesn't recurse, why do we need loop recur?
08:11ejacksonfor data not dealing with seqs :)
08:12michaelr525such as..
08:14ejacksona numeric function: such as say an integration
08:14michaelr525(defn rows [limit start-at]
08:14michaelr525 (lazy-cat (get-rows limit start-at)
08:14michaelr525 (rows limit (+ start-at limit))))
08:14michaelr525why take 1 from the above triggers infinite realization?
08:16bobryhow can I tell cljsbuild to include a js library in the output file?
08:16ejacksonbobry: i dunno, i tend to put it into the HTML template
08:17ejacksonmichaelr525: depends on get-rows i guess
08:17bobryyup, that'll surely work :)
08:17bobryI thought it has :externs option, but I can't find it in the docs
08:17ejacksonluke vanderhart's articel goes into this, 1 sec
08:18ejacksonhere: http://lukevanderhart.com/2011/09/30/using-javascript-and-clojurescript.html
08:19michaelr525ejackson: err how does it depend on get-rows? the whole thing seems very lazy to me
08:19ejacksonwell, I dunno what get-rows is/does, it might realise the whole thing
08:20bobryejackson: thanks! that's exactly what I needed :)
08:20michaelr525ejackson: it returns a vector of maps (rows from database)
08:21ejacksonhmm, dunno.
08:22michaelr525oh, maybe the repl does automatically?
08:24ejacksonchunking perhaps
08:24michaelr525ah
08:24michaelr525yeah, it could be
08:24michaelr525damn chunking
08:26ejacksonah
08:27michaelr525not chunking i think, i replaced get rows with the following and it works as expected now: (defn get-rows [row-limit start-at] [1 2 3])
08:31michaelr525ejackson: it happens when get-rows returns an empty seq
08:32michaelr525ejackson: how do you explain that?
08:34ejacksondunno
08:34ejackson:)
08:35michaelr525&(lazy-cat [1 2 3] [0])
08:35lazybot⇒ (1 2 3 0)
08:36michaelr525&(lazy-cat [1 2 3] [])
08:36lazybot⇒ (1 2 3)
08:36michaelr525&(lazy-cat [] [])
08:36lazybot⇒ ()
08:36michaelr525&(defn get-rows [] nil)
08:36lazybotjava.lang.SecurityException: You tripped the alarm! def is bad!
08:36clojurebotRoger.
08:39michaelr525&(let [f1 (fn [] nil) f2 (fn [] (lazy-cat (f1) (f2)))] (take 1 (f2)))
08:39lazybotjava.lang.RuntimeException: Unable to resolve symbol: f2 in this context
09:01Chiron_Hi, (defn fun [id & {:keys [name phones]}] (println name) (println phones)) phones is a varargs . it could be one value or a lot of values . should I destructure it somehow also?
09:11mfexChiron_: phones can't be both a keyword argument and a varargs. You should pass it a collection if you more than one value for phones
09:23rguilleberthi
09:24rguillebertis there something equivalent to the haskell "where" clause in clojure ?
09:27jedmtnmanrguillebert: cond, maybe?
09:27jedmtnman,(doc cond)
09:28clojurebot"([& clauses]); Takes a set of test/expr pairs. It evaluates each test one at a time. If a test returns logical true, cond evaluates and returns the value of the corresponding expr and doesn't evaluate any of the other tests or exprs. (cond) returns nil."
09:28jedmtnmanor
09:28jedmtnman,(loop)
09:28clojurebot#<ExecutionException java.util.concurrent.ExecutionException: clojure.lang.ArityException: Wrong number of args (0) passed to: core$loop>
09:28jedmtnman,(doc loop)
09:28clojurebot"([bindings & body]); Evaluates the exprs in a lexical context in which the symbols in the binding-forms are bound to their respective init-exprs or parts therein. Acts as a recur target."
09:29mfexrguillebert: use (let or (letfn. for both of these the declarations come for their usage, in haskell the declarations in the 'where' are after their usage
09:39rguillebertmfex, yes I think that'll do it
09:39rguillebertthanks
10:25glitch99this is kind of a goofy question - don't know if anyone is in the room - what is the typical clojure/lisp coding style - lots of _ like C? lots of camel case like java and C++? hungarian?
10:25babilenglitch99: typically-like-this
10:25glitch99lowercase and dash?
10:26babilenglitch99: Yes. See http://clojure.github.com/clojure/ for a list of functions in the standard library
10:26bsteuberyes except java casing for java interop
10:26di-csuehsthat is an interesting question...I don't recall seeing a style guide.
10:27glitch99awesome :-) thanks everyone!
10:27babilendi-csuehs, glitch99: http://dev.clojure.org/display/design/Library+Coding+Standards
10:27Vinzentbsteuber, actually it's not only java interop - any type names should be CamelCased
10:29babilen... as should names of protocols (i.a.)
10:34twhumeSo… I'm trying to load Java classes from an array of bytes (being a serialised class) in Clojure. I also need to be able to unload classes, which I think means getting the class loader which loads them garbage-collected. There may be an easier way of doing this than the one I'm trying, which is to gen-class a subclass of ClassLoader and use that. I'm having trouble with gen-class though: I can generate a class OK but it always seems to
10:34twhumesubclass Object, and not respond to dot-notation method calls.
10:34twhumehttps://gist.github.com/2843627 has the code - (-dummy cg) works just fine, (.dummy cg) doesn't...
10:35twhumeAny ideas?
10:41llasramtwhume: Clojure >=1.3 includes a class-loader which may already do what you need. It's used by deftype but gen-class wasn't switched over. https://github.com/clojure/clojure/blob/eccde24c7fb63679f00c64b3c70c03956f0ce2c3/src/jvm/clojure/lang/DynamicClassLoader.java
10:42llasramIt's wired in to how Clojure loads classes, with some helpers available on clojure.lang.RT
10:43llasramHere's as example I wrote, extending gen-class to use DynamicClassLoader: https://github.com/llasram/shady/blob/master/src/shady/gen_class.clj
10:43gfrederickswhat's the latest strategy for cljs testing?
10:44twhumeThanks. I'm quite a Clojure noob, mind if I have a look at that and probably get back to you with more questions?
10:44llasramnp
10:47wastrelhi
10:50TimMcdnolen: Ever seen anything like this with core.match? https://www.refheap.com/paste/2937
10:51TimMcdnolen: Basically, a match clause is intermittently returning nil, even though it is guaranteed a match.
10:55SurlyFrogHi all, I'm coming to Clojure without any significant Java experience (a decade or so C, Common Lisp, Python, and a few others). I'm wondering if the JVM handles "swapping" or caching large data structures to disk. For example, if you are growing a large data structure in memory, and it gets too large, will the JVM automagically cache portions of it to disk, or will you get out-of-memory exceptions?
10:56clgvSurlyFrog: no. If you hit the -Xmx limit the JVM will die with an exception
10:56SurlyFrogclgv: okay, thanks...
10:57SurlyFrogclgv: is -Xmx a command line option to the JVM?
10:57clgvyes
10:57SurlyFrogthanks
10:58cemerickwell, the thread of execution that hits the allocation limit will throw that exception…which can be caught and recovered from. OutOfMemoryErrors don't actually terminate the JVM process.
10:58clgvhm right. never tried to catch one yet ;)
10:59SurlyFrogcemerick: okay.
11:00cemerick,(try (byte-array Integer/MAX_VALUE) (catch OutOfMemoryError e "you're safe!"))
11:00clojurebotcemerick: Huh?
11:00cemerickwha?
11:00cemerick&(try (byte-array Integer/MAX_VALUE) (catch OutOfMemoryError e "you're safe!"))
11:00lazybotjava.lang.SecurityException: You tripped the alarm! catch is bad!
11:00cemerickoh hell
11:00cemerickanyway, it works outside of a sandboxed environment
11:00twhumellasram: OK, thanks for your help. I now have a class being loaded OK; any idea how I would force it to be unloaded (so that I can load a new class in under the same name)?
11:05llasramtwhume: My understanding is that you don't explicitly "unload" the class. You load it again w/ a different class loader, which gets a new Class instance representing the new class version
11:05llasramThese classes are never resolved through normal JVM class resolution, but instead always go through Clojure namespace lookup mechanisms
11:06twhumeOK, but the class loader in this case is a locally scoped variable inside the load-class function. If I were to pass a new instance of the class loader into that method each time, do you think that would do it?
11:06twhume(I'm guessing that the class loader won't be GCed until classes it's loaded are...)
11:15clgvtwhume: a class has a reference to it's classloader
11:16twhumeclgv: yup. So the loaded and the class have to go. I can sometimes force them out by doing ns-unmap followed by a GC, but it doesn't seem reliable. I think I'll do something else to work around this… it's quite important for my application.
11:17clgvtwhume: what is your big picture?
11:17twhumeAs in, what's the app?
11:17clgvso to say
11:18twhumeA bit wacky; I'm writing a "superoptimiser" for Java byte code - essentially, doing an exhaustive search for optimal programs across all possibilities. So I'm generating many classes, loading them, testing each one, testing if it works, and (usually) discarding it.
11:19gfrederi`is there a CLJS equivalent to (extend-type Object ...)?
11:19gfrederi`(i.e., something that covers all the JS types)
11:20clgvtwhume: oha, ok.
11:22matthavenertwhume: have you seen the minikanren presentation on bliptv ?
11:22dnolengfredericks: extend-type default
11:23twhumematthavener: nope
11:23matthavenerthose minikanren guys write a program that generates arbitrary programs that result in the number 6
11:23matthavenermight be interesting to you
11:23twhumeThis one? http://blip.tv/clojure/dan-friedman-and-william-byrd-minikanren-5936333
11:23matthaveneryes, near the end
11:24twhumeThanks very much - I'll give it a look. There have been superoptimisers for specific hardware (SPARC, RS6000, 68000), but none for the JVM...
11:26gfredericksdnolen: cool thx
11:28TimMcdnolen: Did you see the core.match weirdness I posted?
11:28TimMcI can't get a minimal test case since it's nondeterministic...
11:28dnolenTimMc: no, there's a lot of core.match weirdness, matching what kind of type?
11:29TimMckeywords
11:30dnolenTimMc: link or gist?
11:30TimMcdnolen: https://www.refheap.com/paste/2937 but it doesn't fail reliably (or in isolation?)
11:31dnolenTimMc: what is the weirdness the error?
11:32Chiron_hi! what is wrong with this http://pastie.org/4002330
11:32Chiron_CompilerException java.lang.RuntimeException: Unable to resolve symbol: server in this context
11:33dnolenTimMc: hmm, yeah not sure what's going on and don't have the bandwidth to pursue. Feel free to open a ticket with more details - patch even better of course.
11:35clgvChiron_: the content of your doseq: (1) the ~ (2) there is one pair of parenthesis which is too much
11:35jcromartiehooray for -webkit-overflow-scrolling: touch;
11:37TimMcdnolen: OK, we'll probably just drop it for now. Macro-expansion of the match clause looks fine -- I can't see how it would fail. If we get anything reproducible I'll open a ticket.
11:37ezyangHello folks. I was wondering if there were any implementations of STM-ized mutable data structures.
11:38ezyangOr if this is even a good idea at all.
11:38dnolenTimMc: thanks much! Yeah I do not recommmend relying on core.match until it hits beta status.
11:38dnolenezyang: probably not a good idea I'd think.
11:39ezyangdnolen: How many references would the structure have to use before it became a bad idea?
11:42ezyangCertainly, it wouldn't be "more than one", since the whole point about STM is to deal with multiple references properly.
11:43S11001001ezyang: when it comes to collections, there are only three numbers: 0, 1, and many.
11:43dnolenezyang: do you just mean allowing mutable data structures to participate in STM? isn't that what a most STM research has been trying to do all along? (is not an STM expert)
11:43S11001001yes, and it's slow as hell
11:44S11001001ezyang: so the correct answer is it's fine, as long as your data structure has either 0 or 1 element(s)
11:45S11001001do more stuff immutably; STM gets a lot less interesting then
11:47ezyangS11001001: OK. The difference is something like 'one STM var per index on data store' to 'one STM var per element stored'
11:47ezyangI wonder if there is a middle ground.
12:04goodieboyI'm using an agent w/send-off for async http requests. Under what circumstances will my agent "fail", and how to do I completely avoid failure from happening? Use a top-level try/catch in my agent function?
12:06nDuffgoodieboy: an unhandled exception, and yes... though "completely" is a little strong; there _are_ uncatchable exceptions in the JVM.
12:06nDuffgoodieboy: ...the proper Right Thing is to check for failure when you're going to interact with the agent, and deal with it then.
12:07goodieboynDuff: ahh, right before I attempt to call send-off?
12:09nDuffThat's what I generally do. That said, there _is_ a race condition there, so it's probably not the best pattern.
12:12nDuffgoodieboy: ...catching the exception from trying to do a send to a failed agent, and handling it there, would be the safer thing.
12:13nDuffgoodieboy: ...that said, if you aren't checking the value the agent holds anyhow, there's a decent chance that you're doing something for which a different concurrency mechanism would be more appropriate.
12:13nDuffs/doing something/doing is something/
12:18goodieboynDuff: yes, you're right. I don't care about the value of the agent. Should I be doing something else?
12:21nDuffgoodieboy: ...to quote Joy of Clojure: "In cases where you just need a bunch of worker threads banging away on some work, or you have a specific long-running thread polling or blocking on events, or any other situation where it doesn't seem useful that the Agent maintain a value [...] there's every reasot to consider using a Java Thread directly, or a Java executor"
12:22nDuffgoodieboy: (if you have your own copy -- this discussion is in 11.3.5, pages 254-255)
12:23goodieboynDuff: ahh ok, thanks
12:23nDuff...except the book doesn't contain that typo :)
12:23nDuffs/reasot/reason/
12:25S11001001is the pool used for sends accessible?
12:26duck1123if you're using the new version of lamina, it has some nice helper functions for managing tasks on thread pools
12:26nDuffS11001001: the executors are public static on clojure.lang.Agent, so it's _possible_ to access them
12:26nDuffS11001001: whether it's _wise_...
12:29technoma`planning on cutting a lein release today
12:29technoma`anything else that should be considered for it?
12:30technoma`this one is going out mostly in order to fix a bug in the repl and add support for encrypted credentials
12:31clgvlein2 or lein1.7.x?
12:31technoma`2.0.0-preview5
13:02pbuckleyAnyone know how I can use C-x-e (emacs slime) in a function that relies on args or values from destructuring without having to temporarily def those args/bindings?
13:03pbuckleylike how do I test the inner fn "some-fn" in (defn build? [some-arg] (some-fn some-arg)) without having to temporarily do (def some-arg "foo")?
13:04pbuckleyby "test" I mean C-x-e
13:17lpetithello
13:19tmciverpbuckley: I don't believe you can. C-x C-e just 'evaluates' code, it does not call the fn.
13:19locojayhi anything similar to python os.path.join (to make sure between unix and win paths...)
13:19tmciverpbuckley: To test your inner fn you'd just have to rely on test for the outer fn, or break out the inner fn.
13:19joegallopbuckley: you could C-c C-e instead, and then type (build? "whatever-arg-you-want")
13:20joegalloor (some-fn whatever-arg), for that matter
13:20raeklocojay: yes. (clojure.java.io/file "foo" "bar" "baz")
13:20locojaythnks
13:20raekthat produces a File object (which represents a path)
13:20lpetitShameless plug: Counterclockwise (the Clojure Eclipse Plugin) now has decent leiningen 2 support in its (quite stable) beta version. With the ability to create new projects via a wizard wrapping lein new new (so you also get templates for free)
13:24lpetitFor those interested, more info here: https://groups.google.com/d/topic/clojuredev-users/UhfnjBvIips/discussion
13:25Bronsacool lpetit
13:30gfrederi`why would naive-recursive-fib be 20 times slower in clojure than java?
13:31amalloygfrederi`: best explanation: you're doing something wrong? i certainly can't guess without seeing any code
13:31gfrederi`amalloy: okay I'll pull it together
13:31amalloyeg, boxing is going to cost you a little, but not 20x
13:31pbuckleytmciver, joegallo, thanks, looks like I just have to break out the inner fn
13:33gfrederi`amalloy: refheap.com/paste/2944
13:34gfrederi`amalloy: I guess the clojure could be changed to case?
13:35amalloycemerick: OOM errors can trash your JVM pretty badly though, unless every thread knows how to deal with them at any time (pretty unlikely). thread 1 allocates almost-all the memory, then thread 2 gets an OOM and dies, then thread 1 gets an OOM, recovers, and throws out its excess crap
13:36cemerickamalloy: fair point
13:38technoma`is it or is it not idiotic that exceeding your thread limit throws an out of memory exception?
13:38amalloytechnoma`: the JVM just can't remember all the dang threads you want
13:39amalloygfrederi`: and that's 20x faster in java? even on clojure 1.2 i wouldn't expect that big a difference
13:40amalloyyou could try hinting with ^int, on x and on the parameter vector (to hint the return type)
13:41gfrederi`amalloy: I'll verify the runtimes in just a sec
13:42gfrederi`amalloy: running (time (fib 40)) in clojure prints ~7 seconds
13:42amalloyoh cool, case actually has code in it to special-case "all the test clauses are for ints, don't bother hashing anything"
13:43gfrederi``time java ...` runs in 0.75 sec INCLUDING jvm startup time
13:43gfrederi`amalloy: switching to case cuts it down to ~6.5 sec
13:43jcromartiegfrederi`: are you counting the Clojure startup time?
13:43gfrederi`jcromartie: nope, running the time macro from a repl
13:44jcromartieah ok
13:44amalloy&(-> (map first (iterate (fn [[a b]] [b (+ a b)]) [0 1])) (nth 40)) ;; just checking the number
13:44lazybot⇒ 102334155
13:44kmicu&(time (-> (map first (iterate (fn [[a b]] [b (+ a b)]) [0 1])) (nth 40)))
13:44lazybotjava.lang.ClassNotFoundException: clojure.core
13:45gfrederi`kmicu: obviously that will be much faster
13:45RaynesMan, I sure wish I knew what caused that.
13:45Raynes$login
13:46lazybotYou've been logged in.
13:46Raynes$reload
13:46lazybotReloaded successfully.
13:46Raynes$`foo
13:46Raynes&`foo
13:46lazybotjava.lang.ClassNotFoundException: clojure.core
13:46amalloygfrederi`: adding ^long hints speeds it up 10x
13:48bordatouehello
13:48bordatoueis it safe to use double as a key in hashmap
13:49S11001001bordatoue: what's safe?
13:49kmicuin cljs repl it takes 3ms in my clj repl 8 ms :)
13:49S11001001&({1.0 42} 1)
13:49lazybot⇒ nil
13:51gfrederi`amalloy: oh we tried with Long; yeah primitives are much better
13:52Bronsayes
13:52gfrederi`&(let [x 1.7e90] ({x 12} x))
13:52lazybot⇒ 12
13:52bordatoueS11001001: safe in the sense, will there be key misses
13:52bordatouewhen computing hash
13:52gfrederi`bordatoue: only if your doubles aren't quite equal
13:52gfrederi`bordatoue: can you use ratios instead of doubles?
13:54bordatouei can try
13:55gfrederi`ratios are much less scary
13:55bordatouebut is it recommended to use double as key in hashmap, what is the function used to create hashcode
13:55gfrederi`amalloy: with case and primitive typehints it is only 3 times slower
13:56gfrederi`maybe for var lookup?
13:58technoma`bordatoue: if you're performing lookup on a map from Clojure functions the numbers will hash correctly. if you're using Java methods to get at them then the required broken Java semantics will apply.
13:58bordatouetechnoma`: thanks,
13:58bordatouetechnoma`: Could you please tell me how java would result in incorrect result when using double
13:59bordatouetechnoma`: Basically i just want to know how different it will be
13:59technoma`I don't really know the details; I just know Java requires you to confirm to incorrect semantics if you claim to support certain interfaces.
13:59bordatouetechnoma`: You could point me to some resource I can read , it would be great
13:59technoma`I think you can have both (Long. 1) and (Integer. 1) as separate keys or something?
14:00technoma`no idea how doubles play into that
14:00gfrederi`oddly type-hinting the parameter vector slowed it down significantly
14:00gfrederi`and eleminating the var lookup doesn't help either
14:01amalloytechnomancy: that got fixed in 1.4 though
14:01amalloymaps now use equiv instead of equals for key uniqueness
14:01technoma`amalloy: I thought the clojure functions were fixed in 1.3 but the java methods were still broken due to the requirements of the java interfaces?
14:02amalloythe clojure functions certainly weren't fixed in 1.3 - that was when the breakage became obvious, because longs became the default box
14:03amalloywhether the java methods are broken, i don't know about
14:03technoma`oh, I'm talking about Integer/Long equivalence; primitives are another can of worms
14:04bordatoueCan anyone suggest a method to check if using double is safe as key in java hashmap
14:04amalloyas am i
14:05amalloyi think
14:05amalloybordatoue: step 1 has got to be "decide what you mean by that question"
14:06amalloy,*clojure-version*
14:06clojurebot{:interim true, :major 1, :minor 4, :incremental 0, :qualifier "master"}
14:06amalloy&*clojure-version*
14:06lazybot⇒ {:major 1, :minor 4, :incremental 0, :qualifier nil}
14:06amalloyi hate you both
14:06hiredmanyou want 1.5?
14:06bordatoueamalloy: when i say safe, it means something would work consistently
14:07amalloyhiredman: 1.3
14:07hiredmanpffft
14:07hiredman1.3 is bad and no one should use it
14:07amalloyi agree!
14:07amalloytechnomancy claimed something worked in 1.3, and i was hoping to prove him wrong
14:10S11001001bordatoue: it isn't nondeterministic, you will definitely either get a key match or a key mismatch for any two values
14:11bordatoueS11001001: could there be a key miss
14:12S11001001bordatoue: well you'd want key misses, wouldn't you, otherwise what's the point of a map?
14:13S11001001ok, I'll put it this way
14:13bordatoueS11001001: due to floating point precision can there be key misses
14:14S11001001you can't deal with precision and have =
14:14S11001001let me formalize
14:14S11001001forall a b c in values where c is not nil. (= a b) implies ({a c} b) => c and (not= a b) implies ({a c} b) => nil.
14:17bordatoueS11001001: thanks
14:17bordatoueI will do some research on it
14:39locojayanyone using congomongo . when doing an update! call i keep on getting <#WriteResult N/A> on stdout. anyway i can prevent the output
14:43amalloylocojay: stop calling println on the result of the update? there's really no other reason it would print
14:44gtrak`hmm, is swank supposed to be able to M-. to a protocol def?
14:45technoma`I don't think so
14:58technoma`emezeske: this is weird; someone is claiming authorship of lein-cljsbuild in the comments: http://technomancy.us/158
14:58technoma`is that a spam-bot copying your content from another source?
14:59emezesketechnoma`: that it is. I did write that comment, months ago, on some other blog
14:59emezeskecrazy!
15:00technoma`did you misspell "plugin" in your comment as well? =)
15:00technoma`weird that there's no URL associated with the post
15:00emezeskeI hope I didn't :(
15:00TimMcNope.
15:01kilonthat make no sense, what would be the benefit for a spam bot ?
15:01TimMcIt is probably doing that as a probe. Some spambots will use unique strings so they can do a web search later to find out if their comment was approved.
15:01locojayamalloy: i don't have any print at all https://gist.github.com/2845411 line 5 does the output
15:01technoma`kilon: possibly testing the anti-spam defenses?
15:01amalloyemezeske: no hits for "leiningen plguin" anywhere on the web
15:01technoma`yeah
15:01technoma`emezeske is cleared =)
15:01kilonah i see
15:01TimMcThe original: http://ubercode.de/blog/settling-down-with-clojurescript
15:01TimMcThe bot stripped out all tags, too.
15:01technoma`damn; better wipe that comment before the bot finds it
15:02amalloylocojay: (update! ...) returns a WriteResult, so if you're just printing the result of that (say, in the repl)...
15:02technoma`clever bugger; the content *almost* makes sense
15:02locojayruning via lein run and main
15:02kiloncompanies with too much free time in their hands
15:02kilonno wonder why global economy goes to hell
15:02technoma`in fact if it had been on my most recent post and I didn't already know emezeske then I wouldn't have suspected a thing
15:03raekI vagely recall that "lein run" prints the result of the -main function for some reason
15:03emezesketechnoma`: That is a clever way to keep your comment from being deleted
15:03technoma`hm; that explains the nonsense alphanumerics in the URL field too
15:03technoma`it's a token for checking up on later
15:03TimMcindeed
15:03TimMctechnoma`: Alter the token, cause havoc?
15:04technoma`TimMc: mwahaha
15:04technoma`I've heard of people writing tarpits that have slowly-increasing latencies to gum up the bots
15:04solussd_I'm getting a compiler error "can't recur here" from clojurescript- I've narrowed it down to this: https://www.refheap.com/paste/4fc7bf16e4b09302d009a309 could anyone tell me why I can't recursively call that function?
15:05hiredmanthere is no recur in that function
15:06hiredmansolussd_: what makes you think it is that function?
15:06hiredman(my guess it is your code calling that function)
15:06solussd_hiredman: b/c taking it out makes the compiler error go away. :)
15:06solussd_in fact, removing the (map?) condition stops the error
15:06emezeskesolussd_: are you up to date with your compiler version?
15:07hiredmandoseq may be broken in clojure script
15:07emezeskesolussd_: I know I've encountered that before, but I can't remember where :(
15:07emezeskedoseq works just fine
15:08emezeskeOh, I think maybe cond is not supported in older clojurescript versions (?)
15:08solussd_emezeske: it compiles w/o the map? condition though
15:08dnolenemezeske: cond has been there since the beginning far as I know.
15:08solussd_it's definitely the recursive call that is making it blow up
15:08emezeskednolen: Okay, color me crazy then
15:08solussd_i'm using the version of clojurescript pulled in by noir-cljs: [org.clojure/clojurescript "0.0-1236"]
15:09amalloyemezeske: early versions didn't have case
15:09emezeskeamalloy: Thank you for preserving my sanity, "case" is definitely what I was thinking of
15:09dnolensolussd_: create a minimal reproducible case, open a ticket
15:10solussd_dnolen: k.
15:19piranhahi, if I have a question regarding clojurescript one and lein, should I ask it here, go to #clojurescript or to #leiningen? :)
15:20kilonyou can ask it here too
15:21piranhasure. I'm trying to get cljs one up and running, but then (probably because I have lein2) none of the examples work
15:21piranhafor example, they say run "lein repl" and then "(go)"
15:22piranhafunction go is not defined in my repl
15:22piranhadev-server is not defined as well
15:22piranhaand I'm a bit lost already what to do :\
15:23technoma`have you tried lein-cljsbuild?
15:23piranhahm, nope
15:23dnolenpiranha: CLJS one has seen much activity lately, it's pretty out of date as far CLJS far as I know.
15:23amalloyseancorfield: i'm digging through congomongo to remove the remaining reflection warnings. there are a number of cases like (.method ^GridFS f arg), where arg can be one of several types
15:23dnolenhas not seen
15:23amalloyi have a macro in useful, multi-hinted-let, that can easily expand to something like (condp instance? arg File (.method ^GridFS f ^File arg), InputStream (.method ^GridFS f ^InputStream arg) ...). would you prefer that i (a) add a dependency on useful in project.clj, (b) copy/paste the macro into congomongo, or (c) just do it by hand every time?
15:24dnolenpiranha: best to start with lein-cljsbuild at this point
15:24technoma`piranha: yeah, lein-cljsbuild seems a lot more usable
15:24piranhadnolen: ah, so it's better to skip it and just do...
15:24piranhaok, I see, thanks :)
15:33antares_seancorfield, amalloy: Monger uses helper protocols to coerce things like arg in this example (where possible)
15:34antares_other clojurewerkz.org projects do the same, it works pretty well (although there are cases where something like multi-hinted-let would still be necessary)
15:35amalloyantares_: so does congomongo in other cases, but for example GridFS/createFile accepts either a byte[] or a File or an InputStream, and there's no zero-overhead way to coerce those into a single thing
15:36antares_amalloy: yeah, I am not saying helper protocols are zero overhead. But it is OK for most needs (less overhead than reflective calls). Here's what monger uses, FYI: https://github.com/michaelklishin/monger/blob/master/src/monger/gridfs.clj
15:39amalloyantares_: the other thing i'm doing is removing all the unnecessary typehints from congomongo - looks like monger could use some of the same treatment :)
15:39antares_amalloy: yeah. Monger was my 2nd clojure library, it has a lot of things I'd like to clean up. Pull requests are welcome :)
15:46clojure-newcomerhi guys, I'm trying to do multi method dispatch on a key… I found a working example that dispatches on the value of a key ':name', but my data has arbitrary keys… http://pastebin.com/wpjaBKWU
15:46clojure-newcomerI've made a failed attempt below the working example
15:49dnolenclojure-newcomer: make key return the relevant value for a particular map.
15:50dnolenclojure-newcomer: if you're looking for the general case, not possible with multimethods - would require predicate dispatch.
15:50clojure-newcomerdnolen: I think you are saying I need to change my data structure because its not possible to do what I am trying to do ?
15:51dnolenclojure-newcomer: changing your data structure won't help you.
15:51dnolenclojure-newcomer: it sounds like you want different methods to run if a key is present
15:52clojure-newcomerdnolen: yes I think so, so a certain function called if a key ':id' is found, different function for ':blurb' etc etc
15:52dnolenclojure-newcomer: not possible with multimethods
15:52clojure-newcomerdnolen: nuts, thanks for saving me time anyhow :-)
15:53clojure-newcomerdnolen: I think I can flip it on its head and work with the value anyhow, thx for the help
15:53ezyangCan someone help me out: I can't find where Clojure's jvm code keeps track of nested transactions.
15:54ezyangrunInTransaction seems to always attempt to commit the transaction at the end.
15:54ezyangWhat am I missing?
15:55TimMcAre you sure they nest?
15:55TimMcMaybe dosync always joins any open transaction.
15:55ezyangthere are claims on the Internet that they do. But I might be wrong :-)
15:55hiredmanthey nest
15:56hiredmanezyang: have a look at clojure.core/sync
15:57ezyangThat just calls LockingTransaction.runInTransaction
15:57ezyangI'm staring at that code right now.
15:57hiredmanright, which looks for a locking transaction where?
15:58ezyangSo, it checks if there is a current transaction. But then regardless of whether or not there was a running transaction, it invokes t.run(fn)
15:58ezyangI think that's wrong. I also think that this will have the wrong semantics if a retry is necessary.
15:59hiredmanwhy do you think it is wrong?
15:59hiredmana transaction joins the current transaction if there is one already running
16:00ezyangYes, that is correct.
16:00ezyangThe problem is what happens when the inner transaction finishes.
16:00hiredmanwhat about it?
16:00ezyangIf you straightline the code, you get something like:
16:01ezyangtransaction.set(t = new LockingTransaction()); ... /* no set */; fn.call; t.run(fn2); .... t.run(fn1)
16:02hiredmanthat is not correct
16:02ezyangUnless I'm super misunderstanding what t.run does, I think it finalizes the transaction
16:02ezyangI think that's what the code is doing.
16:02hiredmando you have code that demos the problem?
16:02ezyangNo. It'd probably be a very fiddly race to cause too.
16:03ezyangoh, actually, no, this should be pretty simple.
16:03ezyangjust a sec.
16:03hiredmanyou cannot "straighline" the code, it is nested
16:03ezyanghiredman: What I mean by "straightline" is saying what a hypothetical execution would step through.
16:04hiredmanthat is incorrect in that sense too
16:04ezyangOK, help me understand why this doesn't happen.
16:04hiredmanfn1 would start executing before fn2 and finish executing after fn2 finishes
16:04hiredman(where fn2 is a nested transaction)
16:04ezyangNo, that's not right.
16:04hiredmanit is right
16:05ezyangfn.call is responsible for calling the function.
16:05hiredmanfn2 code is run from inside fn1
16:05ezyangYes, I inlined that in my example.
16:06hiredman(sync nil (X (sync nil Y))) turns in to (.../runTransaction (fn [] (X (../runTransaction (fn [] Y)))))
16:06ezyangYes.
16:07hiredmanso the outermost fn is fn1, and the inner most is fn2
16:07ezyangSo when you enter the inner runTransaction, you run fun2's code, and then run t.run(fun2)
16:07hiredmanright
16:07hiredmanwhich happens while fn1 is running
16:07ezyangI think running t.run(fun2) finishes up the transaction.
16:07ezyangand then when fn1 finishes running, it runs t.run(fun1)
16:08devijversgreetings, can anybody tell me how attribute selectors work in enlive?
16:08hiredmanezyang: no
16:08hiredmanthey are nested, t.run(fn2) cannot happen unless t.run(fn1) is running
16:09ezyangOK, let me state my assumptions.
16:09ezyang1) fn.call() in runInTransaction is responsible for running the code inside fn
16:10ezyang2) If fn contains a runInTransaction, when fn is finished running, all of the lines in runInTransaction will have run.
16:11ezyang3) In our example, we first runInTransaction on fn1. fn.call() causes fn1 to be executed, and doesn't return until fn1 is done executing.
16:12hiredmanit depends for some cases the fn.call line is never reached
16:12hiredmanin the facse of the outmost transaction the fn is run inside the call to t.run(fn) not fn.call()
16:12hiredmanbecause info will be null
16:12ezyangOK, that is true.
16:13ezyang3') In our example, we first runInTransaction on fn1. t.run(fn1) causes fn1 to be executed, and that f.call() doesn't return until fn1 is done executing.
16:13ezyangcombining (3') and (2), because fn1 contains a runInTransaction, when /that/ f.call() line returns, all the lines in runInTransaction on fn2 have finished executing.
16:14hiredmancorrect
16:14ezyangOK.
16:14hiredmanso what happens for fn2 is it goes right to t.run(fn2)
16:14ezyang4) A line of that runInTransaction is t.run(fn2)
16:14ezyangaha! return is short circuiting.
16:14ezyangOk, we're good.
16:14hiredman*eyeroll*
16:15ezyangSorry, this is why I came and asked :-)
16:18devijvershey, can anybody help me with attribute selectors in enlive?
16:18amalloy~anyone
16:18clojurebotJust a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."
16:19devijversI want to write this selector: select[name=somename]
16:20ystaelWhat is the most idiomatic way to filter a seq by a predicate which may have side effects so is required to be evaluated exactly once for each seq element? (I don't care _when_ the predicate is evaluated, only that it is at most once each)
16:20ystaels/at most/exactly/
16:21bobryemezeske: is it possible to pass --define to closure compiler?
16:21emezeskebobry: Nope.
16:21bobryouch <_<
16:21bobrywhy?
16:21clojurebotbobry: because you can't handle the truth!
16:22bobryturns out the only way to override 'goog.LOCALE' is pass --define goog.LOCALE=...
16:22emezeskebobry: Well, for one, it's not called from the command line, so passing command line arguments doesn't really make sense
16:22TimMcSure it does.
16:23emezeskebobry: And nobody's created a nice way to set all of the google closure options in the clojurescript compiler
16:23mstumpI'm getting an exception which doesn't make sense. I'm passing a string to a Java constructor, and I keep getting "java.lang.ClassCastException: java.lang.String cannot be cast to [Ljava.lang.Comparable" which doesn't make sense because String implements Comparable. Any ideas?
16:23TimMcmstump: Look at the [L
16:23kmicubobry: you have fix for that http://dev.clojure.org/jira/browse/CLJS-77
16:23TimMcThat means you have an array of something.
16:23emezeskebobry: I'd love to have all of the google closure options exposed, they're just not. There's about a billion of them.
16:23hiredmanmstump: you are not calling the constructor you think are calling
16:23TimMcmstump: I'll hazard a guess that you're running into varargs.
16:24mstumpThat constructor does take a vargs Comparable
16:24mstumpwhat should I be doing?
16:24bobryI see.. and thanks kmicu ;)
16:24TimMcPassing in an array.
16:24TimMcVarargs is a lie.
16:25TimMc&(class (into-array ["foo"])) might do it
16:25lazybot⇒ [Ljava.lang.String;
16:26devijvershow do I write this selector in enlive? select[name=somename]?
16:27locojayif i do map #(some funciton) on a lazy seq nothing happens do i have to use a doall ?
16:28emezeskebobry: This is where the google closure options get set. Very basic at the moment. 'Twould be awesome for this to be configurable, maybe via a callback that sets the options: https://github.com/clojure/clojurescript/blob/master/src/clj/cljs/closure.clj#L76
16:28devijverslocojay: yes
16:29devijverslocojay: if you use map as a replacement of a loop you're better off with for
16:30dnolenemezeske: bobry: patches welcome
16:30mstumpThat was it. Thank you! That was a horrible fcking exception. I want my morning back. Someone should be violently penetrated with a cactus.
16:31locojaydevijvers : thanks. i was planning to use pmap and and upload function to my db to upload in parrallel so i m not sure if for is better
16:32bobrydnolen: great! btw, is there a reason, cljs doesn't accept pull requests?
16:32dnolenbobry: because that's not approved Clojure process.
16:33emezeskednolen: I wish I had more time to allocate to the cljs compiler... Maybe someday soon. :)
16:33bobryoh, where can I read more about the process?
16:33dnolenbobry: on the Confluence pages.
16:33bobryemezeske: I like the callback idea, can you submit a patch? :)
16:34emezeskebobry: Unfortunately, my time to interest ratio in that particular feature is rather low :(
16:34kmicudnolen: i can write a patch, but my idiomatic clojure sucks for now :] and jonase/kibit it's not so good to fix that :P and seriously what is wrong with this http://dev.clojure.org/jira/browse/CLJS-77
16:34bobryexcept for patch formatting :)
16:36devijverslocojay: can't think of a better solution than pmap
16:36devijvershow do I write this selector in enlive? select[name=somename]?
16:37bobrykmicu: I think this needs a more generic solution, the patch in CLJS-77 only covers --define
16:37locojaydevijvers: not at the moment as i m a total novice
16:37dnolenbobry: kmicu: patch looks ok and applies - just confirmation from someone that it works for them.
16:39dnolenbobry: would welcome a more generic patch.
16:41bobrydnolen: sure, should I create a separate issue?
16:44dnolenbobry: feel free, have you sent in your CA?
16:44TimMcdevijvers: Doesn't the Enlive wiki have an example of that?
16:46devijversTimMc: thx!! found it on the wiki: these selectors requre double brackets, now it works
16:47bobrydnolen: nope, not yet, can you merge the patch from CLJS-77, while the CA flies all the way from Russia? :)
16:48dnolenbobry: if you can confirm that it actually works
16:48bobryokay, let me check then
16:53devthanyone know if clojure.contrib.cond ever got a replacement? looking for a cond-let
16:58devthif there's not a replacement for an old contrib, what's the correct way of making one?
17:00kmicudevth: http://dev.clojure.org/display/design/Moving+Projects+Into+Contrib
17:01devthkmicu: thanks, but doesn't that only apply to 1.2 and below?
17:02devthalso, i'm not the original author. i just want an old contrib to use in my project.
17:03S11001001(<<- (if-let [x whatever] x) (if-let [y whatever] y) otherwise)
17:03S11001001trivial expansion target, combined with flipped ->>
17:06coventry`What's the status of clojure in clojure? Is there a public repository for it?
17:06dnolencoventry`: ClojureScript is effectively C-in-C
17:07technomancycoventry`: there hasn't been much movement on replacing the Java in Clojure with Clojure
17:08coventry`I read that the project was blocking on an inefficiency in Clojure's object creation (http://blog.n01se.net/blog-n01se-net-p-41.html) Is that still the case?
17:09dnolencoventry`: that is very old, the mechanisms for building on host types are already in place.
17:11coventry`Thanks. So the recent work on speeding up operations on native ClojureScript object operations (the benchmark graphs which were posted here recently), is that at the clojure-in-clojure level, or is that hand-tuned js?
17:12dnolenconventry`: barring some 7 lines of interop, nothing in ClojureScript written in JS.
17:13dnolenconventry`: the compiler is tuned to emit optimal JS
17:13hiredmandnolen: once the clojure datastructures are replaced with onces written in clojure ported from clojurescript implementations then I will buy that
17:13coventry`Thanks for the info.
17:13clojurebotWe live to serve.
17:14coventry`You too, clojurebot. :-)
17:14dnolenhiredman: if you want to wait for that, *shrug*
17:15hiredmandnolen: until then clojurescript is just "clojurescript in clojure"
17:15hiredmanclojurescript isn't selfhosting
17:15hiredmanneither is clojure
17:18dnolenhiredman: more *shrug* :)
17:20technomancyI'll believe it when I see (ns clojure.var)
17:20hiredmandnolen: so why keep saying "clojurescript is effectively clojure-in-clojure"?
17:20hiredmanclojurescript is not clojure so it cannot be substituted as either instance of clojure in that expression
17:21SurlyFrogCan someone double check me. If a function is reading an atom, and during the course of the function, it is swapped out by another thread that changes the atom, the first function does not re-read the atom. Correct?
17:21hiredmanand even if it could, you can't do it for both because clojurescript is written in clojure
17:21dnolenhiredman: because most of the language constructs are written in itself? is Clojure all the lame limitations imposed by the JVM? I think not.
17:21brehautSurlyFrog: yes
17:21hiredmantechnomancy: (ns clojure.lang) (deftype Var [...])
17:22SurlyFrogbrehaut: thanks :-)
17:22S11001001SurlyFrog: read via deref, right
17:22dnolenhiredman: and of course vice versa (limitations) for CLJS
17:22technomancyhiredman: yeah yeah--backwards compatibility; who needs it =)
17:22hiredmandnolen: clojure is specificly targeted at the jvm, clojurescript is specificly target at js
17:22hiredmanthey are not the same thing
17:23hiredmanhttp://clojure.org/jvm_hosted
17:23dnolenhiredman: is Clojure a language or an implementation?
17:23hiredman*sigh*
17:24dnolenhiredman: do any of the things in Compiler.java that's not portable make any difference to the language?
17:24hiredmando you really want be to start quoting rhickey on the subject to you?
17:24hiredmanhe went through this entire thing with clojure on the clr
17:24dnolenhiredman: uh, what quote?
17:25hiredmandnolen: lemme grep then
17:25pipelineclojure on the clr could be a cool thing but it wouldn't be clojure anymore
17:25dnolenpipeline: ClojureCLR exists
17:26clojure-newcomerhey guys… I'm using clj-time to try to get a DB field like '1065691975' converted into a decent format… trouble is I am getting 'No instant converter found for type: java.lang.Integer'
17:26clojure-newcomercan I convert this Integer to a Long in clojure ?
17:27clojure-newcomerI had thought to use 'from-long'
17:27brehaut,(class (long (Integer. 1)))
17:27clojurebotjava.lang.Long
17:27miceikenFirst time with clojure here, how can I comment a larger segment of code
17:27brehautbut i dont think thast actually answering the question
17:27miceikeninstead of ;; each line
17:28clojure-newcomerbrehaut: thanks!
17:28TimMcmiceiken: There's no true multiline comment.
17:28TimMcmiceiken: However, #_ will make the reader ignore the next (valid!) form, and (comment ...) is a macro that will replace multiple valid forms with nil.
17:28@rhickeyhttp://vote.jax-awards.com/
17:29TimMclol @ Jenkins
17:30kmicuwhere is thinkrelevance? :)
17:31TimMcThis Restructure thing is such a Java-ish thing.
17:31sjlIs it possible to use swank-clojure (the lein plugin thing) with Clojure 1.4? Even if I require clojure 1.4 in my project's project.clj 'lein swank' always seems to produce a 1.3 repl
17:31S11001001,(+ #_#_3 7 11)
17:31clojurebot11
17:32vijaykiransjl: which version of lein are you using ?
17:32sjlvijaykiran: 2.0.0-preview4
17:33kmicuhiredman: :dnolen 10:43-12.xx http://blip.tv/clojure/rich-hickey-unveils-clojurescript-5399498, so David was right
17:33vijaykiransjl: lein repl is also giving 1.3 ?
17:33sjlvijaykiran: yeah
17:34vijaykiransjl: I just created a sample project with 1.4/lein2-prev-3
17:35vijaykiransjl: seems to work fine *clojure-version* is 1.4
17:35hiredmankmicu: uh, "the compiler itself is written in clojure"
17:35sjlwhat/where is *clojure-version* defined?
17:35vijaykiransjl: may be the deps you have in the project bringing different clojure version ?
17:35bobrydnolen: nope, the patch doesn't work
17:35vijaykiransjl: type it directly into repl
17:36jhultenMy googlefoo is failiing. How do I call a clojure function dynamically? for instance (let [name "action"] (execute (str "do-" name) arg) => (do-action arg)
17:36dnolenbobry: thanks for verifying.
17:37hiredmankmicu: "when you write macros for clojurescript, you write them in clojure" etc etc etc
17:37bobrykmicu: are you the author of the patch for CLJS-77?
17:37sjloh cute, clojure.math.combinatorics and clojure.math.numeric-tower both required 1.3.0, so it silently ignored my 1.4.0 requirement in project.clj
17:37technomancyugh; version ranges
17:38technomancyany project that uses version ranges needs to have hell of bugs filed against it
17:38vijaykiransjl: ^^ :)
17:38amalloyalternatively, a plague of locusts
17:38sjlI still want a language that enforces semantic versioning at the language level somehow
17:39amalloysjl: that's probably harder than the halting problem, just fyi
17:39technomancyyou could always take the go approach: never introduce a backwards-incompatible change ever
17:39sjlyeah, the "don't break your users' code" approach is a fairly solid one
17:39technomancyalso more difficult than the halting problem though
17:40hiredman*shrug* you mean the people who get to use your code for free?
17:40hiredmanyou should go out of your way to keep their code running?
17:40sjlhiredman: yes, because they're humans and wasting their lives is a dick move
17:40`rand`-AFKjhulten: use (symbol)
17:41sjlat least put a "don't use this project if you care about your sanity" warning label if you're going to break things a lot -- that's totally fine
17:41hiredmansjl: wasting yours working around their faulty assumptions is better?
17:41emezeskesjl: Nobody is forcing users to upgrade to a newer version of the language
17:41sjlemezeske: yeah I'm sure all the new libraries will continue to release security fixes compatible with old versions forever
17:41sjlhiredman: yes, it's called being a nice person
17:41emezeskesjl: They can always keep using the old version. If they want all the cool features or security fixes from a new version, they can choose whether it's worth making things work against breaking changes
17:41nDuffsjl: eh? The clojure version you require in your project.clj should override what your dependencies specify
17:42sjlnDuff: that's what I thought, but it doesn't
17:42kmicubobry: nope, I only have used some solution based on that diff in ClojureScript One
17:42sjlemezeske: alternatively, library authors can grow up and care about backwards compatibility and everyone wins
17:42amalloynDuff: not if version ranges are involved. thus, the locusts/bugs
17:42nDuffsjl: I'm really _very_ sure that, under normal circumstances, it does. I have dependencies which specify 1.2.0, and I very certainly get 1.4.0
17:42emezeskesjl: Are you the author of an open source library?
17:43nDuffsjl: ...it'd be interesting to look at the project.clj or pom.xml files for the relevant bits of tooling.
17:43sjlemezeske: yeah, a whole bunch, which I use Semantic versioning for
17:43amalloyif your dependency specified [1.2.0] instead of 1.2.0, then you would not get 1.4.0 no matter what your project.clj says, nDuff
17:43emezeskesjl: Then you know how much work it is. I also try hard for backwards compat.
17:43emezeskesjl: But sometimes that weight can build up and drag you down
17:43sjlemezeske: it's really not that much work to write a few wrapper functions to preserve backwards compatibility
17:43nDuffamalloy: *nod*, which is why I noted that it'd be interesting to actually look at the relevant files.
17:43emezeskesjl: I beg to differ.
17:44hiredmanbackwards compatibility is just another trade off
17:44emezeskehiredman: Exactly
17:44emezeskehiredman: Time spent on backwards compat is not spent on cool new stuff
17:44nDuffsjl: It depends. As I understand it, rhickey tries hard to stay backwards compatible, but only with behaviors he explicitly documented; anything which happens to fall out of the current implementation but isn't documented is liable to change at any time w/o notice.
17:44emezeskehiredman: Both are desirable, and it's a balancing act like everything else.
17:45hiredmanthe dick move is pretending you haven't made a trade off
17:45sjlnDuff: 1.4 doesn't seem to bad, 1.3 was a mess
17:45technomancysomeone should write a lein plugin that tells you which of your dependencies have version ranges and opens your browser to the bug report page for those libraries
17:45nDufftechnomancy++
17:45hiredmantechnomancy: people should use their version ranged deps via polycosm!
17:45sjltechnomancy: if library specifies a range, will lein deps :tree show you the range or just a single number?
17:45Chousukein Clojure's case, I think all backwards-incompatible changes have been good so far.
17:46technomancysjl: just the number; it's collapsed down
17:46sjltechnomancy: ah okay
17:46technomancyyou could determine it's a conflicting range by looking at top-level :deps in project.clj and comparing though
17:46nDuff(don't even remember what it was about anymore)
17:46sjltechnomancy: numeric-tower and combinatorics don't seem to use project.clj -- they have pom.xml files
17:47sjlso I don't know where the range would be specified
17:47technomancythat's contrib for you =(
17:47amalloyChousuke: 1.3 contained a big batch of bad incompatible changes. 1.4 reverted or otherwise addressed most of them
17:47technomancyit should be under <dependencies> -> <version>
17:47hiredmannDuff: http://www.leancrew.com/all-this/2012/04/where-modules-go-to-die/
17:47sjltechnomancy: https://github.com/clojure/math.numeric-tower/blob/master/pom.xml
17:48technomancyhiredman: I just read the ruby equivalent to that post this morning
17:48hiredmanit is a universal
17:48brehautsneaking the name munging change into 1.2.1 was a pain
17:48technomancysjl: bleh; maven is being object-oriented here and inheriting from another pom =\
17:49sjlbut yeah, working on projects like Mercurial (which is wire-compatible to versions something like ~5 years old) made me realize that A) Backwards compatibility matters. and B) It's not that hard once you actually commit to it.
17:49hiredmanproject object model oriented programming
17:49sjltechnomancy: ah
17:49S11001001wire protocols aren't apis
17:49sjltechnomancy: so how can I use both numeric-tower and clojure 1.4?
17:49glitch99anybody know a trick for a memset of clojure - like 10 copies of the same element in a list?
17:49sjlS11001001: It's Mercurial's API, along with the CLI
17:49hiredman,(doc repeat)
17:49technomancysjl: you could add an :exclusions entry to your numeric-tower dependency
17:50clojurebot"([x] [n x]); Returns a lazy (infinite!, or length n if supplied) sequence of xs."
17:50glitch99hiredman: sweet! thanks!
17:50sjltechnomancy: hmm, never seen that -- are there docs on it somewhere?
17:50S11001001implication doesn't imply equivalence
17:50glitch99clojurebot: also thanks!
17:50clojurebotI'm no man, and she's no lady!
17:50technomancysure; `lein help sample` | grep :exclusions
17:50sjlS11001001: okay, replace "API" with "the part of your thing that real humans other than you are going to use"
17:51technomancyhm; well the grep doesn't really work since it cuts off a wrapped line but you get the idea
17:51S11001001right, even more of those things are different
17:51technomancysjl: anyway, there's a time to commit to stability and a time to be experimental and explorative.
17:51amalloytechnomancy: grep -C?
17:51technomancyamalloy: yeah, that
17:52technomancyif I had to commit to stability on something like slamhound it would never get written
17:52sjltechnomancy: right, and the time is either "version 1.0" or "lots of real people use this now and will have to waste time if you break it"
17:52sjltechnomancy: you did the right thing with lein 2.0 -- I just wish more people did the same.
17:52technomancythe problem isn't that people break things, it's that they don't communicate expectations well
17:53sjlsure, putting "Don't use this if you care about your time" is fair warning. You're right -- people don't do that either.
17:53hiredmanthe problem is people use a software package and expect the next version to work the same way
17:54hiredmanwhich is why tools like maven are good, because you can lock a specific version and just use it
17:54sjlYes. Why would a version that had *more* work put into it now be broken? Isn't it supposed to be *better* after more work?
17:54hiredmanand not worry about "oh, I depended on this bug that got fixed, in what was a patch version, so I thought it was ok to upgrade"
17:55technomancysjl: it's silly to think "better" is one-dimensional
17:55sjltechnomancy: Partially, but it's important to remember that the only person who actually cares how pretty the internals are is you (plus other implementers)
17:56sjlPeople using the library care way more about "it's not broken" than "it's elegant inside".
17:56technomancycode that's easier to reason about has fewer bugs
17:56sjlSure, except it's broken and now I need to fix things before I move on.
17:57technomancyit's complicated
17:57technomancysometimes it's worth it in an immature codebase
17:57sjlIt's really not that hard to either 1) Provide little wrappers to stay backwards compatible or 2) Increment the major version and make it obvious that people are going to need to sit down and figure out how to deal.
17:58hiredmaneven in a mature codebase
17:58sjlyes!
17:58hiredman"this is slow and in efficient, it will now be fast, any stick in the mud who hates change is welcome to continue to use the old version"
17:59hiredmanetc
17:59sjlSure, if you don't care about the time and frustration of other human beings that's a valid approach.
17:59technomancyoften you're not free to use old code though; upgrades are contagious
17:59antoineBhello, can i talk clojure-script in this channel?
18:00RaynesWe'd prefer English, but sure.
18:00Raynes;)
18:00sjltechnomancy: exactly -- "use the old version" tends to be a valid option for a couple of months or so
18:00technomancyunless you use that fancy new polycosmosish thing I hear is pretty hot these days =)
18:00borkdudeEsperanto is also accepted
18:00hiredmanit is pretty sweet
18:00hiredman:)
18:01borkdudeor maybe emacs people like Ido more (http://en.wikipedia.org/wiki/Ido)
18:01hiredmanit lets you be more free wheeling with your versions, you can stick with an old version and still move to newer versions of it's dependencies for your own code
18:02technomancyhiredman: curious why you didn't just use plain old classloaders thouh
18:02technomancythough
18:02technomancydo jboss models get you basically the same thing?
18:02sjltechnomancy: okay this is weird
18:03sjltechnomancy: http://paste.stevelosh.com/4fc7e98b58d2e20007000000?clojure
18:03hiredmantechnomancy: they get you more than classloaders, e.g. if you have two things that depend on clojure-1.2 they can share a clojure 1.2 runtime
18:03sjltechnomancy: that results in http://paste.stevelosh.com/4fc7e99c58d2e20007000001 -- no clojure 1.3.0, which looks right
18:03technomancyhiredman: can't you do that by nesting your classloaders the right way though?
18:03technomancyhiredman: I guess you aren't responsible for the tricky calculations on how to do that?
18:03hiredmantechnomancy: right
18:03sjltechnomancy: but if I remove the exclusion from metrics-clojure, clojure 1.3.0 reappears under combinatorics in lein deps :tree
18:03technomancyhiredman: cool
18:03sjlhow could that be?
18:04hiredmanthe plan for jboss modules seems to be that they will be compatible with whatever comes out of project jigsaw too
18:04nDufftechnomancy: ...at least with the OSGi classloader-based model, I have trouble with thread-locals being left around by "unloaded" Clojure plugins, linked to their classloaders, which can't be unloaded in turn until everything they instantiated is gone. Not saying that there aren't approaches to track down and fix leftover thread-locals -- I think Tomcat makes the attempt on app unload -- but it's not always easy.
18:05hiredmannDuff: yeah that kind of thing is still an issue
18:05hiredmanpolycosm doesn't attempt to provide a way to unload modules
18:05technomancysjl: I think when multiple dependencies bring in a given dep there's not really one right answer for questions like that.
18:06sjltechnomancy: okay, I lied -- it's just metrics-clojure bringing in clojure 1.3. But why does :tree put it under combinatorics?
18:06hiredmanif X brings in A and B, and A and B depend on C, should A and B be visble to each other?
18:07sjltechnomancy: and should I not be specifying a version of clojure in the metrics-clojure library anyway? Just tell people which one they need?
18:07hiredmanit short of depends on what you mean by visible, and given clojure's implementation it is actually pretty tricky to avoid
18:07technomancysjl: as long as you don't specify a range you're fine
18:07hiredmanbut dealing with that kind of stuff is what a module system does
18:08sjlseems strange that specifying a range (more flexibility) actually makes things less flexible...
18:09technomancysjl: yeah, I didn't realize how horrible the implementation was for a long time and unfortunately encouraged their use for a wihle
18:09technomancywhile
18:09amalloyyou can specify open-ended ranges like [1.3.0,], or some syntax like that
18:10technomancyamalloy: which is horrible for different reasons =)
18:10amalloywhen i did that, people made fun of me "lol how can you know it will work with 1.6.3?"
18:10TimMc[1.3.0,1.3.9999999] is safer
18:10technomancyyou can say it'll work with 1.3.0 up to but not including 2.0.0
18:10amalloytechnomancy: sure you can
18:10TimMcit still doesn't protect you from alpha releases
18:10technomancyto which aether will be like "what's that? you want 2.0.0-SNAPSHOT? OK, here ya go!"
18:10technomancyಠ_ಠ
18:11amalloyand then if it happens to work with 2.0.0 anyway, people will still be annoyed
18:11technomancyamalloy: yeah, exactly why I don't recommend the 9999999999 approach
18:11technomancysemantic versioning doesn't mean major version bumps must be completely incompatible
18:12sjl"Major version X (X.y.z | X > 0) MUST be incremented if any backwards incompatible changes are introduced to the public API."
18:13TimMctechnomancy: Unless you version your variable names too. :-P
18:13amalloysjl: uhhhh, are you trying to disagree with technomancy? because he just stated that the converse is untrue
18:13antoineBi am trying to use the browser repl with a server (file:///myfile.....) and it doesn't works
18:14sjlamalloy: the other part is that there's no other place in that spec that says anything about incrementing major version numbers
18:14TimMcamalloy: Not even that.
18:14TimMc"Completely" is the operative (and fun) word.
18:14sjlWell sure, they could happen to have only broken parts of the code you never use, that's true.
18:15amalloysjl: so what? "x MUST be done if y" does not mean "x MUST NOT be done if not-y"
18:15sjlBut in the semver.org description of it, the ONLY time the major version is incremented is when you break something
18:15pjstadigif P, then Q does not imply if Q, then P
18:15sjlamalloy: yeah, but that's the only rule applying to major versions in the spec
18:15amalloysjl: uh huh
18:16pjstadigin fact it is fallacious to draw that conclusion
18:16amalloywhich is my point
18:16amalloyand pjstadig's
18:16technomancythe more careful you are about bumping on every incompatible change the more likely it is that a bump will result from a change that doesn't affect some people
18:16TimMcsjl: It's not part of the spec, even though it might be a good idea.
18:16sjlSure, you could also say "well he doesn't say NOT to increment the major version number when you eat Indian food for lunch that day!"
18:16pjstadigsjl: sounds good to me
18:16amalloy*shrug* and if i chose to increment the major version number once a year on my birthday, i would not be in violation of the spec
18:17amalloyas long as i also bumped it whenever i broke something
18:17sjlamalloy: you are technically correct
18:17sjlthe best kind
18:17pjstadigif the sun comes up, then the rooster crows, therefore if the rooster crows, then the sun will come up
18:17pjstadigbut of course roosters don't make the sun come up
18:17amalloysjl: the only kind. if the spec doesn't forbid something, then doing it can't cause you to be non-compliant. that's what a spec MEANS
18:18sjlamalloy: I guess I'm assuming some level of common sense here,
18:18TimMcpjstadig: Well, we've never tested that by taping all the roosters' beaks shut...
18:18amalloyTimMc, chicken-harasser incognito
18:19arohneris there a way to examine an agent's queue?
18:19TimMcsjl: I get annoyed at "needless" major version bumps, but I'd not say they're counter-spec.
18:19arohnerand has anyone else ever wanted an agent's queue to be a sorted set? i.e. ignore duplicate calls?
18:19TimMcsjl: It certainly violates the Principle of Least Astonishment.
18:19hiredmanarohner: perhaps you should put a set in your agent
18:20pjstadigTimMc: you do something major, so you bump the major version...doesn't astonish me
18:20arohnerhiredman: I'm kind of hacking it. I don't really care about the value of the agent, I just want to serialize some I/O
18:20pjstadig"something major" is not necessarily equal to "something breaking"
18:20sjlTimMc: They might not violate the spec in the pedantic nerd version of it, but they do in the normal-human, spirit-of-the-thing version.
18:20hiredmanarohner: :(
18:20sjlpjstadig: in semantic versioning yes, it is
18:20TimMcpjstadig: If it only adds stuff, it's a minor version bump.
18:21hiredmanarohner: then just put a sorted set in a ref
18:21sjlpjstadig: http://semver.org/ is the spec we're talking about
18:21TimMcsemver doesn't track cool, it tracks compatibility.
18:21hiredmanrun a loop in a future to read it and the io
18:21technomancyuh oh; pjstadig is violating semver
18:21technomancy~guards
18:21clojurebotSEIZE HIM!
18:21arohnerhiredman: yeah, but I want the fn to be called when I call it, but if another call to f is already in the queue, throw it on the floor
18:22sjlThe benefit to using it is that I can say "Foo works with version 1.4 or higher, but not anything starting with a 2 because that broke something"
18:22sjlThat way I don't need to manually inspect each new version of the library unless the major version changed
18:22hiredmanarohner: well that isn't an agent anyway, right? agents are asynchronous
18:22borkdudeso emacs 24 is not compatible with 23?
18:22sjlborkdude: if they used semver, that would be the case, but I don't think they do
18:23arohnerhiredman: I want async and serialized, I just want the queue to be a sorted set
18:23amalloyarohner: so put a ref around a set. or a queue, and have your alter function check to see if it should actually add anything
18:23hiredmanarohner: right, but you don't want a reference, you don't care about the value
18:23technomancyborkdude: the answer, as always, is "it's complicated" =)
18:23technomancysome things are compatible and some aren't.
18:23hiredmanso you don't want an agent
18:23sjlborkdude: and anyway isn't the "24" in "emacs 24" short for "emacs 1.24" and it's just that no one ever writes the "1." any more?
18:23sjlI thought I read that somewhere
18:23sjlCould be wrong though -- I use Vim.
18:23hiredmanso, stick a sorted set in a ref, have a thread read from the ref in a loop
18:23hiredmandone
18:24borkdudeslj with java that is the case, with emacs I doubt it, but could be
18:24technomancyborkdude: no, he's right
18:24TimMcIt doesn't always make sense to follow semver.
18:24borkdudetechnomancy ah, ok
18:24TimMcApps like Firefox and Emacs... nothing really links against the UI.
18:24TimMcNow, their internal components, sure.
18:24sjlYeah, standalone GUI apps don't really make sense, definitely.
18:25clojure-newcomerhey guys, I've got dates stored as '1065706498' (int(11) in MySQL), I'm trying to get them out with clojure.java.jdbc and they are all coming up as 1970 or thereabouts….. how do I extract them correctly ? oh, I'm using clj-time
18:25sjlCLI ones do though -- the CLI becomes the public-facing API as soon as someone writes a bash script.
18:25borkdudetechnomancy where can I find that?
18:26pjstadigmeh
18:27pjstadigthat's enough bikeshedding for me for today
18:27technomancyborkdude: wikipedia says "Versions 2 to 12 never existed. Earlier versions of GNU Emacs had been numbered "1.x.x", but sometime after version 1.12 the decision was made to drop the "1", as it was thought the major number would never change."
18:27technomancyso I guess that's a little different from 24 technically still being 1.24
18:27pjstadighehe
18:28jjidoclojure-newcomer: maybe times 1000? This timestamp is in 2003 using Unix epoch
18:28pjstadig"these are not the major numbers you are looking for"
18:28pipelineemacs also stopped development for a really, really long time
18:29pipelineall "interesting" things happened inside of xemacs or another fork first for a really l ong time
18:29pipelineemacs 22 came out in '07 and development has been really rapid since then
18:29clojure-newcomerjjido: could you tell me a little more about this, sorry
18:29TimMcJava will never go 2.0. Python is pretty much stuck at 2.x.
18:29hiredmanjava went 2.0
18:29hiredmanand is now at 7
18:29technomancypipeline: I think it still came in under the XP->vista gap though =)
18:30S11001001TimMc: I'm a 3k believer :)
18:30pjstadigclojure-newcomer: that doesn't seem like a clojure issue. ask the person who created the database and inserted the data what the numbers mean
18:30TimMchiredman: Eh, Java 7 is the marketing name, but it is Java v1.7.
18:30gfrederi`you'd think there weren't any major numbers above 5
18:30hiredmanTimMc: 1.7 is the jvm version
18:30S11001001wasn't it java 2 v1.2, java 2 v1.3?
18:30pipelinetechnomancy: yes, technically, but versions 18 through 21, particularly 18, 19, 20, were so similar that you might as well compare them to service packs
18:30pjstadigclojure-newcomer: java dates can be constructed with number of millis since epoch, you may need to do some work to convert the fields to millis
18:31gfrederi`versions could be like points in pinball -- you add 500 at the slightest provocation
18:31TimMchiredman: Mmm, interesting... I'll have to think about that.
18:31TimMcgfrederi`: Well, Firefox already went full retard with versions.
18:31clojure-newcomerthanks guys
18:31pjstadigclojure-newcomer: i think what jjido suspects is that they are actually the number of seconds since epoch, which means you'd have to multiply my 1000
18:31clojure-newcomerI'll have a look
18:31pjstadig*by
18:31jjidoclojure-newcomer: it is a JDBC issue, find how it interprets timestamp from your db.
18:31gfrederi`TimMc: the only thing retarded is all opinions except my own
18:31ethanishey guys, I'm trying to setup testing in a clojure project and use leiningen to run the tests
18:32pjstadigbut he said they are int(11) fields, not date fields
18:32pjstadigso my guess is JDBC brings them out as integers
18:32ethanisbut whenever I call "lein test", the output is: "Exception in thread "main" java.lang.RuntimeException: java.io.FileNotFoundException: Could not locate sherbondy/test/point_api__init.class or sherbondy/test/point_api.clj on classpath"
18:32hiredmanjjido: most likely since he says "I am using clj-time" he is turning the ints in to dates badly
18:32clojure-newcomerpjstadig: yes int(11)
18:32ethanisis there some sort of classpath voodoo I need to do to set things up properly?
18:32TimMcethanis: Did you name the file with an underscore or a hyphen?
18:32ethanishyphen
18:33clojure-newcomerhiredman: same problem if I construct from java.util.Date with Long in constructor
18:33TimMcethanis: There's your problem.
18:33ethaniswoohoo
18:34technomancywelcome to the JVM where the filenames are made up and the points don't matter
18:35brehautlol
18:35brehauti liked the original british JVM better than the US remake
18:36hiredmanthe british jvm is for toffs
18:36technomancybut there was that one episode where Stephen Fry made a cameo
18:37technomancyas the G1 garbage collector
18:37technomancywait, are toffs good or bad?
18:38brehautclearly they are good
18:38brehautotherwise hiredman wouldnt be making any sense
18:39pjstadighttp://en.wikipedia.org/wiki/Toff
18:39pjstadigderogatory
18:39pjstadigand mildly so
18:42zomgHi, I wonder if there are any common gotchas or such in Clojure for people not familiar with it?
18:42technomancyzomg: contains?, isa?, and partition don't do what you think they do.
18:42zomgI'm converting some Java code into Clojure, and while I've managed to make the code compile, it doesn't work the same way as the Java code does
18:42zomgSo just wondering if there's anything that could easily trick you before I go through the code again for the 5th time to find out if I did some stupid mistake somewhere
18:42zomg=)
18:42technomancyalso don't use protocols, defrecord, or deftype until you have a few months of experience
18:43zomgYeah I don't even know what those are... =)
18:43technomancyeven better! =)
18:43technomancydon't mix laziness and side effects
18:43technomancywe need like a ten commandments for newbies
18:43hiredmanzomg: that is generally a bad idea, clojure code for the same task is often very different from the java code
18:44zomghiredman: Yeah I'm not doing one to one code of course :)
18:44gfrederi`technomancy: that was impressive
18:44zomgbut more like rewriting it to do the same job
18:44technomancygfrederi`: I, uh... spend a lot of time on IRC.
18:44gfrederi`~gotcha
18:44clojurebotCool story bro.
18:44zomgI've done some Haskell before so I'm not *completely* lost ;)
18:44zomgBut only passingly familiar with any lisp like languages
18:44gfrederi`clojurebot: gotcha is contains?, isa?, and partition don't do what you think they do.
18:44clojurebotRoger.
18:44gfrederi`~gotcha
18:44clojurebotgotcha is contains
18:44technomancydon't write any macros in your first three months
18:44gfrederi`crap
18:45gfrederi`technomancy: please make your language sound as much like new-parent advice as possible
18:45technomancyhaha
18:45borkdudealso, only use def/defn on top level expressions
18:45zomg"do not drop the baby"
18:45pjstadigdon't expect any sleep for at least 2 months
18:46arohnerhiredman: FYI, you can get at the agent's queue with wallhack field, but the items in the queue aren't amenable to being put in a set, because each fn gets a new (binding-conveyor-fn) wrapped, which kills equality
18:46zomgOh regarding defn, is there a difference between using 'do' in it or not? :P As in, (defn foo [] (one) (two)) vs (defn foo [] (do (one) (two)))
18:46gfrederi`zomg: no diff
18:46zomgI noticed the docs for certain things like when and when-not say they have an implicit do, but I wasn't really able to find out anything concrete
18:46technomancyzomg: sounds like you're asking the right questions at least. =)
18:46pjstadiguh oh
18:47pjstadiglet's not open up that can of worms
18:47gfrederi`pjstadig: there's a diff?
18:47pjstadigwhen vs. if can be very contentious
18:47gfrederi`oh nm
18:47gfrederi`well there is technically one difference
18:48pjstadigzomg: i think the answer is that defns have an implicit do as well, so the do is unnecessary
18:48zomgAh I see
18:48gfrederi`(fn [] {:pre [false]} :x) is definitely not the same as (fn [] (do {:pre [false]} :x))
18:48gfrederi`but you wouldn't do that anyways
18:48hiredmanarohner: also it is just a bad idea, as everyone (all 2 of us) that have responded to you have said
18:49hiredmanthe semantics you want are not the semantics of agents, so stop trying to use them
18:49zomgWell, thanks for the pointers. I guess I'm going over my code once more to find that mistake I did =)
19:03ethanishmm, how can I preserve my shell's environment variables when using lein repl/test?
19:04ethanisas in, I have defs which rely on System/getenv calls
19:04ethanisor is there a better way of going about this? profiles?
19:04technomancythe environment should be preserved
19:04technomancy(just ask Captain Planet)
19:04technomancysorry
19:04ethanishaha
19:06ethaniseven the temporary environment created by a call of source?
19:06ethanishere's my setup:
19:06ethanisI have a local .env file containing various API keys
19:07ethanisto test, I figured I could call source .env
19:07technomancyethanis: try export $(cat .env)
19:07ethanisalright!
19:07technomancyethanis: curious, is this for heroku?
19:07ethanisyep
19:08technomancycool; have fun =)
19:09ethanisgreat, it works! thanks technomancy.
19:48devni wonder... does it make sense to port pprint to clojurescript?
19:51devnklauern: howdy
19:52antoineBi just start to do a simple "hello world" in clojure-script
19:53antoineBit give me 19000 lines
19:53brehauthave you used advanced compilation?
19:53antoineBno
19:53amalloygood thing the computer writes them for you, eh?
19:53brehautthat would be why then
19:56devnantoineB: {:optimizations :advanced, :pretty-print :false}
20:00antoineB5400 lines, it is probably more than my application will need
20:01devnantoineB: perhaps
20:02devnantoineB: not everyone needs jquery or clojurescript
20:03antoineBi try to build a schema maker with the svg element
20:06antoineBin 708 lines i do "simple direct link", "box wiith text", "context menu", "serialization/deSerialzation"
20:11devnantoineB: why do you think it is 700 lines?
20:12antoineBuntil no it is 700lines
20:12devnsorry. why do you think it is 5400 lines?
20:12antoineBi just count them
20:13devnantoineB: yes. but why do you think it is 5400 lines?
20:13TimMcI wonder what jquery weighs in at these days.
20:13antoineBi make a simple hello world compile then with advance but with pretty print and give me a js file
20:14brehaut9404 lines
20:14brehautTimMc: ^
20:14devnantoineB: i understand. think about why the output is that big. do you know why?
20:14antoineBrealy?
20:15antoineBdevn: unfortly not
20:15devnantoineB: http://lukevanderhart.com/2011/09/30/using-javascript-and-clojurescript.html
20:15TimMcbrehaut: Huh. That's the uncompressed, right?
20:15brehautTimMc: yes
20:15brehautantoineB: if you wrote hello.c compiled it and statically linked it with libc would you be surprised if it was large?
20:16brehautTimMc: compressed im pretty sure its only one line
20:18TimMcheh
20:18devnhaha i was thinking the same thing
20:22fil512how do i add something to the front of a vector?
20:22antoineBdevn: i think the code is the goog stuff
20:23technomancyfil512: depends, do you care the tiniest bit about performance?
20:23fil512not so much...
20:23antoineBbrehaut: no, but the libc embrace also the browser stuff
20:23brehauterr
20:24devnfil512: why do you want to add to the front of a vector? what do you want to accomplish?
20:24fil512the reason I want to stick it at the start is to make it easy to use update-in, e.g. (update-in :foo 0 :bar 0
20:24technomancyfil512: ok, in that case you can do something goofy like (vec (cons x myvec))
20:24hiredmaninto!
20:24technomancyoh yeah
20:25fil512I'd love it if I could go (update-in :foo $ :bar $) or sth to mean "last"
20:25technomancy,(into [:head] [:middle :tail])
20:25clojurebot[:head :middle :tail]
20:25fil512nice!
20:25TimMcHuh, cute.
20:25fil512thanks!
20:26TimMcHmm. update-in would make a nice protocol.
20:27devncute indeed
20:27TimMcEach layer could decide how much of the key list to consume.
20:28TimMcFor instance, a 3rd-order tensor would consume 3 integer keys.
20:33brehaut,(for [:let [a [1 2]] b a] (inc b))
20:33clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalStateException: Can't pop empty vector>
20:33brehaut,*clojure-version*
20:33clojurebot{:interim true, :major 1, :minor 4, :incremental 0, :qualifier "master"}
20:35antoineBgood night
20:37TimMcbrehaut: Same in 1.3.0. What's up?
20:38brehautjust curious
20:39brehautits also the same in 1.2; i just wondered if it had been fixed on a new version
20:39hiredmanwhat for really needs is :do
20:39TimMcbrehaut: Fixed, as in... better error message?
20:40brehautwell, let you have a :let at the start of a for
20:40technomancyhiredman: :let [_ (horrible-side-effects)]
20:40technomancyoops, beat me to it
20:41hiredmanwell, duh
20:41hiredmanI would just prefer :do to having to do that
20:41samlhey, how can I watch a directory tree for modification?
20:41samlsomething like inotify on linux
20:41technomancysaml: you need java 7 to do it portably IIRC
20:41TimMcThat's a common question these days.
20:42samlcool i just downloaded jdk
20:42saml7
20:42technomancyhiredman: that comes dangerously close to endorsing side effects in laziness
20:42technomancyugly things should be ugly
20:43lazybotjava.lang.RuntimeException: EOF while reading
20:46hiredmantechnomancy: sometimes you gotta log
20:46hiredman:do in doseq would be nice too
20:52TimMcExplain to me again the use-case for a :let at the beginning of a for form?
20:53hiredmanyou have a for inside a let, and you want to pull it up a level
21:13_KY_I did a "lein clean" before "lein uberjar" but I still get "java.language.NoClassDefFoundError", how to fix that?
21:20hiredmanI don't see how people expect to get anything done when they go around throwing out all the information that comes with an exception
21:20_KY_This is the error log:
21:20_KY_https://www.refheap.com/paste/2950
21:22hiredmanwhat does the ns form for genifer.core look like?
21:25_KY_1 sec...
21:25_KY_(Ands genifer.core
21:25_KY_ (:require [genifer.forward_chaining :as forward])
21:25_KY_ (:require [genifer.backward_chaining :as backward])
21:25_KY_ (:require [genifer.core :as core])
21:25_KY_ (:require [clojure.main])
21:25_KY_ (:require [clojure.string :as string :only [split triml]])
21:25_KY_ (:gen-class)
21:26brehaut_KY_: http://refheap.com etc
21:26_KY_First line should be (ns
21:26hiredmanthose underscores should be hyphens
21:26hiredmanyou only need a single :require
21:26xeqiwhy does genifer.core :require itself?
21:26_KY_But it used to work...
21:27hiredmanthat's not right either
21:27hiredman_KY_: no it didn't
21:27_KY_The file name is with the underscore
21:27hiredmansure
21:27hiredmanthe file name has an underscore
21:27hiredmanthe namespace name should have a hyphen
21:28hiredman_KY_: you tricked yourself in to thinking it worked somehow
21:28hiredmanbut it did not
21:28_KY_Namespace is just genifer.core
21:29_KY_The file is exactly "forward_chaining.clj"
21:29hiredmansure
21:29_KY_You mean I change it to hyphen in the file name?
21:29hiredmanno
21:29hiredmanthe file name stays the same
21:29_KY_Alright
21:29hiredmanbut the namespace for the namespace backed by that file should have a hyphen
21:30hiredmanclojure trys to make things simpler by giving the .clj file name the same file name as the generated class, and java doesn't allow '-' in classnames
21:31hiredmanbut in clojure the convention is to use '-' in symbols to separate words
21:31hiredmannamespaces are named by a symbol
21:31hiredmanso the namespace genifer.forward-chaining lives in the file genifer/forward_chaining.clj
21:32hiredmanand this is why most people just avoid hyphens or dashes when it comes to namespaces
21:33joegallohere's something totally bizarre
21:33hiredman_KY_: so there are a number of problems with that ns form, the one that is stopping your code from loading is most likely the namespace requiring itself
21:33joegallooops, wrong channel -- you tricked me hiredman!
21:33hiredmanhah, now people in #clojure know you can talk
21:34_KY_Do you mean clojure automatically changes my namespace to forward-chaining?
21:35_KY_But I declared the namespace in that file to be genifer.forward_chaining
21:35hiredmandon't do that
21:35hiredmanit should be genifer.forward-chaining
21:35brehautunderscores in clojure space names is non-idiomatic style, even when it works
21:36brehautnot to mention plain ugly
21:37_KY_So I keep the file names, and change the space names?
21:37_KY_Is that allowed?
21:37ethanishey guys, has there been any talk of tweaking the load-lib function in clojure.core so that the :only option accepts an individual symbol in addition to a seq of symbols?
21:37_KY_I thought it's required that file name = namespace name
21:38ethanisI'm new to clojure, and I keep getting tripped up and accidentally typing (:use some-package :only bla) when I only want to use one function
21:38ethanisI guess this would make the use function inconsistent
21:39ethanisbut it seems like a pragmatic tweak
21:39ethanisthoughts?
21:39hiredmanethanis: use :require not :use
21:39_KY_I have been using :only blah without [] and it seems to work
21:39ethanisah, so it's just poor form to do :use if I only want a single function?
21:42tmciverethanis: not because you only want one function; use is discouraged - use require.
21:42ethanis_KY_: what version of clojure are you using? (use '[clojure.string :only lower-case]) definitely does not work for me.
21:42ethanisah, use is just generally discouraged because require is more explicit?
21:43_KY_1.3.0
21:43gtrakI find 'use' obfuscating
21:43ethanissure, I understand why
21:43_KY_I use :require in ns
21:44brehautuse is also unnecessary with :refer in 1.4+'s require
21:44brehautthough still useful at a repl
21:44hiredman_KY_: have you read the docstring on require?
21:44hiredman(you may find that there is no :only option, so clojure is silently ignoring you)
21:46_KY_Oh really
21:46samlhey, if anyone is using La Clojure, how would I import lein project to that IDE?
21:46gtrakwhere's an example of the :refer feature?
21:48ethanisdon't actually do this
21:48brehaut,(do (require '[clojure.set :as set :refer [difference]]) (difference (set/union #{:a} #{:b}) #{:b}))
21:48clojurebot#{:a}
21:48ethanisbut an example
21:48ethanisoh, never mind
21:48brehautgtrak: ^
21:49gtrakah, neat
21:49ethaniseven so
21:50gtrak,(difference #{:a} #{:a :b})
21:50clojurebot#{}
21:50ethanisit'd be nice to be able to type (require '[clojure.set :as set :refer difference])
21:50ethanisbut you could make the case
21:50hiredmandenied
21:50brehautclojure.set/difference cares about ordering
21:50ethanisthat it'd just be more typing later the moment you decide to refer another function
21:50gtrak,(difference #{:a :b} #{:a})
21:50clojurebot#{:b}
21:51brehautgtrak: theres a math word for that and i cant remember waht it is
21:51brehauttransitive?
21:51brehautassociative?
21:51brehautone of those
21:51gtrakassociative
21:51brehautthanks
21:52aperiodicwell, if it cares about ordering, then it's *not* associative
21:52gtrakright
21:53metellusI think you mean commutative
21:53brehautthis is why im no good at math
21:53ethanisalright folks, thanks for the style tips re: use of require
21:54ethanisnight
21:54aperiodic"ordering" in the (a (b c)) vs ((a b) c) sense
21:54aperiodicnot the (a b) vs (b a) sense
21:54gfrederi`What's purple and commutes?
21:54aperiodican abelian grape!
21:54gfrederi`AAAAHAHAHAHAHHAA
21:55gfrederi`o/
21:55aperiodic\o
21:55gfrederi`my work here is done
21:55_KY_,(docs ns)
21:55clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: docs in this context, compiling:(NO_SOURCE_PATH:0)>
21:55aperiodici'm partial to the "what's purple and takes the train to work?" version, myself
21:55_KY_,(doc ns)
21:55clojurebot"([name docstring? attr-map? references*]); Sets *ns* to the namespace named by name (unevaluated), creating it if needed. references can be zero or more of: (:refer-clojure ...) (:require ...) (:use ...) (:import ...) (:load ...) (:gen-class) with the syntax of refer-clojure/require/use/import/load/gen-class respectively, except the arguments are unevaluated and need not be quoted. (:gen-class .....
22:05_KY_I don't know why but I changed my deps and now lein won't work
22:05_KY_It's always noClassFound for this and that file
22:06_KY_The namespace, require etc used to work
22:15TimMcHey, Light Table hit 300 kilobucks!
22:26abpTimMc: Thanks, reminded me that i meant to pledge too..
22:26TimMc:-D
22:27xhhabp: you got 19 hours left ;)
22:29abpxhh: I know, but then I surely would miss the deadline. Where waiting the last months, despite knowing i will pledge eventually .
22:43_KY_Oh I found out... I was opening 2 sessions of lein at the same time =)
22:43_KY_Almost drove me nuts
23:03irc2samushi guys, if I were to capture SIGINT in order to do cleanup I should use the Java way that is registering a shutdown hook like it's said here: http://stackoverflow.com/questions/2541475/capture-sigint-in-java right? or is there a Clojure-specific way that is preferable?
23:03technomancyirc2samus: shutdown hook is best
23:04irc2samusgreat thanks!
23:40zomgNeat, managed to whip together a desktop streaming application even though I had never used clojure before :D
23:40zomgUsing xuggler with ogg theora encoder and html5 video as the "target" where you can view the desktop stream
23:41zomgon my local box only about 1-2 seconds of latency so not bad I think =)
23:41zomgprob worse over a network tho
23:42irc2samusso guys, do I need gen-class for the shutdown hook thread? or is there a more "direct" way to define the function to run there
23:45LajlaChousuke, mun rakkaus, oletko täällä?
23:48irc2samushmm there's a "proxy" thingy that seems to do it
23:51abpirc2samus: http://cemerick.com/2011/07/05/flowchart-for-choosing-the-right-clojure-type-definition-form/ have a look at that chart and deceide
23:55technomancyirc2samus: you don't need anything fancy to create a thread, just pass it a function
23:55technomancy(.start (Thread. #(do :some 'stuff)))
23:56technomancywell, don't start it in this case I guess
23:58irc2samuslots of options :) the proxy thing worked, copied it from here: http://java.dzone.com/articles/clojuretest-introduction