#clojure logs

2011-12-21

00:01akhudeksuccess, one project updated to 1.3!
00:29amalloyakhudek: lists mean something different. and matches are looked up by hashcode: the clojure sequential collections all hash the same regardless of type
00:34qbg,(case '(:a :a) (:b :a) 1 (:a :a) 2)
00:34clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Duplicate case test constant: :a>
00:34akhudekamalloy: thanks for the info. For some reasons I thought the data type would matter and also figured that escaping the list would disable the default evaluation semantics. Not sure why I would think this.
00:35qbg,(case 1 (1 2 3) :low (4 5 6) :high)
00:35clojurebot:low
00:36akhudekwhoa, actually in 1.2 it does behave oddly
00:36akhudekwith quoted case statements
00:37qbgDoesn't do error checking?
00:37akhudek(case '(:a :b) '(:a :a) 1 '(:a :b) 2 '(:b :a) 3 '(:b :b) 4) returns 2
00:37akhudek(case '(:a :b) (:a :a) 1 (:a :b) 2 (:b :a) 3 (:b :b) 4) throws a no match error
00:37akhudekoh well, 1.3 doesn't allow this wonky thing
00:37amalloythat's because you can't just arbitrarily quote something and expect it to mean the same thing
00:37qbgSecond one is wrong
00:37akhudekI know
00:38akhudekwas just exploring if quoting works like I thought it did in 1.2
00:38qbg,(case '(:a :b) ((:a :b)) 1)
00:38clojurebot1
00:38akhudekoh, interesting, I see
00:38akhudekdidn't know you could do that
00:38qbgLists are shorthand for multiple cases
00:39akhudekright, it makes sense now that I think about it
00:39qbgAnd that is why quoting doesn't work
00:40akhudekquoting oddly enough did work in 1.2
00:40qbgDidn't check for dups back then it looks like
00:41qbgSince you effectively had (case '(:a :b) (quote (:a :a)) 1 (quote (:a :b)) 2 (quote (:b :a)) 3 (quote (:b :b)) 4)
00:42jkkrameramalloy: (just read through some backlog) FYI, you get 750 free dyno hours per heroku app, not per account
00:42akhudekI see, that explains it. Thanks. :)
00:43jkkramercitation: http://devcenter.heroku.com/categories/billing and my november invoice
00:44amalloyah, thanks jkkramer. that makes a lot more sense
00:44amalloy$mail technomancy btw, looks like it's 750 h/mo/app
00:44lazybotMessage saved.
00:46technomancy_no kidding
00:47ibdknoxoh, it's per app?
00:47ibdknoxsweet
01:24jliman, I have a really hard time understanding what Java Beans are
01:26brehautjli objects that conform to a reflectiony interface for getters and setters
01:26brehautjli: enterprise beans are a world of hurt more complicated
01:26jlireflectiony?
01:26brehautits an interface based on the names of methods, rather than a concrete interface
01:27brehautimagine a retarded hashmap with a fixed set of keys a, b and c that you can read with getA, getB, and getC and set with setA, setB, and setC
01:28brehaut,(bean (java.util.Date.))
01:28clojurebot{:seconds 46, :date 20, :class java.util.Date, :minutes 28, :hours 22, ...}
01:29brehautjli: compare that with http://docs.oracle.com/javase/6/docs/api/java/sql/Date.html
01:30jliso beaniness is just having getters and setters for all your fields?
01:30brehautbingo
01:30jliwtf.
01:30brehautwelcome to java ;)
01:30brehautyou know what is also cool? acres of xml
01:31brehautjava has some awesome stuff. and some stuff that is not awesome
01:32jlido the getters and setters actually have to correspond to real fields? I guess I don't see the point.
01:35brehautyeah i think thats the point
01:35brehautits encapsulation at its finest
01:36jli:/
01:42jliEJB is a server-side model that encapsulates the business logic of an application.
01:42jliwut
01:43ibdknoxjava makes me sad
01:43jliEJB: it's code!
01:43jliI don't understand :/
01:48ibdknoxanyone have a good explanation of state monads somewhere?
01:48hiredmanimagine a burrito
01:49hiredmanthey are similar in that you can imagine either of them
01:49ibdknoxlol
01:49ibdknoxwell done :p
01:51jsnikerisHi all. I'm trying to play around w/ the internals of clojure.pprint. I'd like to call some of the fns in dispatch.clj directly, such as pprint-code-list. However, when I do so, I get an exception: java.io.PrintWriter cannot be cast to clojure.lang.IDeref. Any ideas what's going on?
01:52replacajsnikeris: you need to call those functions with a pretty writer
01:52replacawhich is the extension of Writer that keeps track of line breaks and columns
01:53jsnikerisreplaca: ah OK. I see a with-pretty-writer fn
01:53replacayup, that's the easiest wat to do it
01:54jsnikerisIs there a pretty writer already set up in a special variable?
01:54hiredmanibdknox: http://channel9.msdn.com/shows/Going+Deep/Brian-Beckman-Dont-fear-the-Monads/ I don't thing he goes it the state monad specificly, but if you are look for a generally intro to monads it's a pretty good video
01:54replacaor you can call get-pretty-writer: http://clojure.github.com/clojure/clojure.pprint-api.html#clojure.pprint/get-pretty-writer
01:54replacajsnikeris: no, they're created on demand when you call pprint
01:55replacaunless you already have one bound to out
01:55replaca*out*, I mean
01:56jsnikerisah, I got it
01:56jsnikeris(with-pretty-writer *out* form) did the trick
01:57jsnikerisreplaca: thanks for the help
01:58replacajsnikeris: np
03:34Blktgood morning everyone
03:35Blkt(yes, it is a /amsg, but I love to greet everyone)
03:37gunsg morning; where are you in the world?
03:37BlktItaly
03:53Scriptornew york city
03:53ScriptorI wonder if a speaker has been lined up yet
03:53rfgpfeiffergood morning
04:14kralnamaste
04:37Vinzentwhen I have some ns with vars conflicting with clojure.core ones it compiles for the first time, but throws exception on second. Why?
04:41clgvVinzent: you can use (refer-clojure :exclude [stupid-command-that-conflicts])
04:42Vinzentclgv, of course, but why the behaviour is so strange? It first compiles with warnings, but then doesn't compile at all
04:43Vinzentalways compile with warnings seems like a more reasonable behaviour
04:43clgvwhat is first and second time? first time = open repl, second time = reload in running repl?
04:43tscheiblVinzent: maybe because the second time it tries to override your overriden functions with the core ones again...
04:43clgvthats thecase where I noticed that
04:44tscheibl...which may cause a different behaviour
04:44clgvI think it is a one way street: you can override core-fns but when reloading core-fns would replace your local definitions it throws the error
04:45tscheibl..that's what I wanted to say
04:45Vinzentclgv, yeah, first = just after starting slime, second - compiling it again after first one
04:45clgvtscheibl: right. you got the same idea.
04:46Vinzenttscheibl, yeah, I think so too, but what's wrong with doing so?
04:47tscheiblclgv: as a non native english speaker (writer) I cannot alway be sure that people understand what I try to say :)
04:47clgvtscheibl: what origin?
04:47tscheiblAustria
04:47tscheibl..no Kangaroos :)
04:47clgvah well then you might like #clojure.de as well ;)
04:49tscheiblmust have a look if telepathy alows me to join more than one channel on the same IRC network...
04:49tscheiblI'm not an IRC pro I must say
04:50clgvme neither
05:06Vinzenthow can I destructure nested map? e.g. I have {:a {:x 1 :y 2}}, how to get x and y?
05:08clgvshould be ##(let [{{x :x y :y} :a} {:a {:x 1 :y 2}}] [x y])
05:08lazybot⇒ [1 2]
05:10Vinzentah, right, thank you
05:12Vinzentalthough, it's not very readable, I'd better won't use it in my case
05:13clgvVInzent: you can also use 'get-in like ##(get-in {:a {:x 1 :y 2}} [:a :x])
05:13lazybot⇒ 1
05:14Vinzentclgv, yeah, but i'd better stick with {:keys [a] ...} in let and (:x a) (:y a) in body
05:15clgvVinzent: If you only query one value dont use destructuring at all
05:16clgv(let [c (:a m)] [(:x c) (:y c)]) is sufficient^^
05:17Vinzentyeah, but actually it's in a for loop: (for [{:keys [price] :as i} items] ...)
05:19clgvVinzent: you also do it like (for [i items :let [p (:price i)]] ...) - only showing you the options ;)
05:20Vinzentright :)
07:05VinzentI'm trying to use lobos. It throws "java.lang.String cannot be cast to java.lang.Number" (and long creepy stacktrace) when I'm calling migrate or rollback. Have somebody faced it too?
07:20clgvVinzent: well, any idea where you might have put a string that should be a number according to the api docs?
07:21clgvstacktraces are best dealt with by filtering all the clj stacktraceelements
07:21Vinzentclgv, I don't have ANY strings in that namespace
07:21Vinzentwell, except the db spec
07:21clgvyeah, probably some configuration
07:22VinzentBut direct call to (create ...) works fine. I'm trying to reproduce it in the new project now...
07:22Vinzentyep - same thing
07:31accelis I need to pass a null to java; can I do it with nil from clojure?
07:35clgvaccel: pass the nil
07:36clgvacced: it's just a different name in clojure
07:41accelclgv: worked; thanks!
07:42accelI am familiar with clojure's proxy (proxied a few AWT event listeners). However, now I need a way to create a new Java class (from Clojure land) that inherits from a Java class + adds a few member fields to it. Is this do-able with proxy? [All examples of proxy I have seen only adds new member functions; but does not attach member fields.]
07:44clgvaccel: you always have the option to just write that class in java if you need almost all of javas oop
07:45accelI'm converting a java code base to clojure + rewriting it
07:45accelSo I'm basically taking Java classes, and knocking them off one by one.
07:46clgvthat process is probably not a good one
07:46accelit induces OO code in lisp syntax?
07:48clgvyou shouldnt try to reimplement your java class structure in clojure.
07:49accelIt's a Java library that I did not write; I'm simutaneosuly trying to understand it + use it.
07:49accelRewriting it in Clojure + rewriting it in a functional style seems like the best way to go.
07:50clgvif you rewrite it in a functional style that will work. but if you stick to the class hierarchies you wont get much more benefits from that
07:51accelAgreed. However, I prefer to do incremental rewrites onw orking code.
07:51accelThus, it's beneficial to me if I can rewrite the java code in a OO manner in clojure first before making it functional.
07:52clgvaccel: that will cause a lot of overhead
07:52clgvyou could work from small simple task implementing them functional to the more complex onex incrementally
07:53minikomihi there!
07:54acceli have a Java function that takes two constructors. Animal(Foo foo); Animal(Bar bar); how do I tell clojure to call Animal. on Foo ?
07:54minikomijust got rolling with clojure on arch linux, using rxvt, but the repl seems a little strange.
07:54clgvaccel: typehints
07:54minikomii installed jline, but deleting removes the user=> prompt
07:54clgvlike: (Animal. ^Foo obj)
07:54accelclgv: noted; thanks
07:55rabblerminikomi: JLine behaves poorly for me too, on OS X Lion. I haven't really looked into it. Hopefully someone has a tip.
07:55minikomiah..
07:56clgvI recommend rlwrap instead of JLine
07:56rabblerthe previous (0.9.x something) works better for me.
07:56minikomiclgv: thanks I'll look into it
07:56rabblersame here.
07:59rabblerclgv: well, that just worked for me… Thanks. Will read the docs for more info.
07:59clgvrabbler: there is a wikibook for clojure that explains a good rlwrap setup
08:00rabblerclgv: will google.
08:00minikomiclgv: on it right now :P
08:00minikomishould have known to rtfm haha
08:02gtrak```minikomi, why not just emacs and slime?
08:02minikomidiehard vim user :/
08:02minikomibaby steps, baby steps.
08:05accelis there an easy way to inject type checking assertions into clojure?
08:05accelto have exceptions thrown when an function gets an argument that is not of a certain type
08:05gtrak```:pre
08:05rabblergtrak```: I still can't get my head around emacs. One issue I have is that it's just so fugly and feels overly complex to me. Plus, I just can't seem to ever get it to work. I wish there were a github fork of emacs with all settings ready for Clojure users.
08:05accelI love how clojure's anser to everyhting is a function.
08:06rabblerI can't figure out why its so much work to get it to function.
08:06rabbleraccel: unless its a value. hah.
08:06gtrak```rabbler, well the emacs-starter-kit is a good start
08:06rabbleraccel: which could be a function, or a native something or other… I'm just joking around here.
08:08rabblergtrak```: I'll look at it again. Its just that I have 3 different machines that need to be configured and each is different. Using a simple repl and a separate editor (vim or IntelliJ) have been fine (for now).
08:08rabblergtrak```:and that sounded redundant…heh.
08:08gtrak```rabbler, yea, some guys don't even go full slime, just emacs and inferior-lisp mode
08:09gtrak```being able to quickly execute stuff without having to copy-paste is a good thing
08:09rabblergtrak```:and whatever 'inferior-lisp' mode is. I haven't googled that term yet.
08:09gtrak```basically a dumb repl in another emacs buffer
08:10rabblergtrak```: Thats what I have been using IntelliJ for. The plugin is clunky and needs work, but it has simple 'select and execute' functionality.
08:10gtrak```vimclojure probably does that too
08:12rabblergram```: One major issue I have with emacs is that I have 3 versions and don't know which to use: Aquamacs, gnu emacs (gui) and the terminal version.
08:12minikomiok
08:13minikomithat setup from the wikibook did the trick!
08:13minikomithanks for that. have a nice evening / day!
08:14gtrak```rabbler, ah, you're on the mac, yea, no idea
08:14gtrak```though people do it here all the time
08:14gtrak```i think no one uses aquamacs
08:15rabbleri'll look around. Thanks.
08:16clgvgtrak: I saw aquamacs in a couple of videos. the last one was about midje,
08:17gtrak```I heard things to that effect, I don't have any data :-)
08:18gtrak```but you don't really need the gui anyway after a day or os
08:18gtrak```so(
08:18gtrak```so* :-)
08:19accelwhat sodes the % do in clojure? it looks like a way to create anonymous functions
08:19acceli.e. even shorter than fn
08:19gtrak```% is a shorthand for a parameter
08:19gtrak```,(#(+ 1 %) 2)
08:19clojurebot3
08:19duck1123accel: you can use :pre and :post checkers to assert types, but you're still trying to impose strongly-typed ideals onto clojure's dynamic types
08:20gtrak```accel, #( actually makes the anonymous fn
08:21accelduck1123: I'm not trying to build haskell. I just wish to catch run time errors when they happen (rather than when it crashes).
08:21gtrak```accel, you would rather get a IllegalArgumentException than a NullPointerException? what's the difference except more code?
08:22accelI want to get the error when I _store/pass_ an object of an inappropriate type
08:22accelnot when I retrieve/use the object.
08:22gtrak```ah, I guess it makes sense there
08:22gtrak```but that's what you get for using mutable state :-)
08:23accelPerhaps I am doing somethign wrong here: imagine the stack frames of clojure. At the top post frame, we use the argument; 7 layers lower is where we call the function.
08:23accelI want to catch it when I pass the argument; not when I use it.
08:23gtrak```yea
08:23accelgtrak```: In this paritucar case, I don't have mutable state; I just have nested functions.
08:23gtrak```well, you should sanitize user-input, then assume that everything's fine past that barrier, imo
08:24duck1123accel: http://clojure.org/special_forms#Special%20Forms--%28fn%20name?%20[params*%20]%20condition-map?%20exprs*%29
08:24gtrak```just do that kind of stuff in the top layer
08:26accelduck1123: In addition, % may be used in a post-expr to refer to the function's return value. <-- got it. Thanks :-)
08:27gtrak```accel, I guess the issue I have with it is you're conflating (I'm starting to get annoyed with complect) interface with implementation details, clojure's function signatures care about data structures and parameters, not so much concrete types
08:28accelgtrak```: what's complect?
08:28gtrak```a word Rich Hickey made up to mean to interleave two things unnecessarily :-)
08:28gtrak```it's become very popular for some reason :-)
08:29duck1123"To join by weaving or twining together; interweave."
08:29duck1123it's latin
08:29mdeboardgtrak```: Because it's very apt
08:29mdeboardA much-needed word
08:29gtrak```how's it different from conflate, tho?
08:29mdeboardmuch-needed/underutilized
08:30accelhonest queston: since I can't specify type signatures on the input/output of a clojure function; what is the signature of a clojure function besides arity?
08:31mdeboardgtrak```: Because the common usage of conflate, at least as I usually hear it, is as a synonym for confuse. Regarding two different things as essentially the same thing, or two parts of the same whole. Where as complecting, to me, is the active process of unnecessarily joining two things together.
08:31gtrak```accel, the java arity is behind the scenes, the clojure arity is just another case of structure
08:32gtrak```mdeboard, ah, I guess that's persuasive
08:33gtrak```accel, you can even do named parameters if you like, it's basically building a hashmap from the varargs
08:34mdeboardgtrak```: Here is an excellent real world example that I'm dealing with atm. A Django project I work on has several template files that consist entirely of Javascript, except that some of them have Django's template language mixed in. Some javascript files are saved as .html; Some HTML files are saved as .js files. We had until recently (after I fixed it) a file called "pager_js.html" which was a javascript module th
08:34mdeboardat rightly should've been called "pager.js" but the previous developer had conflated the template scheme, javascript and HTML into one big horrible hairy mess. That to me is conflation (and I said as much in the commit message fixing it). Complecting doesn't fit there, IMO.
08:35mdeboardAnyway.
08:35gtrak```ah
08:36gtrak```accel, http://stackoverflow.com/questions/3337888/clojure-named-arguments
08:36gtrak```accel, I would just say, generally stick with a hashmap, vector or seq except for really low level stuff
08:37accelHow does this help me solve my problem of "types do not match?"
08:38gtrak```I don't really understand why they wouldn't match, I guess I'm talking about that problem
08:38gtrak```you already have the answer with :pre
08:39accelIn Clojure, can I check that a list of homogeneous w/o running through all elements?
08:40duck1123can you do that elsewhere?
08:40accelC++ sure; std::list<int>
08:40accel:pre seems a bit expensive on complicated structures
08:41accelif I have to traverse the entire structure to check whether it satisfies typing constraints
08:41accel[I realize this soudns trolling ish; but I'm writing a large0ish WYSIWYG editor; and catching errors early is very important to me.]
08:42duck1123but with a c++ list, it's checking as the elements are inserted, so that is still going through the elements (in a way).
08:42accelyeah; but :pre is called on every function call, no?
08:42accelI would very much so like to have the cost occur only once; not every time I check it
08:43clgvaccel: then check when you create that list ;)
08:44accelthis is non-trivial
08:44accelsince clojure is about creating new objects; not modifying existing ones
08:44acceltypes works great when you can attach tyeps to varaible names
08:44acceland modify those variables via their names
08:44accelclojure objects --- new ones are created all over the palce from old ones
08:45clgvaccel: actually you are quite near at modifying existing ones although the old ones dont change ;)
08:45accelmy point is that suppose oldList = homogeneous
08:45accelthere's nothign taht says newList = (conj elem oldList) should be homogeneous
08:45accelwhereas oldList.add(elem) implies elem should be homogeneous of the same type as oldList
08:46clgvaccel: I think you thinking is quite natural when comming from java, but not very well suited to work with clojure unchanged
08:46duck1123you could write a function that checks the type, and adds to the list only if it satisfies your requirements
08:47duck1123you can always use straight up java arrays
08:47Chousukeisn't oldList.add() heterogeneous too.
08:47clgvaccel: as well, you can make this list a deftype with a modification protocol where add-method checks the type like duck1123 suggested
08:47Chousukesince you only add Objects
08:48Chousukethe compiler might do some type checking but that won't stop someone from giving you a heterogeneous list.
08:50Chousukeaccel: the best way to go about this is just assume the list is homogeneous and document the requirement. Also you can write some tests if you want to :P
08:52clgvaccel: I think you have the two option: (1) expensively checking the list on top-level (2) assuming the list is valid, letting the bottomlevel throw on error and implementing a handler for that in the toplevel to signal a more specific error to the caller
08:53ChousukeI suppose you could write your own typed list structure too
08:54Chousukethat implements conj in a way that checks the type of the arguments
08:54accelhmm
08:54accelwhy not put clojure's ability to generate java clsses on the fly to good use? :-P
08:55Chousukepretty much all type checking you do must be runtime though.
08:55Chousukeunless you want to go ahead and implement that predicate-based static checking tool/sufficiently smart compiler that has been sometimes discussed :P
08:56gtrak```it's just the wrong approach for clojure, you should be able to trust the code you write to work correctly, but you have to sanitize input from the outside.
08:56ChousukeThere's nothing that really prevents Clojure from having static checking
08:56Chousukeit's just not implemented :P
08:56clgvChousuke: isnt someone trying to build that on a clojure fork?
08:56ChousukeI'm not aware of anything like that
08:57clgvsomeone mentioned it here in #clojure
08:57duck1123Sometimes, if you find that Clojure is making what you want to do difficult, you have to ask if you're really going at it the right way.
08:58clgvChousuke: one could even build some of the typechecking via macro like specialized defn-something...
08:58Vinzentwhat's the most idiomatic way to get the string without last n characters?
08:59gtrak```we'd need a generics library like java's
08:59Chousukeclgv: yes.
08:59Chousukeclgv: have you seen typed racket?
08:59gtrak```protocols, covariance
09:00ChousukeVinzent: just make a substring. though beware, the whole string will remain in memory.
09:02VinzentChousuke, ok (I thought maybe there is some special fn for that)
09:03gtrak```accel, really you should be using lazy seqs anyway :-), running through it to check the type is bad for laziness
09:03duck1123Vinzent: I think there used to be a contrib fn for that, but it didn't make the cut
09:05duck1123Vinzent: http://clojuredocs.org/clojure_contrib/clojure.contrib.str-utils2/butlast
09:06Vinzentduck1123, thanks, but it's contrib and I have clj 1.3 project
09:06duck1123Vinzent: just look at the source, if you ignore the if part of the code, it's just a simple .substring
09:08Vinzentduck1123, ah, I've already written .substring version, just enlarging my knowledge :)
09:11CmdrDatsdoes this work? ##(let [string "hello world" len 5] (apply str (take (- (count string) len) string)))
09:11lazybot⇒ "hello "
09:11CmdrDatsthat was fun :)
09:13VinzentCmdrDats, use drop-last then
09:14CmdrDatsawesome - learn something new everyday
09:14CmdrDatsthanks
09:15duck1123also, the built in .substring is surely more efficient than converting the string into a sequence of characters and then building it up into a string again
09:16Chousukeunless you're chopping a huge string into many small strings.
09:16Chousukesince creating a new string will allow the huge one to be GC'd
09:17CmdrDatsye, i was just thinking 'idiomatic clojure'
09:17duck1123does substring prevent the original from being GCed?
09:30clgvChousuke: no not yet. is "typed racket" A LIB?
09:30Chousukeyes
09:31clgvok, google on^^
09:31Chousukeit extends the racket language by adding static typing.
09:31Chousukeit's pretty cool
09:36clgvll
09:57TimMcduck1123: Yeah, we discovered that here at work. >_<
09:58TimMcduck1123: Tokens were taken via substring from documents and used in a hash table. As long as the hash table was around (i.e. forever), all the documents were too.
09:59duck1123TimMc: that's interesting. I'll have to keep that in mind
10:01TimMcIt would be awesome if there were some kind of java.lang.ref.WindowReference wherein if that was the only type of reference to an object, the GC would ask all the holders to compute explicit copies of the information they were using from the main object.
10:02TimMcOr maybe that would be hella complicated and not all that much of a gain.
10:03samaaronTimMc: sounds fancy, but i have no idea what you are talking about.
10:03samaaronwhat would be the problem it is trying to solve?
10:04TimMcsamaaron: substring and subvec hold a reference to the original, possibly much larger data structure.
10:05TimMcI'm trying to solve the problem of having to create copies every time you take a relatively small window on a large data structure.
10:05samaaronmakes sense
10:09misfoDoes anybody familiar with moustache know why ring's wrap-session wouldn't work within a nested `app` macro?: https://gist.github.com/1506329
10:11gfredericksare there any built in functions for translating between native JS data and CLJS data?
10:11gfredericks(or equivalently, cljs<->json)
10:22kralare there any libraries for iptables/ipfilter for clojure?
10:23kralalready googled it, but I found nothing
10:30samaaronkral: there should be some java iptables/ipfilter libs you can just use
10:31samaaroni.e. a quick google search returned this: http://jipfire.ilug.gr/
10:36simardis there a function that does this: (doall (map ..)) ?
10:37samaaronsimard: no, you need to compose the fns like you indicated to force the lazy seq to be evaluated
10:37samaaronare you looking to get the actual returned seq, or are you just running this for the side effects?
10:37simardside effects (spit)
10:38samaaronwell, then you should use dorun instead of doall
10:38duck1123there's always doseq
10:38samaarondoall holds onto the head and therefore consumes more memory
10:38simarddorun, doall, doseq.. ok :)
10:39samaaronuse the one that fits best :-)
10:39samaaronalthough only use doall if you want to do something with the returned seq
10:39gfredericksfor some reason doseq feels like the side effects are less hidden
10:41samaarongfredericks: that shouldn't be the case - doseq is explicitly for generating side-effects :-)
10:42samaaronin fact, all the do* fns are about doing stuff now
10:42gfredericksum...yes. I think what I meant is that you have a body instead of an impure function
10:43simardso the difference between dorun and doseq is only with respect to the usage of it, ie.: doseq provides for like synthax ?
10:43gfrederickssimard: yes
10:43gfrederickssimard: so doseq is better if you would otherwise be creating an anonymous fn
10:44gfredericksI like it better in any case, but people must use dorun for something, so I probably don't know what I'm talking about
10:44simardlol
10:44simardwell, thank you for your help
10:45semperosit's been a while since I've used clojureql, but I recall it having a dedicated site with good documentation (clojureql.org, I believe), but that seems down
10:45semperoshas it been replaced by something else?
10:46cemericksemperos: the original maintainer has moved on, I think.
10:46cemerickMany people are moving to http://sqlkorma.com AFAICT.
10:46semperosanother of ibdknox's creations, yeah?
10:46cemerickyeah
10:46semperosalrighty
10:47semperosI saw that Lau didn't put out the latest artifact release of clojureql
10:47cemerickThere are people still working on clojureql, but there's some uncertainty at this point, anyway.
10:47semperosbut its docs still point to that clojureql.org site
10:47replacacemerick: did Lau leave us? I had noticed that I hadn't heard much from him in a while
10:47cemerickreplaca: He's here (hi LauJensen), but perhaps not present?
10:54jakeskikcemerick: Hmm..any idea how one would handle migrations with clojure? Is there something like rails (= ActiveRecord) migrations?
10:54semperosjakeskik: this has migrations support: https://github.com/budu/lobos
10:54cemerickjakeskik: I'm absolutely not the person to ask about RDBMS stuff. :-)
10:54jakeskiksemperos: thanks
10:54jakeskikcemerick: hehe, ok :)
10:54semperosand conjure has its own as well, worth a look
10:55jakeskikty, i'll take a look
10:55semperosnp
10:57Vinzentsemperos, clojureql with 1.3 support was released yesterday, so the project surely isn't dying or anything
10:58semperosVinzent: I figured it wasn't dying; my question was about the documentation's current home
10:58semperoscouldn
10:58semperos*couldn't find the main body of examples and nice docs that used to be at clojureql.org
10:59ejacksonjakeskik, semperos : They've just pulled the migration side of thinsg out of Conjure and into its own library http://github.com/macourtney/drift
10:59jakeskikah, nice
11:01Vinzentsemperos, ok, just to be sure that people don't think anything like that about clojureql :) I haven't found the source for the site too, so I'm using version from the yandex cache now: http://yandex.ru/yandsearch?text=clojureql&amp;site=clojureql.org&amp;clid=46510&amp;lr=11108
11:01Vinzentlooks like google already removed it from the index
11:01semperosyes, they have
11:03semperosVinzent: thanks for the link to the yandex results
11:03mrb_bkI'm a clojure noob -- if anyone feels like ripping apart some clojure code, here's something small I'm working on: https://gist.github.com/1504840
11:04mrb_bkRight now it validates that a Redis .rdb dump file is in fact a dump filee
11:04mrb_bkAny comments appreciated
11:05Vinzentsemperos, np. Is it possible to have these pages on clojureql.github.com? Or some actions from repo's owner (Lau) required to do that?
11:06semperosowner would need to do that, as far as I know
11:06semperosit can be added to its wiki, for now
11:06Vinzentyeah, better than nothing
11:06semperosbetter than sending folks to a Russian search engine :)
11:06semperosfor cached copies
11:07Vinzenthah, sure :)
11:07kumarshantanusemperos: Vinzent: One good thing may be to setup a Google group for ClojureQL (just an idea)
11:08semperosprobably something better started by the folks who maintain it
11:08jhirnm4b_bk: you might want to look at clojure.java.io instead of using interop for Files http://richhickey.github.com/clojure/clojure.java.io-api.html
11:08lazybotNooooo, that's so out of date! Please see instead http://clojure.github.com/clojure/clojure.java.io-api.html and try to stop linking to rich's repo.
11:08Vinzentmrb_bk, I didn't actually read the code, but it's a good style to use ;; instead of ; in your code (; for inline comments)
11:08jhirnor, what lazybot sait =)
11:09licenser_Raynes: I love you for lazybot saying that
11:09mrb_bkThanks everyone
11:09mrb_bkI couldn't get clojure.java.io to read bytes easily
11:11jhirnI like lazybot for that too. I always end up on the wrong doc page.
11:11jhirnNow I know.
11:12jhirnI need to just remember to use clojuredocs.org
11:12mrb_bkjhirn: So you're saying I should use make-input-stream?
11:13jhirnmrb_bk... I think so . Experiment with calling class on what it returns. I beleive it might return an InputStream.
11:17gfrederickswhy does my clojurescript code clobber the $ variable?
11:20Vinzentsemperos, do you know is bendlas hanging here? Seems like he is the most active maintainer and I can't send him a message on github
11:20semperosI don't know
11:22ejacksonVinzent: he posted to the list recently
11:24ejacksonactually, you replied to his email :) He's Herwig.
11:26triyoWhat would be the cleanest way to have a config clj file that contains some global vars (*is-prod*, etc.). These globals in config file are populated from the command line args when the program's process is launched.
11:26triyoMaybe there is a better way to do this all together.
11:31semperostriyo: you can define your "global vars" in you regular source code
11:31semperosthen as part of your CLI handling (suggest clojure.tools.cli if you're not using it) you can change the value of those var's
11:32triyosemperos: right, I am using CLI :)
11:32triyoits great
11:32semperose.g., doing a (swap! *is-prod* value-from-command-line) if you're using atoms for those
11:32triyoso I have a config.clj and it contains *is-prod*, *webapi-host*, etc.
11:33triyoAnd the CLI lives in the main.clj
11:33semperosyour config can just be a clojure map
11:33semperossoemthing like {:env "prod", :host "localhost"} etc
11:33semperosyou can use the (read) fn to read that map as a Clojure datastructure straight from the file
11:34triyofor sure, thats true... However what is the best way to set this *config-map* that lives in config.clj so the entire app in this running process has access to it
11:35triyoSo here is the scenario...
11:35semperosposting what you have in a gist might also help
11:36triyoShell -> java -jar myapp.jar --env prod --host xxxx --port 8000
11:36triyomain.clj makes sense of args via CLI
11:36semperosright, which gives you an options map including {:env "foo" :host "foo"}
11:36triyoand then it sets the config.clj global *config-map* to what was passed in.
11:37semperosif config-map is an atom, for example, you can just do (swap! *config-map* options), with options being the options that c.t.cli gives you from parsing the command-line arguments
11:38triyoNow, when a part of my app calls, myapp.config/*config-map* or even better, one of its accessors function (production?), it gets what was passed in when process was started
11:38Vinzentejackson, ah, it was he :)
11:38semperosright
11:38triyosemperos: I'll give it a try..
11:38semperosI understand what you're trying to do, not sure where your question still is
11:39triyoDon't think there is one, guess I'm just thinking out loud now ;)
11:39semperosalrighty
11:39semperosno harm there
11:50semperosexamples of what specs look like with clojure.java.jdbc/create-table ?
11:51semperosnm: http://en.wikibooks.org/wiki/Clojure_Programming/Examples/JDBC_Examples#Creating_a_Table
11:57ibdknoxI wish ddl stuff weren't such a disaster
12:31CmdrDatshey everyone - I'm needing to create a fairly simple queue system to get forms to run in a GUI thread
12:32CmdrDatscurrently, I have an action-list ref, a simple enlist function that conj's a form onto it and a handle-actionlist! function that pops the forms off and evaluates it (which i run from the main thread)
12:32CmdrDatsdoes that sound like an ok solution?
12:36amalloyCmdrDats: sounds like you've reinvented agents using refs
12:37CmdrDatsye :/ but i'm not sure how to make an agent run in a pre-existing thread
12:37CmdrDatsI'm working on the jMonkeyEngine - it hands me a thread and says 'only make changes to the scene on here'
12:38cgrayany idea why this snippet https://gist.github.com/1506911 doesn't work properly? it's not appending to the end of the file -- just overwriting the file every time the fn gets called
12:39amalloyyeah, i thought that might be the case. i don't think you can really do that with an agent
12:41CmdrDatsok, cool - thanks - was hoping there was something i didn't know about
12:45cemerickcgray: FileOutputStream overwrites by default
12:45cemerickuse (FileOutputStream. "path" true)
12:45cgraycemerick: yeah, I figured it out...
12:45cgraythanks though
12:54choffsteinAnyone familiar with congomongo and know how to fetch an entry by id value and not an id object? I am trying to seriealize an id object to a redis queue and can't seem to do it, but also can't seem to fetch by the value of the id -- I need to recreate the object somehow
12:57ddudeyI've done this recently, I think you can fetch where :_id is whatever you want
12:59ddudeyOr do a (ObjectId. "xxxx") to get an object for value
13:01TimMctry-CLJS sucks a little less now; it can evaluate (clojure.core/first (clojure.core/map clojure.core/+ [1 2] [300 500])) correctly.
13:02TimMcAlso, def and defn work.
13:02choffsteinddudey: Yeah, I feel like an idiot. just saw `object-id` in the congomongo source
13:20choffsteinGeneral design question: I am trying to build a web API on top of Ring that takes a request, checks if the answer exists in a MongoDB, and if it doesn't, fires off a job on redis (via resque) and then tries to read the result from MongoDB, eventually timing out with an error if it doesn't find the result. My questions are, 1) What is the best way to poll without hammering the DB? Can I sleep the Thread? 2) Can I set it up so that while I am polling
13:20choffsteinDB, I am not blocking?
13:20gfrederickschoffstein: for 2) I think you want to use aleph?
13:20gfredericks
13:21choffsteingfredericks: Like … with wrap-aleph-handler?
13:22gfredericksisn't that the one that does synchronous responses?
13:22gfrederickswhich would defeat the purpose of using aleph
13:23gfrederickschoffstein: the point is that aleph (I think) ignores the return value of your handler function, but gives you a mechanism to respond later. Thus you're not blocking.
13:23choffsteingfredericks: Gotcha. Hmm, I'll check it out
13:24gfrederickschoffstein: relevant docs here: https://github.com/ztellman/aleph/wiki/HTTP
13:24choffsteinthanks
13:27gfredericksdo cljs doc-strings do anything that comments don't?
13:28gfredericksI guess they're easier for code-reading tools to find
13:31cgraygfredericks: I think they put into the output js as comments as well (though I'm not sure that regular comments don't)
13:36semperosusing h2, I've created a table called "events"
13:36semperoshere is my trying to use it with Korma and getting an error about the table not existing:
13:37semperoshttps://gist.github.com/1507124
13:37semperosI've checked the h2 database file with a GUI app and verified that the table does, in fact, exist
13:37semperosand I used the same connection spec to create it in the first place
13:37semperosany thoughts?
13:49CmdrDatsemacs users: how do explore java libraries for method names/import paths?
13:49CmdrDatsI'm using eclipse/netbeans to alt+enter auto-import and then copy and paste the import into my clojure
13:49technomancyCmdrDats: C-c S-i works great on java libraries
13:50technomancyjava classes, rather
13:50technomancythe only thing it's missing is method argument names, but you can see methods, constructors, fields, interfaces, and it's all hyperlinked
13:50CmdrDatshmm, my C-c S-i is undefined
13:50semperosnice
13:50gfredericksthe leiningen README says "You can also include one-off tasks in your src/leiningen/ directory if they're not worth spinning off; the plugin guide shows how."
13:50semperosCmdrDats: are you using slime/swank ?
13:50CmdrDatsye
13:51gfredericksassuming "the plugin guide" is /doc/PLUGINS.md, I'm not sure where it's mentioned.
13:51semperosCmdrDats: I just tried it at a REPL (I use elein-swank to connect) on String and it worked fine
13:51gfredericksis there any documentation on how to do per-project lein tasks?
13:51gfredericks
13:51CmdrDatssemperos: hmm, i'm using slime-connect
13:52technomancygfredericks: hm; looks like it's not addressed specifically.
13:52semperosseems like my Korma issues have to do with case...
13:53technomancygfredericks: oops; got disconnected; how much of that came through?
13:53gfrederickstechnomancy: just you noting that it's not addressed
13:53technomancygfredericks: there's nothing special needed though; you just put the file in src/ instead of in the src/ dir of its own project.
13:54CmdrDatssemperos: if you describe the key (C-h k C-c S-i) what do you get?
13:54gfrederickstechnomancy: okay, so I'll look at the regular plugin docs for the rest of it then; thanks
13:54semperosCmdrDats: reconnecting usine slime-connect...
13:55CmdrDatshaha
13:55CmdrDatsnvm - figured it out
13:55semperosCmdrDats: does slime-inspect
13:55semperosgood
13:55CmdrDatsShift-i
13:55semperosI didn't know about it myself
13:55CmdrDatsnot cmd-i....
13:55semperosyep
13:55CmdrDatss-i = cmd+i on my mac
13:55semperosgood ol' meta keys
13:56CmdrDatsok, but now - i know that KeyTrigger is somewhere in my classpath
13:57CmdrDatsC-c S-i is super handy though, thanks technomancy :D
13:57technomancyit's the best!
13:57CmdrDatshow do i find out what I need to import to get KeyTrigger :/
13:57CmdrDatsbesides heading off to javadocs/netbeans
13:58semperosfor KeyTrigger, what does it say its class is?
13:58CmdrDatsunable to resolve
13:59CmdrDatsi haven't :import'ed it into my namespace
13:59semperosright
13:59CmdrDatsbut in order for me to import it…. i need to know where it is xD
14:00CmdrDatsi've been spoilt with years of eclipse
14:00technomancyCmdrDats: C-c S-i has tab completion
14:00technomancyso if you know its general vicinity it shouldn't be too hard to track down
14:01CmdrDatstechnomancy: that's always the problem though - some libraries are really… interestingly.. laid out
14:02CmdrDatsand then the samples they provide (w/o looking at source code downloads) usually omit import statements
14:03technomancyyeah, that's super-lame
14:03technomancyyou can always try slamhound
14:03technomancyCmdrDats: you can always open the jar file in emacs and do C-s though
14:03CmdrDatshmm, my tab completion doesn't work.. something about fuzzy-complete-symbol being void - maybe i haven't installed something
14:03CmdrDatsi can open a jar in emacs??
14:03lazybotCmdrDats: Definitely not.
14:04technomancylazybot: LIES
14:04technomancyCmdrDats: sure you can
14:04technomancyyou can even edit the bytecode if that's how you roll
14:04CmdrDatshehehe
14:04semperosoption-.
14:04semperosM-.
14:04jodarostraight up byte code editing playah
14:04semperoswill open a jar up and take you to the source
14:05ekoontzthe M-. doesn't work for me tho :(
14:05technomancyI don't think M-. works on classes
14:05semperosah, that's true
14:05technomancyit would be rad if that could run it through javap though
14:06CmdrDatshehe, this is emacs, after all
14:06ekoontzsemperos, what is the long form of it (the M-x ...something)
14:06hiredmanhttps://github.com/hiredman/javap-mode doesn't work on class files in jars yet
14:07hiredmanhttp://www.thelastcitadel.com/images/javap-mode.png
14:07ekoontzinteresting, thanks hiredman for the link
14:07CmdrDatsO.o awesome being able to browse jars!
14:07technomancyhiredman: would be a great holiday-time hack project though, eh? =)
14:08semperosekoontz: slime-edit-definition
14:08semperosdefined in slime.el
14:08technomancyhiredman: did you ever get that on marmalade?
14:08hiredmannope
14:09CmdrDatshiredman: that is awesome
14:10CmdrDatsanyhow - back to binding my little cube to keys so i can start moving it around
14:10CmdrDatsjMonkeyEngine rocks
14:16technomancygfredericks: https://github.com/technomancy/leiningen/commit/579fef7337962a21c764a361040a4f91cb89023a
14:24aravindhi
14:25aravindI am failing at understanding why this won't work, (Math/sqrt 2) works, but (map Math/sqrt [2]) doesn't. I have to do something like (map #(Math/sqrt %1) [2]).. I don't quite understand why..
14:27pandeirois it possible to do (ns foo.core (:use bar.core [baz.core :only baz]))?
14:27hiredmanaravind: seriously?
14:28hiredmanaravind: what is the difference between 2 and [2]? or 2 and {:two 2} or 2 and (atom 2)?
14:28technomancyhiredman: I may be hallucinating, but I think there's a batshit crazy lisp dialect out there that will automatically translate calls like that into map calls.
14:29hiredmantechnomancy: :|
14:29semperosaravind: map takes a function as its first argument, Math/sqrt isn't a function
14:29aravindokay, if it isn't a function, then why does (Math/sqrt 2) work?
14:30semperos(macroexpand '(Math/sqrt 4))
14:30semperos,(macroexpand '(Math/sqrt 4))
14:30clojurebot(. Math sqrt 4)
14:30semperosthat's what's happening under the hood
14:30semperosinterop sugar
14:30technomancyhm; misread that; I was thinking of something that would translate (f [x]) into (map f [x])
14:31technomancywhich I really hope is something I invented in some kind of feverish dream rather than an actual language.
14:31aravindsemperos: ah okay.. I am mistaking java interop stuff as straight supported function calls..
14:31semperosexactly
14:31aravindcool, thank you.
14:31semperosnp
14:31semperosaravind: if you dig deep
14:32semperosyou see that the f needs to have implemented clojure.lang.IFn
14:33semperosusing lobos for schema definition and table creation, anyone know how to set the default column value?
14:33aravindsemperos: how would I have found that on my own? this seems like something I should have known, before begging for help..
14:34semperosthe Java method vs. Clojure function distinction is a common learning point
14:35RaynesAnd it is explained in all of the books and probably that ociweb tutorial.
14:35semperosnot sure there's one "how" to getting that down in all places
14:36technomancyif only clojure.lang.IFn could be a protocol. =(
14:36RaynesNot that I'm criticizing you for not knowing it. It isn't a big deal that you asked. :p
14:36semperosif you're comfy with it, looking at the source never hurts
14:36RaynesIt's what the channel is here for.
14:36semperostechnomancy having more feverish dreams ;-)
14:37gfrederickstechnomancy: how do I use the "src/leiningen" strategy with a different :source-path?
14:37Raynesgfredericks: You can't, IIRC.
14:38aravindRaynes: yup, I read those, but I guess I never made the jump between sytactic sugar and it not behaving like a regular function (when used in map)..
14:38aravindin any case, thanks for the help.
14:38technomancygfredericks: he's right; it's unpossible
14:38gfredericksRaynes: guess it's about time to check out that lein-cljs plugin then
14:38technomancybecause the classpath must be known at launch
14:39RaynesI'm not a big fan of those plugins.
14:39technomancyagreed
14:40technomancyvery few projects necessitate plugins that aren't general purpose
14:40pandeirois it possible to use :use foo and :use [bar :only baz] in the same ns?
14:40RaynesThey just grab a version of cljs and stuff it clojars and are like "here ya go, fresh clojurescript. no worries that critical bugs are fixed every other day, just use this"
14:40gfredericksRaynes: technomancy: you two are talking about different things aren't you? :)
14:40technomancyoh
14:40technomancyyeah
14:40technomancyI'm talking about plugins-in-src/ in general, though I agree re: unofficial cljs packaging.
14:41gfredericksmy imminent issue is that the cljsc script sets the classpath to "src/clj" and "src/cljs"
14:42Raynestechnomancy: I have a plugin internal to tryclj that pulls down my javascript dependencies.
14:42RaynesI guess that could be external and public, but then I'd end up writing a Javascript package manager and I'd have to hang myself.
14:42gfredericksyeah it takes extra work to generalize things
14:43technomancyit's always The Right Thing, whether it's Right for Right Now or not.
14:44gfrederickstechnomancy: xkcd.com/974?
14:44technomancypretty much
14:48Raynesgfredericks: It is illegal to link to something without prefixing it with http:// and thus making ERC link it without having to take a massive regex to it.
14:48gfredericksRaynes: what is the penalty for infringement?
14:48RaynesDeath.
14:49gfrederickswell then I hope my life has been a lesson to all other potential violators. I assume they're all watching right now.
14:49pbuckleyI'm completely deterred.
14:49gfredericksor if not I'm sure my story will be taught in middle schools everywhere
14:50gfredericksthank you Raynes, you have given my life a purpose.
14:51duck1123Here lies gfredericks, he forgot the http://
14:52jodaroprobably preschools by now
14:52jodaro"and remember, children, if you forget the http:// in irc, your mommy and daddy will stop loving you."
14:55duck1123"Daddy, check my closet for Raynes"
15:02gfredericksdoes the cljs compiler assume that all code is in the directory you pass it?
15:06gfredericksit is complaining that my macro ns's are not on the classpath :/
15:12cgraygfredericks: when i was hacking cljs a couple of months ago, i had to put my macros in the cljs source dirs to get them read... it's probably changed since then, but it's worth a try
15:12gfrederickscgray: that's where I've got it
15:12cgrayand it still doesn't work?
15:12gfredericksnope
15:13gfredericksreading the cljsc script, it doesn't put any of the dirs from my project on the classpath
15:13gfredericksso maybe I need to hack it to add that in...
15:13cgraygfredericks: oh, i meant in CLJS_HOME
15:13gfredericksaah
15:15gfredericksI like hacking the cljsc script slightly better, and that seemed to work
15:25KenthHi, I'm on page 92 of the Joy of Clojure book, where they use defmethod and '<- and '-< . I looked up stuff on clojure docs, however they use defmulti before defmethod, there is nothing for -< and <- mentions a datalog rule
15:26KenthCan someone explain what print-method is doing to the queue?
15:26hiredmanthey are adding a print method for the queue type
15:26hiredman,clojure.lang.PersistentQueue/EMPTY
15:27clojurebot#<PersistentQueue clojure.lang.PersistentQueue@0>
15:27Kenthwhy are the arguments split into [q , w] ?
15:27hiredmandoesn't have a nice printable form
15:27hiredmanprint-method part of clojure, and it's arguments are defined there
15:27hiredmanis
15:28hiredmanso if you look through the clojure source you will find the defmulti for print-method
15:28hiredmanor if you just check the metadata for where it is defined
15:30Kenthis there a function to pull the metadata up?
15:30Raynes&(meta print-method)
15:30lazybot⇒ nil
15:30RaynesDuh.
15:30Raynes&(meta #'print-method)
15:30lazybot⇒ {:ns #<Namespace clojure.core>, :name print-method, :line 3253, :file "clojure/core.clj"}
15:30hiredmansurely it's in the joy of clojure
15:33KenthYep, page 71. I forgot about it
15:36jodaroi started putting those sticky tabs on important pages in JofC
15:36jodarobut i ended up stopping cuz like every page seems to have one
15:37jodaroits like when you highlight the whole textbook
15:37jodaroand then you go back to review
15:37jodaroand end up reading the whole thing again
15:42bweaverHello, I'm experimenting with the `checkouts` folder in a leiningen project for the first time. I notice that it adds the sub-project's `src` folder to the CLASSPATH, but not the deps in the sub-project's `lib` folder. Am I doing something wrong?
15:43devinus_how do you guys repeat the last slime line?
15:43gfredericksbweaver: I think you have to have the proj declared as a dep, which presumably means maven is taking care of the indirect deps?
15:43duck1123devinus: M-p
15:44devinusduck1123: what about the opposite?
15:44duck1123M-n
15:44devinussweet, thanks
15:44bweavergfredericks: Oh, so if I have `checkouts/sub-project` I need to add `[sub-project "x.y.z]` to my `:dependencies`?
15:44duck1123also, if you start typing part of the line, it'll go through lines that match what you typed
15:44gfredericksbweaver: yep
15:45gfredericksbweaver: I don't know if it reads the sub project's project.clj or not
15:45gfredericksbweaver: from the lein readme: "Note that this is not a replacement for listing the project in :dependencies; it simply supplements that for tighter change cycles."
15:45duck1123The checkouts folder is if you're hacking on a dependency of a project. It save you from constantly having to install, change directories then deps
15:45bweavergfredericks: I was wondering what that meant...
15:46bweavergfredericks: Looks like if I add `[sub-project "0.1.0"]` to my `:dependencies` and to a `lein deps`, it blows up trying to fetch `sub-project` from a remote repo :(
15:47bweaverThings seem to work OK if I hoist sub-project's dependencies up into the `:dependencies` of the parent project. That just seems a little messy so I thought I might be doing something wrong.
15:47duck1123bweaver: install the sub-project at least once
15:48gfredericksduck1123: would he have to install it whenever the sub-project's deps change?
15:49duck1123no, lein is going to try to download the deps like normal, so it has to be in your ~/.m2, once that's done, it'll use the checkouts copy
15:49bweaverduck1123: aha, thanks
15:50bweaverThat makes sense, the `checkouts` folder is a trick. It just shadows the jar in `lib` by being earlier on the CLASSPATH.
15:50bweaverAnd `lein install` on `sub-project` allowed `lein deps` to run successfully.
15:50bweaverThanks!
16:00technomancyeveryone is confused about checkout deps, and I can't figure out why
16:01hiredmantechnomancy: I got your back
16:02technomancyhiredman: time for a factoid?
16:02technomancymaybe calling it "checkout dependencies" is confusing because it implies that the checkout is a dependency declaration?
16:02brehauttechnomancy: is that like a non-polymorphic factad ?
16:03hiredmanco-dev-dep
16:03technomancyprobably
16:05technomancyhiredman: what about just "checkouts"?
16:05technomancytoo vague probably
16:07gfredericksfun fact: clojurescript causes a bug in the underscore library, which assumes that strings don't have a 'call' method
16:09Raynesgfredericks: Fun fact: ClojureScript is a bug. :P
16:09gfrederickssquish it!
16:09Raynes~guards
16:09clojurebotSEIZE HIM!
16:12TimMcRaynes: I believe it.
16:13kotarak~suddenly
16:13clojurebotBOT FIGHT!!!!!111
16:13kotarakNot CLABANGO anymore?
16:14gfrederickskotarak: probably does that too?
16:14gfredericks~suddenly
16:14clojurebotCLABANGO!
16:14blakesmithRaynes: I haven't played with ClojureScript yet, but I'd like to hear more about what you don't like about it.
16:14kotarakgfredericks: ah. there it is. :)
16:15Raynesblakesmith: I was just being annoying.
16:15gfredericksblakesmith: he didn't say he didn't like it, just that it's alpha
16:15RaynesIt's kind of buggy, but it's also kind of brand new and thus understandably kind of buggy.
16:15jodarono excuse!
16:15jodaroall clojure is to be bug free the instant it is written
16:16TimMctechnomancy: Rename the "checkouts" folder to "symlinks-to-projects-you-already-have-listed-in-dependencies".
16:17blakesmithI just assume all developers don't like bugs. ;-)
16:17TimMcblakesmith: It is extremely alpha.
16:18technomancythere is a sense in which software that "feels polished" is less likely to get patches because users are more likely to assume that quirks are intentional.
16:18jodaroTimMc: derive worked exactly as i needed it to, thanks again
16:18technomancyOTOH with core's attitude toward contributions this seems unlikely to apply to clojurescript.
16:20TimMcCLJS is more like... rosh, or some other Phoenician letter. Pre-alpha.
16:21devinusanybody know how to kill and restart slime without killing emacs and jacking-in again?
16:22technomancyM-x clojure-jack-in
16:24TimMcas many times as necessary
16:24TimMcjust like LaTeX
16:24gfredericks~rimshot
16:24clojurebotBadum, *ching*
16:25devinustechnomancy: thank you. btw, did you happen to see my last comment in https://github.com/technomancy/swank-clojure/issues/88 ?
16:25technomancyyeah, not sure what's going on there
16:25devinustechnomancy: this is in both my OS X and Ubuntu environement (both Emacs 24). i'm willing to do w/e it takes to help debug this
16:26technomancydoes it happen if you use -Q to skip all your personal config and load just the stock clojure-mode plus that snippet?
16:26devinustechnomancy: all i have in my personal config is this snippet :P
16:26devinusother than i'm using emacs starter kit
16:27technomancyhmmmmm
16:27devinusfrom marmelade
16:27devinusi'm not sure how it fixed it for that one dude
16:27devinusweird that it fixes it for one person but not me, even though we had the exact original problem
16:27devinus:-/
16:28technomancyhow recent is your 24 build?
16:28devinustechnomancy: very recent. most recent build in OS X from http://emacsformacosx.com/builds
16:28devinuson Ubuntu i use emacs-snapshot PPA package
16:29devinusto be honest I don't mind having hackish elisp in my .emacs. i just hope it's not indicative of a larger problem, you know?
16:29devinusotherwise i honestly could care less
16:31technomancyyeah, unfortunately I have no idea why your setup would behave differently
16:31devinusi'll keep an eye out as i upgrade emacs versions
16:32devinusmaybe track it down
16:45devinustechnomancy: starter-kit-lisp automagically turns paredit on for clojure code?
16:46technomancyright
16:47devinusthat's hot
16:47technomancynecessarily
16:57zdodAnyone in NYC know if the Clojure Meetup is happening tonight at Google?
17:28technomancyo_O
17:28technomancyweavejester: may I interest you in a https://github.com/technomancy/s3-wagon-private ?
17:29weavejestertechnomancy: That looks interesting!
17:30technomancyweavejester: better than dumping it on clojars anyway =)
17:30weavejestertechnomancy: For open source stuff?
17:30technomancyyou don't even necessarily need to make it private; that plugin works for public s3:// repos as well.
17:30weavejesterI can see it being really useful for private repos!
17:31weavejesterBut does it have any advantages over Clojars for public ones?
17:31technomancyweavejester: well I assume dep-a and friends are not real dependencies but some kind of test, right?
17:31technomancyso s3 has the advantage that you can delete them when you're done testing
17:31weavejesterOhh, right!
17:32weavejesterDuh, yeah, sorry, I didn't put 2 and 2 together there.
17:32technomancyheh; sure
17:33weavejesterI was just trying to figure out whether it's better to specify [org.clojure/clojure "1.2.1"] or [org.clojure/clojure "[1.2.1,1.3.0]"]
17:35technomancyI'd go with the latter if you're trying to communicate to consumers that you're targeting both versions
17:35weavejesterWell, the problem with the latter is that it's saying 1.3.0 maximum, no exceptions.
17:36weavejesterSo if Clojure 1.3.1 comes out, you wouldn't be able to use it with a project that specifies a Clojure version of [1.2.0,1.3.0]
17:36technomancyfor a library or for an application?
17:37weavejesterFor a library. A dependency
17:37technomancythe thing about specifying a dependency on Clojure in a library is that practically speaking it is always a mechanism for communicating to the author of an application
17:37weavejestere.g. If B 1.0.0 => A [1.0.0,1.1.0]
17:37technomancyit has no bearing on what version of Clojure will actually be used
17:38technomancysince the consumer will always pick that, and the version they specify will take precedence
17:38weavejesterIs Clojure treated specially?
17:38technomancyno, but Clojure is the one thing that consumers are guaranteed to declare a dependency upon
17:38weavejesterOkay, so I ran some tests...
17:39technomancythe more direct declarations always win
17:39amalloyif you want to allow 1.3.1, you can specify [1.2.0,1.4.0)
17:39weavejesterApparently not.
17:39weavejesterI ran a few tests...
17:40weavejesterI had B 1.0.0 depend on A [1.0.0, 1.1.0]
17:40weavejesterAnd if I included two dependencies in a new project
17:40weavejesterA 1.1.1 and B 1.0.0
17:40weavejesterThen I got A 1.1.0 and B 1.0.0
17:41weavejesterI tried swapping round the order of dependencies too
17:41weavejesterSame result
17:41technomancywow, really?
17:41weavejesterThe [1.2.0,1.3.0] syntax ensures that 1.3.1 is never chosen
17:41weavejestertechnomancy: Unless I've made a mistake... but I double-checked
17:41technomancylemme see if I can repro
17:42weavejestertechnomancy: I'd appreciate it if you could. It's a really weird result.
17:43TimMcI think "1.3.0" is a soft requirement, and "[1.3.0]" is hard.
17:43technomancyyeah, it may be that the range is given precedence because it's considered more specific
17:43amalloyright. "1.3.0" means "I'd like 1.3.0 but am willing to try whatever you want"
17:43weavejesterYeah, but I'd expect that a more direct dependency to override
17:44amalloy"[1.3.0]" is: this library will not work with any version but 1.3.0, refuse to build
17:44weavejesterSo if I specify A 1.1.1 and B 1.0.0, I wouldn't expect A 1.1.0 and B 1.0.0
17:44weavejesterI'd expect A 1.1.1 to be the nearer dependency and override B's dependency of A [1.0.0, 1.1.0]
17:44amalloyweavejester: if your main project asked for [1.1.1], then you wouldn't get an override
17:44amalloyyou'd get a build failure instead
17:45amalloybut if you ask for 1.1.1, you're agreeing to let maven do its best
17:45weavejesteramalloy: I'm saying if a *dependent* library asks for [1.0.0,1.1.0]
17:45amalloyuh huh...
17:45weavejestere.g. B depends on A [1.0.0,1.1.0]
17:45pandeirois the (some #{foo} my-vector) idiom the fasted way to test a vector for a specific value?
17:46amalloyand your project asked for 1.1.1, right?
17:46weavejesterAnd C depends on A 1.1.1 and B 1.0.0
17:46amalloyor C does, whatever
17:46technomancywow, ok... I'm swearing off ranges.
17:46weavejesterThen in my lib directory for C I get A 1.1.0 and B 1.0.0
17:46technomancythis is just too confusing.
17:46weavejestertechnomancy: Got the same result?
17:46technomancyyeah
17:46amalloybut it's not in brackets: C is saying it's willing to try other versions
17:46amalloyi agree it's kinda a dumb system, but the results are consistent with the meanings of [x,y] and x
17:47weavejesterYeah, it makes sense...
17:47weavejesterBecause B is saying "I will *only* accept versions between 1.0.0 and 1.1.0"
17:47weavejesterBut in practise I'd like a nearer dependency to override it.
17:48weavejesterI wonder what happens if C tries to force it with a "[1.1.1]"
17:48technomancyseems crazy to implement that without a way to say "no really, ignore the fact that this certain dependency doesn't know about this newer version that it happens to be totally compatible with"
17:48amalloyweavejester: build failure, i think, which is what i said earlier
17:48weavejesterYeah, build failure
17:48technomancy"The artifact has no valid ranges"
17:49weavejesterIt is pretty crazy.
17:49weavejesterIf you had specified a library to work with Clojure [1.1.0,1.2.0] for instance
17:49weavejesterThen you couldn't use Clojure 1.2.1 in any dependent project.
17:50technomancyright; there's no way to know whether future versions are backwards-incompatible or not, so it's crazy to declare an upper-bound unless an incompatible version has already been released.
17:50technomancyin which case you should just upgrade your code. =(
17:51amalloytechnomancy: of course, if semver were unversally followed, you could know some versions won't be compatible
17:51amalloybut i don't think any projects out there actually follow semver to the letter
17:52technomancyamalloy: sort of. a library could still introduce a breaking change in a namespace you don't use.
17:52amalloysure
17:53weavejesteramalloy: The problem is that if a dependent project releases a new patch version, if you use hard version ranges, no-one can you your project with the new patch version
17:53weavejesteramalloy: Even if it was sematically versioned correctly
17:54amalloyweavejester: [1.0.0,2.0.0)?
17:54amalloyi mean, i recognize version ranges have serious issues
17:54weavejesteramalloy: Doesn't that mean 1.0.0 <= x < 2.0.0 ?
17:55weavejesteramalloy: Ohhh. I see what you mean.
17:55amalloyyes. so their patch version would go from 1.0.0 to 1.0.1
17:55TimMcExcept that doesn't work.
17:55amalloybut the free-for-all approach of "i want 1.3.0, but i'll try anything once!" has issues too
17:55weavejesteramalloy: Yeah, so breaking changes involve changing the major version in sematic versioning.
17:55TimMcIf you do [1.2.0,1.4.0), you'll get 1.4.0 alphas and/or SNAPSHOTs.
17:55amalloyTimMc: ewwwwwww
17:56TimMcYup.
17:56weavejesterTimMc: Ah, good point!
17:56TimMcI was all :sadface: when I discovered that.
17:56amalloyjesus. [1.2.0,1.3.4654321564567]
17:56TimMcHaha, yeah.
17:56TimMc1.3.9999999999999999999999999
17:57amalloysee if you can find an Integer.parseInt bug in maven
17:57brehautyou guys have made me paranoid that ive got bad version strings now
17:57brehautim using in my one publicly released library "[1.2.1],[1.3.0]" is that great badness?
17:57amalloybrehaut: at least it's a big club you've just joined
17:58brehautamalloy: lol :(
17:58amalloywait what does that range even mean
17:58brehautamalloy: i *think* it means either 1.2.1 exactly, or 1.3.0 exactly?
17:58TimMcI think Maven provides a way to override dependencies' version requirements.
17:58SomelauwIs read-string considered a safe function or is it as dangerous as eval?
17:59brehauti went spelunking a while ago and came back with the first thing that worked
17:59SomelauwShould it be used on user input?
17:59weavejesterI'd have just gone with "1.2.1"
17:59technomancySomelauw: you can disable read-eval
17:59TimMcSomelauw: ##(read-string "#=(+ 1 2)")
17:59lazybotjava.lang.RuntimeException: EvalReader not allowed when *read-eval* is false.
17:59brehautSomelauw: if you have *read-eval* set to true its dangerous, otherwise safe
17:59amalloySomelauw: it's as unsafe as eval, unless you turn off that feature
17:59amalloyi think clojail exposes a read-string-safely function, or something like that
17:59brehautweavejester: would that let it use 1.2.1 and up?
18:00SomelauwAnd its enabled by default?
18:00technomancyyeah, as far as what you actually *want*, clojure version declarations in libraries should function as documentation to the consumer
18:00amalloybrehaut: it lets it use 0.0.0 and up, but expresses a preference for 1.2.1 :P
18:00TimMcSomelauw: read can also run out of stack, I think.
18:00technomancybut for that purpose, lein-multi is probably better
18:00TimMc,`````````````````f
18:00weavejesterbrehaut: Yeah. "Prefer 1.2.1 if nothing else is specified, but accept any version above it too."
18:00clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.StackOverflowError>
18:00brehautamalloy: ah. that definately wont work for necessary evil ;) it breaks on 1.2.0
18:00amalloyweavejester: it allows lower versions too, doesn't it?
18:01weavejesteramalloy: I didn't think so...
18:01amalloyi could definitely be wrong there
18:01weavejesteramalloy: Let me test!
18:01amalloylike if you publish a lib that depends on "1.3.0", and your app depends on "1.2.1", you get 1.2.1
18:01amalloybetraying the lib's preferences
18:01TimMcclojurebot: read-string |is| as unsafe as eval unless *read-eval* is bound to false.
18:01clojurebotRoger.
18:02brehaut~read-string
18:02clojurebotread-string |is| as unsafe as eval unless *read-eval* is bound to false.
18:02TimMcaugh
18:02amalloyTimMc: the extra || confused him
18:02amalloyamusingly
18:02TimMchorrible
18:02amalloyhe learned it using the second "is" as the separator
18:02TimMcclojurebot: botsmack
18:02clojurebotOwww!
18:03amalloyand iirc with his current parser there's no way to un-teach him the thing he just learned. hiredman to the rescue?
18:04weavejesteramalloy: You're correct
18:05weavejesteramalloy: A nearer dependency with a lower version will override a further dependency with a higher dependency
18:05weavejesteramalloy: Assuming neither dependency uses ranges or []
18:05brehauthalf an hour ago, i thought maven versions were unbelievably complicated. turns out i was wrong by an order of magnitude
18:07TimMcweavejester: So it's some kind of lexicographic sort?
18:08TimMcNever mind, I don't want to know.
18:08brehautTimMc: it all starts with a lamb…
18:09amalloyweavejester: well, [] is a range too. just a small one
18:10TimMcamalloy: The question is, is [] a higher empty interval than []?
18:10TimMcI guess it really should be () and ().
18:10iruediger\join #enlive
18:10TimMciruediger: DENIED
18:11amalloyTimMc: weavejester meant single-size "ranges" like [1.3.0], i'm fairly sure
18:17weavejesterYeah, assuming all versions are "1.0.0" style
18:17weavejesterNo ranges
18:17weavejesterOr single-size ranges
18:17weavejesterThen you can use a lower version number if you put it in your project.clj file
18:17weavejesterEven if a dependent library uses a later version
18:18weavejesterBut if ranges or single-size ranges are involved
18:18weavejesterIt's very strict.
18:18amalloyright. version numbers are hard
18:19amalloyfor a while i specified [1.2.0,), which gets you the "sure, you can use a higher version if you want" behavior
18:19amalloybut is obviously a lie: my code won't work with clojure 5.7
18:38weavejesterHm, even [1.0,1.1] doesn't allow you to use 1.1.1
18:39weavejesterI think I'll just swear off ranges :)
18:42Raynesweavejester: Thank you.
19:05accelis ther ea init.clj somewhere that gets executed every time I run java clojure.main ?
19:05acceli.e. there are some scripts that I want executed every time I load up the clojure repl
19:05technomancyaccel: user.clj will, but it must be on the classpath
19:05accelanyehwere in the classpath, or in clojure.jar?
19:06technomancyanywhere
19:06acceltechnomancy: nice; it worked!
19:06accel(inc technomancy)
19:06lazybot⇒ 21
19:06accel(inc lazybot)
19:06lazybot⇒ 3
19:07technomancyin general it's probably not a good idea to rely on that because it means every manually-constructed invocation of "java -cp [...]" needs to place the directory containing user.clj on the classpath
19:07technomancybut there are some cases where it's nice to have
19:08acceltechnomancy: This suffices; it's purely for development purposes.
19:13technomancychoffstein: did you see this? https://github.com/heroku/heroku-buildpack-clojure/tree/private-repo
19:20technomancyweavejester: you know these kinds of tests work fine out of ~/.m2, right? =)
19:20weavejestertechnomancy: Oh, I hadn't thought of that. Easier just to lein-push though
19:21technomancyonly by three keystrokes
19:22weavejestertechnomancy: Oh, there's a lein command to deploy a jar locally?
19:22technomancyweavejester: "lein install" does that. =)
19:22weavejestertechnomancy: Ohhh
19:22weavejestertechnomancy: Ah well
19:29technomancyanyone else interested in running a private repo want to test out https://github.com/technomancy/s3-wagon-private ?
19:38qbgIs there a reason why Clojurescript doesn't generate arity checks for fns?
19:39cgrayqbg: I think it does
19:39qbgI just pulled down master and I'm not seeing them
19:40qbgFor instance, this evaluates: ((fn [x] (* x 2)))
19:40qbgto NaN
19:40qbgAnd if you print the fn you see no check
19:41cgrayhow about if you do ((fn ([x] (* x 2)) ([x y] (+ x y)))) ?
19:42qbgThat throw an arity exception
19:42hiredmanqbg: are you running code through the optimizer?
19:42qbgNo
19:43qbgJust ./script/repljs
19:43qbgI guess the Closure compiler would catch that
19:44cgrayprobably, and it'd slow things down quite a bit to generate an arity check for every single-arity fn
19:45qbgNow I'm wondering if advanced optimizations could remove that check if it existed
19:45qbgTo the internet!
19:46cgrayit seems like something that could be checked at compile-time, but i'm sure there's some diabolical example that shows I'm wrong
19:46qbgNope
19:47qbgYou wouldn't know the type of the function at compile time in all cases
19:47qbgHoFs would make that hard
19:47cgraytrue
19:49qbgIs there a way to pretty print an object in ClojureScript, showing its actual impl? (so you see what a vector looks like under the covers for example)
19:50brehautqbg: can you console.log it if thats possible and explore it with the inspector?
19:51qbgWhat is the syntax for js*?
19:51qbgOr how should I invoke console.log?
19:52brehauterr (.log js/console …) ?
19:53cgraybrehaut: that's right
19:54qbgYep. Only Rhino doesn't have a console object :(
19:54brehautoh. rhino.
19:54qbgI thought there was a web browser powered repl somewhere?
19:55qbgSupposedly there is one included with ClojureScript now
19:59qbgOkay, I think I know how to get to it
20:00qbgBe nice if there was a script for it, and the readme pointed to https://github.com/clojure/clojurescript/wiki/The-REPL-and-Evaluation-Environments instead
20:03accelin a clojure map (which cuases lazy seq); is it guaranteed that each element is evaluated _at most_ once?
20:04acceli.e. after the first time it ahs been evalutaed, is it gaurnteed to be memoized rather than re-excuted the next time the value is needed
20:04hiredmanyes
20:04accelcool; not taht I distrust you; but can you provide a link? I would like to read up on related material on how all of this works (laziness + interacting with Java code scares me a bit)
20:04hiredmanwell, actually, I forget, there may be a race to memoize
20:04hiredmanaccel: read the source
20:05hiredman(there isn't the relevant methods are synchronized)
20:06cgraythe results of map aren't memoized
20:07TimMcaccel: If map uses lazy-seq, then it is guaranteed to realize each cons only once.
20:07brehautif you hold onto the head they are
20:07accelhow do you retain access to a map w/o hodling on to head?
20:07hiredmanaccel: don't
20:07hiredmanaccel: and it isn't a map
20:08hiredmana map is a {:foo 1}
20:08accelerr, how to you retain acess to a lazy list w/o holding on to head?
20:08hiredman(map … …) creates a lazy sequence
20:08hiredmanwhy do you want to do that?
20:08cgraybrehaut: i'm thinking there's confusion here between "memoize" and "realize"
20:08accelhiredman: I want to understand the weird case where the results of map aren't memoized.
20:09hiredmanaccel: there aren't any
20:09accelwhat was cgray referring to?
20:09brehautcgray: memoization isnt just the use of the function memoize
20:09hiredmandunno
20:09hiredmanaccel: but when in doubt feel free to trust what I say over what he says
20:10cgrayhiredman: very true
20:11cgraybrehaut: to me, memoization means storing the result of a function given its inputs... what does it mean to you?
20:11brehautcgray: its storing the result of a computation to avoid recalculating it later
20:11hiredmanlazy seqs are internally a series of no argument functions, the values of which are stored for later
20:11TimMc"memoization" can mean either a certain computational strategy or the specific technique of using the memoize function.
20:12brehauthiredman puts it much more clearly than i can
20:13qbgbrehaut: Yep, console.log shows the interesting guts. Thanks
20:13accelhiredman , cgray , TimMc : got it; thanks :-)
20:14TimMcaccel: https://github.com/clojure/clojure/blob/1.3.x/src/jvm/clojure/lang/LazySeq.java is pretty interesting
20:14TimMcThat's what map uses (by calling lazy-seq).
20:16brehaut,(let [s (map (fn [x] (Thread/sleep 100) x) (range 4))] (dotimes [_ 2] (time (doall s))))
20:16clojurebot"Elapsed time: 404.038 msecs"
20:16clojurebot"Elapsed time: 0.021 msecs"
20:17accelTimMc: added to reading list.
20:18accelAn unrelated question: is there a way to tell clojure: when printing out stack frames in REPL, only show me stacks that involve *.clj files, and ignore the ones involving *.java files?
20:18accelI often times find myself scrolling through pages of *.java invocations to find the *.clj error
20:18qbgclojure.repl/pst does some of that
20:18qbgBut not all of what you want
20:19accelhow do I use clojure.repl/pst? my current invocation is: "java clojure.main"
20:19qbgAre you in the user namespace?
20:20accelI think so.
20:20qbgIf so, (pst) will print the stacktrace of the last exception
20:20qbg,(doc clojure.repl/pst)
20:20clojurebot"([] [e-or-depth] [e depth]); Prints a stack trace of the exception, to the depth requested. If none supplied, uses the root cause of the most recent repl exception (*e), and a depth of 12."
20:20accelah, it only shows one *.clj line
20:20accelbut it's the one I care about
20:39simardIs there a better way to do that ? http://pastebin.com/1nCfvYK1
20:40simardIn particular, should I use recur instead ?
20:42brehaut,(taken-nth 2 (range 10))
20:42clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: taken-nth in this context, compiling:(NO_SOURCE_PATH:0)>
20:42brehaut,(take-nth 2 (range 10))
20:42clojurebot(0 2 4 6 8)
20:43brehautsimard: but lazy-seq seems correct there; recur would give you a strict list
20:43simardok this function is basically the same as mine
20:43simardgood to know, there's always a bunch of already existing functions I don't know about .. :)
20:43brehautsimard: with the appropriate check for sequenceness ;)
20:43simardyeah
20:43simardhehe
20:43simardforgot about that.
20:44simardI should skim through core.clj somesay
20:44simardsomeday, to get that "I've seen this before" feeling.
20:44brehautsimard: a good starting place is the clojuredocs quick reference
20:44brehauthttp://clojuredocs.org/quickref/Clojure%20Core
20:54TimMcsimard: There's also $findfn.
20:54TimMc$findfn 2 2 4
20:54lazybot[clojure.core/unchecked-multiply clojure.core/+ clojure.core/* clojure.core/unchecked-add clojure.core/+' clojure.core/unchecked-multiply-int clojure.core/*' clojure.core/unchecked-add-int]
20:54TimMc...best used in private /msg
20:55seancorfieldsimard: don't forget the Clojure Atlas - a great way to explore the library space! http://clojureatlas.com
20:56simard$findfn (1 2 3 4) 2 (1 3)
20:56lazybotjava.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn
20:57TimMcsimard: Try quoting those lists.
20:57simardTimMc: right.
20:57seancorfield$findfn '(1 2 3 4) 2 '(1 3)
20:57lazybot[]
20:57simard$findfn 2 '(1 2 3 4) '(1 3)
20:57lazybot[clojure.core/take-nth]
20:58simardthere :)
20:58simardhow does it work ?
20:58simardcan't be brute force or is it ?
20:58TimMcit is!
20:58alexbaranoskythat's sweet
20:59simardvery nice
20:59TimMcsimard: lazybot goes through basically all the sandbox-allowed functions in core.
21:00TimMcYou can also get find-fn as a lein add-on or something. The syntax is slightly different, but it works the same way.
21:00TimMcalexbaranosky: I am so fed up with try-cljs. It works differently on kibble than on my local machine.
21:02qbgWow. vector is defined pretty late in core.cljs
21:02alexbaranoskyTimMc, well it can always chill out on the back burner for a bit
21:02TimMcqbg: I guess everything before it uses an RT method?
21:03qbgClojureScript here
21:03alexbaranoskydang, Midje is so cool (caveat: imho) and I am constantly surprised how few people have used it... argg!!!
21:03qbgLazySeqs and lists come first
21:03TimMcqbg: Oh, CLJS, got it.
21:04qbgStill, shows that you don't need vector too much
21:04alexbaranoskyon a related note, have you guys used core.match or core.logic to do anything neat?
21:04qbgcore.cljs is really beautiful
21:05simardcljs ?
21:05qbgalexbaranosky: I was going to write a Sudoku solver using core.logic, but got stuck figuring out where to start
21:05qbgsimard: https://github.com/clojure/clojurescript
21:05simardno way, that's cool.
21:06TimMcsimard: Not yet.
21:07TimMcHasn't even had an alpha release yet, and there are a *lot* of design decisions still to be made.
21:07TimMcDon't get me wrong, I'm excited about it -- but it is a very young project.
21:09simardbah I can wait. I was working on a webapp for which the server side ran on clojure and the client side JS + webgl. I found that the JS side was dirty. Hopefully CLJS can reduce the impedance mismatch between the client and the server.
21:10qbgYou have the reader available at runtime
21:10qbgMight be useful
21:10simardand dangerous :)
21:10qbgYou don't have eval though
21:11simardhaving the reader is quite cool. that's a whole protocol that needs not be designed.
21:12simard(I mean, when replacing a JS client by a CLJS client)
21:12simardwill it be possible to execute JS code from CLJS ?
21:12brehautsimard: do you mean call external JS?
21:13simardyes, I mean that. not eval.
21:13accelI need some advice. I'm writing a WYSIWYG editor. I want to ahve a var (call it "root") that keeps track of the DOM tree. I know that at times, there are goign to be exceptoions thrown. I want to have a setup of something like this: forever, (if exception, ignore it), then just reload document @ root and continue on. Is this a reasonable appraoch? suggetions?
21:13alexbaranoskyI think I just wrote a abstract for Clojure/West about TDD with Midje.... but now I'm scared to submit it :)
21:14qbgsimard: Yes, you can call external js
21:15qbgaccel: What type of exceptions?
21:18accelqbg: ones I did not accept
21:18accel*expect*
21:19qbgProbably want to at least log the exception
21:20qbgAnd then during the reload die if another exception occurs to prevent a possible infinite loop
21:20simardI'm writing a macro that takes a vector of symbols (not bindings) and a body, what name should I give the vector of symbols ? vars ? syms ?
21:21choffsteinHey all. Can anyone provide some idiomatic clojure code for repeatedly polling a database using aleph? I basically want to have a database poll that times out if a background job doesn't post to the database fast enough -- but I can't seem to come up with a good method for repeated polling on the sever side
21:22amalloyyou should call it whatever the symbols are for
21:22amalloyor syms, if you think that's more useful
21:22amalloybut it's like: "I'm writing a function that accepts some integers, what should I call it?" kinda depends what you do with the ints
21:23simardyeah but there's that naming convention for arguments out there, x, y, n, coll, fn, etc..
21:27brehautx and y arent good examples; they have very specific meanings
21:31qbgsubvec uses v for the vector
21:32brehautfunctions (and macros) that operate generically on their arguments use generic names. if they operate specifically on their arguments, they more often have specific names
21:35simardmakes sense. is defstruct still used ?
21:35brehautno defstruct is largely deprecated
21:35brehautuse plain maps or records
21:57benares_98Is there any difference between (partial filter odd? x) and (filter odd? x) ?
21:57brehautbenares_98: yes, one of them returns afunction the other returns a list
21:57brehaut,(filter odd? (range 10))
21:58clojurebot(1 3 5 7 9)
21:58brehaut,(partial filter odd? (range 10))
21:58clojurebot#<core$partial$fn__3796 clojure.core$partial$fn__3796@1f2e6d8>
21:58brehaut,((partial filter odd? (range 10)))
21:58clojurebot(1 3 5 7 9)
21:59brehautbenares_98: in this case, the partial version is a bit redundant given lazy seqs are only realized on demand anyway
21:59benares_98thanks that's what I was thinking, I saw a solution with partial and thought it wasn't necessary
21:59benares_98going through 4clojure
22:00brehautbenares_98: presumably the partial is there because the solution called for a function
22:00benares_98I thought that too but (filter odd? x) worked too.
22:00brehauti presume someone just did somethng weird then
22:01benares_98thanks!
22:01brehautwhat question btw?
22:01benares_98http://www.4clojure.com/problem/25 Find the odd numbers
22:02brehauthah my solution is (partial filter odd?)
22:03brehauti haven managed to grasp 4clojure solutions as literally putting your solution into the slot in the sexp
22:04benares_98yeah I'm still learning the language and I love that there's a website for quiz oriented learning
22:05simardbenares_98: have a look at project euler, the solutions there often include neat clojure code
22:06benares_98Thanks simard!
22:06brehautsimard: 4clojure is a better learn clojure resource because its focused on a wide range of things rather than being heavily math oriented
22:08amalloy4clojure is a bit more guided, too. you won't see an euler problem about how to use 'map
22:09simardof course not, but it's still great to see solutions 5x shorter as your own :)
22:09simardI didn't know about 4clojure.. I'm registering just now, gonna have some fun.
22:10amalloyhm, we should add a problem that introduces/teaches 'for, but i don't know how to write such a problem
22:10accelI need to be able to catch Java exceptions from clojure land. What should I google to read up on? (URLs are acceptable too.)
22:11brehauthttp://clojure.org/special_forms#Special%20Forms--(try%20expr*%20catch-clause*%20finally-clause?)
22:11amalloymaybe something like "transform the map {a {x 1 y 2} b {p 3 q 4}} into {[a x] 1 [a y] 2 [b p] 3 [b p] 4}, and btw you might want to use 'for"?
22:12accelbrehaut: noted; thanks
22:12accelbrehaut: clojure.org is surprisingly concise + useful
22:12accelit's like people put thought into writing this documentation
22:12brehautamalloy: ithink you'd want a series; for as map, for as filter, for as cross product
22:13brehautand disallow map, filter, mapcat, reduce and recur i guess?
22:13amalloybrehaut: well, it doesn't have to work that way either. you could be like "here's a for expression, what does it evaluate to"
22:13brehautah true
22:14Raynesaccel: Surely not. I usually just slap my keyboard to write docs.
22:14brehautamalloy: what about (for [____] x) ?
22:14amalloyinteresting
22:15Raynes(for [___________________________________] x), more like.
22:15RaynesYou should have seen the `for` that amalloy wrote earlier.
22:15RaynesIt did everything but fix me breakfast.
22:16alexbaranoskyRaynes: no breakfast? ... meh
22:16alexbaranosky;)
22:17brehautRaynes: if your for's dont have the full complement of destructirings and keyword subforms, you arent really putting enough efford into things
22:17brehauts/bad spelling/good spelling/
22:17amalloybrehaut: i actually got all of them into one for! that's why it was so epic
22:17brehautamalloy: when while and let?
22:17amalloyhttps://github.com/flatland/jiraph/blob/502c452e4/src/jiraph/masai_sorted_layer.clj#L83-92 if you want to have a peek
22:17brehautwow
22:17brehautthat is epic
22:18simardamalloy: how long has 4clojure been running ?
22:18amalloysimard: since april, i think?
22:18simardnice initiative
22:18brehautamalloy: what is a masai layer?
22:19amalloybrehaut: an implementation of a jiraph backend
22:19amalloy(using masai)
22:19brehautah so masai is a db ?
22:19amalloymasai is another thing ninjudd wrote
22:19brehautright
22:19amalloyit's an interface to a k/v datastore
22:20amalloywith a number of actual implementations
22:21amalloythere's backends for redis, tokyocabinet, and memcache, though i don't know how many of them actually work since the only one we use is tokyo
22:21RaynesUh!
22:22RaynesHe didn't write that whole thing, ya know.
22:22brehautRaynes: you are too young to be allowed to get credit for things
22:22brehautits embarassing for the rest of us
22:22amalloyRaynes: oh, i didn't know you were involved with masai
22:23Raynesamalloy: I did the redis impl. It was my first project at Geni.
22:23amalloynice
22:23amalloythat sounds familiar now but i'd forgotten
22:23RaynesIt was before you got there.
22:23RaynesI imagine I talked to you about it though.
22:23amalloyright
22:24RaynesI also rewrote the tests.
22:24RaynesI emphasize that because you say I never write tests.
22:24Raynes:>
22:25amalloybrehaut: i was thinking of creating the same value with several different for-expressions. all the odd numbers, maybe? but it's really hard to get the "iterate over N sequences nested-wise" worked into that
22:26simardI'd like to do something like that: (and (map contains? (repeat a-map) [map? :type :unit :val]))
22:26simardof course, I need to apply and to the map, which won't work
22:26simardis there a neat way to do that ?
22:26amalloy(every? #(contains? a-map %) [...])
22:27amalloyor if you don't have any nil/false values, you can do (every? a-map [...])
22:28brehautamalloy: i think id still want to split for stuff into two chunks: all the basic mechanics it provides, nested stuff
22:28brehautsome sort of nondeterministic search might be nice
22:28amalloyah, that's nice. then to cover just the nested-ness, my earlier thing about nested maps is good
22:28amalloybrehaut: like what?
22:29brehautamalloy: im trying to think of a suitable small example.
22:29brehautactually, i think nesting is probably a seperate challenge to nondeterministic search
22:33brehaut,(for [:let [a [1 2 3]] b a] b)
22:33clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalStateException: Can't pop empty vector>
22:33brehaut,(for [_ [1] :let [a [1 2 3]] b a] b)
22:33clojurebot(1 2 3)
22:33brehautdoes that seem like a bug to anyone else?
22:34qbgYeah, that seems like a bug
22:35brehauttime to brave the jira i guess
22:35amalloyhuh?
22:35amalloythat seems like obviously-correct behavior
22:35brehautamalloy: that you cant :let at the top of a for?
22:35amalloyoh, i missed the exception
22:35amalloyno, i agree, it would be nice if you could :let
22:36amalloybut there's also no particular reason to be able to
22:36qbg:let seems a bit weird being first, but whatever
22:36brehautwell, no you could just wrap the for in a let
22:36brehautbut never the less
22:36qbgDo not look at the implementation of for with remaining mind
22:37amalloyyeah, it's...pretty hairy
22:37amalloyeven looking at the macroexpansion of a 'for is not for the faint of heart
22:37brehauthehe
22:38brehautoh well
22:38amalloy&(macroexpand-1 '(for [x (range 10) :when (even? x) y [5]] [x y]))
22:38lazybot⇒ (clojure.core/let [iter__4191__auto__ (clojure.core/fn iter__15951 [s__15952] (clojure.core/lazy-seq (clojure.core/loop [s__15952 s__15952] (clojure.core/when-first [x s__15952] (if (even? x) (clojure.core/let [iterys__4187__auto__ (clojure.core/fn iter__15953 [s__... https://gist.github.com/1508809
22:38brehautif i really need it, i know i can fall back on (domonad sequence-m …) ;)
22:38amalloyhaha
22:40qbgExplaining monads is easier than explaining how for is implemented
22:40brehaut(= :magic :magic)
22:40brehaut,(= :magic :magic)
22:40clojurebottrue
22:41brehautnope, looks equivalent to me
22:41qbgdnolan wrote a logic program that derives magic, and ran it backwards to get for.
22:41brehautlol
22:46amalloybrehaut: http://www.4clojure.com/problem/145 is my intro-to-for
22:48brehautaha thats nice ;)
22:49brehautamalloy: aha you also kicked my arse for golfing it too :P
22:49amalloy*chuckle*
22:59amalloybrehaut: also approved someone's submission at http://www.4clojure.com/problem/144 while i was at it. solve those dang problems, guys!
23:00brehautamalloy: im sure theres a suitable dice or cards or simple game board search that would be good for an advanced search with for problem but i cant think of one right now
23:08brehautamalloy: thats a nice problem
23:19accelis there a way I can create a timer object that expires when a particular JFrame is closed?
23:20accel_how_ can I create a timer object that expires when a particular JFrame is closed? (an answer of "yes" is rather useless :-D )
23:20minikomiHi there
23:21minikomihaving a little trouble with vimclojure .. the syntax hilighting is going ok but the nailgun server is giving me a couple of errors
23:22minikomi Unable to resolve symbol: special-form-anchor in this context,
23:23accelvimclojure is doing lots of weird things for me too
23:23minikomi:)
23:23accellike when I hit o to open a new line, it clears my copy/yank buffers
23:23accelindenting is also very slow
23:23minikomitheres a lot of information but I'm not sure which is the most up to date
23:24accelso far; I have found the best way be just keeping another clojure repl open
23:24accelit's surprisingly effective
23:24minikomiah
23:24minikomii have used the slime/screen hack with ruby and python
23:24minikomior do you just copy paste between?
23:26acceli don't copy/paste
23:26amalloyaccel: add a WindowListener to the frame, that cancels the timer on close?
23:26accelI just do (load-file "blahblah.clj")
23:27minikomiah
23:28accelthen, I use (doc ...) to get documentation in the repl
23:28acceluse the repl to get the satck traces
23:28acceland most imporatntly; when I get stuck; I write long deatiled posts of exactly what I'm trying / waht is working / what is not working
23:28acceluntil someone uch smatter in #clojure decides I'm cluttering up the channel, and helps me out. :-)
23:28minikomihaha
23:29minikomii'm interested in learning a lisp-ish language but getting a working toolchain is a bit of a hassle .. such is the nature with new things I guess!
23:30accelthe toolchain is overated
23:31accelamalloy: http://docs.oracle.com/javase/1.5.0/docs/api/javax/swing/Timer.html <-- interesting; so there is one thread that keeps track of all the timers; but all the timers are eecuted in the Swing TUI thread? I guess it makes sense to allow all the updates to happen; this is knd of cool.
23:32accelThis is the timer I want to use. http://docs.oracle.com/javase/tutorial/uiswing/misc/timer.html . Is there a way to say "kill all existing timers?
23:35amalloybrehaut: just finished writing up the problem i proposed earlier: "transform the map {a {x 1 y 2} b {p 3 q 4}} into {[a x] 1 [a y] 2 [b p] 3 [b p] 4}, and btw you might want to use 'for". can't think of a good title for it, though
23:38hiredmanaccel: the cools kids use scheduledthreadpoolexecutors
23:39hiredmanhttp://docs.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html has a shutdownNow method
23:40brehautjava.util.concurrent is just jammed full of cool classes
23:42brehautamalloy: thats boggling my brain :P
23:44accelhiredman: does ScheduledThreadPoolExecutor have hiredman's seal of approval?
23:45accelhiredman: is the difference between FixedRate & FixedDelay that: (1) FixedRate does NOT drift and (2) FixedDelay drifts ?
23:49hiredmanaccel: actually I am not sure, but I believe fixedrate tasks can end up running at the same time if you take longer than the period, while fixed delay tasks wait for the delay after termination for executing again
23:55accelhiredman: so I'm reading http://docs.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html and I don't see a promise anywhere that says "when this object is GC-ed, shutdown is automatically called on it. Is this implied somewhere, or can I not make this assumptino?"
23:57hiredmanaccel: why would you assume that?
23:58Raynes&(reduce #(if ((set %) %2) % (conj % %2)) [] [1 1 2 1 3 2 3 3])
23:58lazybot⇒ [1 2 3]
23:58accelIn C++, when objects are freed; their desructors are called; I extrapolate it to in Java, when objects are GC-ed, they should "clean up"; it seems like for a thread pool to clean up; it should shutdown all its threads.