#clojure logs

2012-02-04

00:09_philcan i use a single quote as part of an identifier, i.e. (def a' 5)?
00:10_philit seems to work but i dont know if there arent any implications, e.g. with macros
00:10guns_phil: there are clojure functions like +' and *'
00:10_philguns: so no problem?
00:11guns_phil: I assume not. I use it all the time myself (nice mathy feel), but I'm pretty new to Clojure too
00:12_philguns: haha, bad bad haskell :D
00:13gunssilly to name iterations of a variable x, x1, x2 ...
00:13jkkramer1trailing apostrophes are supported in clojure 1.3+. doesn't work in clojure 1.2
00:15_philjkkramer1: thx
05:07tfaro.
05:11Raynes,
05:11clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
05:23AimHere,(Thread/sleep 1000000000000)
05:24clojurebotExecution Timed Out
05:24AimHereHeh
05:50bkolobaraHi I just started learning clojure and I'm relatively new to emacs. When I start the slime repl (M-x clojure-jack-in) I can't access the doc macro. I get a message "Unable to resolve symbol: doc in this contex" and a RuntimeException is thrown. When I use the Leiningen repl everything works. What am I doing wrong?
06:04raekbkolobara: 'doc' is not in clojure.core since Clojure 1.3. you need to run (use 'clojure.repl) in the repl.
06:05raek"lein repl" does that step automatically for the 'user' namespace
06:44bkolobararaek: tnx
07:12cmajor7if 'defn' just a macro that is the "Same as (def name (fn [params* ] exprs*))", how come:
07:13cmajor7" (def f-seq (map f (iterate inc 0))) " returns lazy results with caching
07:13cmajor7and " (defn f-seq [] (map f (iterate inc 0))) " does not?
07:14raekthe (def f-seq (map f ...)) example does not match the (def name (fn ...)) pattern...
07:14raeksince (map ...) does not return a function
07:15raekeach time the second f-seq function you defined is called a new lazy-seq is constructed
07:15cmajor7raek: thank you. so why is def caches and defn does not in this case?
07:16raek(which is cached)
07:16raekcmajor7: the first and second example are not of the same types!
07:16raekthe body of a (fn ...) expression is never cached
07:16amrocmajor7: your second example is missing a (fn ...)
07:17amroer, first
07:17cmajor7amro: 'f' is a hypothetical (any function)
07:17raekas amro said, if you replace the first one with (def f-seq (fn [] (map f (iterate inc 0)))), _then_ they are equivalent
07:18raekthen, both versions are _functions_, which create _new_ lazy-seqs when they are called
07:19cmajor7right, and hence _not_ cached.. ?
07:19raekthe particular lazy-seq that a function returns is cached
07:19cmajor7"(doall (take 3 f-seq))", and then "(println (nth f-seq 2)) ; uses cached result -> 2.0"
07:20raekso if you traverse that particular lazy-seq multiple times, f will only be called once per element
07:20raekbut each invocation of f-seq makes a new lazy-seq with its own caching
07:21raekcmajor7: yes, but in that example you use the same lazy-seq object in both cases
07:21cmajor7right.. that is the caching I am referring to
07:22raekok, then you have to keep a reference to the lazy-seq object you want to keep
07:22cmajor7I thought that 'defn' is just a "(def name (fn [params* ] exprs*))"
07:22raekit is
07:22cmajor7hence a confusion where I see def/defn resulting in different behavior
07:23raekbut what it isn't is "(def name exprs*)"
07:23raekdo you see the difference?
07:23raek(defn foo ...) = (def foo (fn ...)) is true, but you did not use that fact in your example at all
07:24cmajor7are you saying that a "(map f (iterate inc 0))" part in "(defn f-seq [] (map f (iterate inc 0)))" becomes a function, where in "(def f-seq (map f (iterate inc 0)))" it just a lazy-seq bound to a name?
07:24raekno, that part is a lazy-seq in both cases
07:25raekbut "f-seq" becomes a function in the first case and a lazy-seq in the second
07:25raekfunction that take zero arguments are not the same as the values in their bodies
07:26raek(defn x [] y) is the same as (def x (fn [] y)), that is, "x is bound to a nullary function that returns y"
07:27cmajor7does "(defn f-seq [] (map f (iterate inc 0)))" wrap "(map f (iterate inc 0))" into a function? Is that why the binding result is different?
07:27raek(def x y) is not the same, and means "x is bound to y"
07:27raekcmajor7: yes, it does
07:27cmajor7aha.. I think I see it now
07:27cmajor7thank you!
07:27raekthat's what (defn x [] y) --> (def x (fn [] y)) is all about!
07:28cmajor7I was a bit confused by the "undercover" wrapping :)
07:28cmajor7I see now it makes perfect sense: every time you call x, an underlying fn is reevaluated
07:29cmajor7vs. just a binding where the reference points to a lazy-seq
07:32raekyes, the body of the function is evaluated each time the function is called
07:33raek(i.e. only the "y" part and not the whole "(fn [] y)" part)
07:33cmajor7raek: right, thanks!
07:38echo-areaIs there an "assoc for vector", that is, takes a vector, an index and a new value, returns a new vector with the value at the index is replaced with the new value?
07:47echo-areaHmm. `assoc' can operate on a vector.
08:04AimHereecho-area > if you're looking for an analogue for a function between collection types, then try the function you want the analogue of!
08:26gfrederickswhat're these three elisp files in my .emacs.d/swank directory? should I be versioning them or ignoring them?
08:38the-kennygfredericks: I ignore them
08:40gfredericksthe-kenny: okay, thanks
08:41the-kennygfredericks: They're auto-generated when you run clojure-jack-in for the first time. I wouldn't delete them, as it takes some time to recompile them
08:42gfredericksnoted
08:44miniyukito extract the set of keys of a list of hash
08:45miniyukiit there a better way than (distinct (mapcat keys [{:prop1 "any"} {:prop2 "any"} {:prop1 "any" :prop3 "any"}]))
08:46miniyukiexpected result (:prop1 :prop2 :prop3)
08:48the-kennyIf you want a real set, use `set' instead of `distinct'
08:48gfredericksI'm trying to think if there are any performance issues with that...
08:48gfredericksprobably laziness would make it okay
08:50miniyukithanks
09:12TimMcgfredericks: This is a test of the code we were discussing: https://github.com/timmc/kpawebgen/blob/master/clj/test/kpawebgen/test/munge.clj#L40
09:12TimMcgfredericks: And this is what implements it: https://github.com/timmc/kpawebgen/blob/master/clj/src/kpawebgen/munge.clj#L35
09:16gfredericksman I need a better way to get links out of a terminal
09:16gfredericksTimMc: I've never seen an ASCII graph drawn in comments before
09:25the-kennyI'm pretty sure emacs has support for this :)
09:25TimMcgfredericks: It was the only way I could keep it straight in my head.
09:38pyrhey! anyone used cascalog with s3 before ?
10:24dribnetHi. Can anyone help me understand gen-class, specifically why I'm not making the constructor I think I'm making?
10:26the-kennydribnet: Don't ask to ask.
10:27dribnetI have a very short :gen-class. It has :constructors {[] [foo]} and then later (defn -construct [] [[(thing)] ])
10:28dribnetYet when I try to call (class.) later to construct with no args, i get "No matching ctor"
10:29dribnetobviously i have the wrong model of how this is supposed to work.
10:30dribnetI don't understand how the (classname.) could fail to resolve at compilation if i've declared both :constructors {[] []} and the -init [] methods.
10:36dribnetBasically my question is: what governs the type of constructor available in the class generated by gen-class?
10:38dribnetIf I setup a no-arg constructor via :constructors {[] [whatnot]]} and then later implement (defn -init []) correctly, how is it even possible that the no-arg ctor can be missing at compile time?
10:45dribnetis there an easy way to make lein launch the repl in 1.3.0 by default?
12:16dgrnbrgif I'm writing something that uses (binding) to override a fn, but I want to invoke the previous binding in my new binding, how can I do that?
12:24arohnerdgrnbrg: use a let to store the old version before binding the new one
12:24clojurebotPardon?
12:25arohner(let [old-fn f] (binding [f new-fn] (f) (old-f)))
12:30dgrnbrgI did this: (let [old (bound-fn [args] (apply myfunc args))] (binding [myfunc old] (myfunc))
12:30dgrnbrgarohner, and that caused a stack overflow
12:31dgrnbrgI don't see why I can't use bound-fn here
12:33dgrnbrgIs there a way to make a defn ^:dynamic?
12:42arohnerdgrnbrg: why do you want to use bound-fn? bound-fn is for times when you want to preserve the bindings across threads, i.e. when you want the binding value to appear in another thread. it doesn't appear that's the case here.
12:42dgrnbrgI want to preserve the binding under a different binding
12:42arohnerit's causing a stack overflow because you're calling the same fn recursively
12:42dgrnbrgIt seems like the logic should work fine in both cases
12:43dgrnbrgI would expect the bound-fn to cause the recursive call to myfunc to use the old binding
12:43dgrnbrgsince the bound-fn should save the binding from when I called it
12:43arohnerit doesn't work like that
12:43arohnerbindings are a thread-local stack. new calls to binding push values onto the stack
12:43dgrnbrgso bound-fn is just pushing onto the stack?
12:43dgrnbrgnot replacing the stack?
12:44arohnerlet's talk about only binding for a second
12:44arohnerbinding pushes onto the stack
12:44arohnerbut bindings are only thread-local
12:44arohnerso bound-fn is for situations where you want to take the binding stack, and use the same values in another thread
12:44dgrnbrgexactly
12:44arohnerare you using another thread here?
12:45dgrnbrgI'd expect it to work by saving the stack at the time bound-fn is called
12:45arohnerthe standard, idiomatic answer here is to use a let to save the value you care about
12:45dgrnbrgand then when I invoke the bound-fn's result, i'd expect it to swap the binding stack that's in effect for the one from the bound-fn, and then execute under that
12:46dgrnbrgbut I guess it's not swapping the stacks, but instead just pushing the saved stack on top of whatever's already there
12:46dgrnbrgwhich is why it overflows
12:46dgrnbrgis that the correct interpretation?
12:52tjgilliesdoes clojures STM have the same type of role as monads in haskell?
12:52tjgillies"Programs written in functional style can make use of monads to structure procedures that include sequenced operations,http://en.wikipedia.org/wiki/Monad_(functional_programming)#cite_note-0http://en.wikipedia.org/wiki/Monad_(functional_programming)#cite_note-1 or to define some arbitrary http://en.wikipedia.org/wiki/Control_flow (like handling http://en.wikipedia.org/wiki/Concurrency_(computer_science), http://en.wikipedia.org/wiki/
12:52brehauttjgillies: no
12:53brehauttjgillies: it has a similar role to the STM monad in haskell, not monads in general
12:54tjgilliesi mean STM is not a monad by any means, but wiki says monads are for chaining functions together to handle concurrency and side effects
12:54tjgillieswhich is the whole point of the persistent data structures, thats why i asked if they play similar roles
12:54tjgillieshandling concurrency and side effects, not so much chaining
12:55Scriptorer, persistent data structures don't really do anything special to avoid side effects, I think
12:56Scriptorwell, they avoid side effects
12:56Scriptorbut they don't do anything special to handle them
12:56brehauthaskell has persistent datastructures to, and it doesnt use monads to implement them
12:56arohnerdgrnbrg: it does save the stack, but you're still going to have a stack overflow
12:56brehautall the things haskell uses monads for can be implemented without them and still have pure functional semantics (eg, let, for, do)
12:57brehautmonads are just one (very elegant) way of defining them
12:58tjgilliesbrehaut: ah thanks
12:59brehauttjgillies: look at algo.monads for a clojure implemenetation
12:59tjgilliesbrehaut: already was looking at it
12:59dgrnbrgIs there an implementation of a zipper that works on nested maps and vectors?
13:00tjgillieswhat does haskell use to update persistent data structures? do they have something like refs
13:00brehauttjgillies: thats a confusing question
13:00brehautyou dont update persistent data structure
13:00brehautthats the point
13:01brehautbut haskell does have a variety of reference types that are similar to clojures reference types
13:01tjgilliesbrehaut: you don't update them? i thought they were a tree structure that had history of previous state
13:01brehautIORefs in the IO monad, TVars in the STM monad, others for other contexts
13:02tjgilliesi guess im using "update" wrong
13:02brehaut,(let [one {:a 1 :b 2} two (assoc a :b 3}], [a b])
13:02clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unmatched delimiter: }>
13:02brehaut,(let [one {:a 1 :b 2} two (assoc a :b 3)] [a b])
13:02clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0)>
13:03brehaut,(let [one {:a 1 :b 2} two (assoc one :b 3)] [one two])
13:03clojurebot[{:a 1, :b 2} {:a 1, :b 3}]
13:03arohnerdgrnbrg: yes, zippers work on maps and vectors
13:03dgrnbrgarohner: I meant more of an existing API
13:03dgrnbrgit's tricky deciding what the API for traversing nested maps should look like in a zipper
13:03arohnertjgillies: they are trees, but they don't store previous state. The trees are designed so it's easy to make a new tree that shares state with the old ones
13:04arohnertjgillies: i.e. the "update" returns a new tree, but most of the tree that didn't change shares pointers with the existing tree
13:04tjgilliesarohner: aaah. thnx
13:05dgrnbrgtjgillies: http://blog.higher-order.net/2010/08/16/assoc-and-clojures-persistenthashmap-part-ii/
13:05dgrnbrgpretty pictures of how it works
13:05dgrnbrgThis image in particular is enlightening: http://blog.higher-order.net/files/clj/persistenthashmap-pathcopy.png
13:13tjgilliesdgrnbrg: thnx
13:13dgrnbrgtjgillies: I found that post very illuminating
13:27thhellerhey, I'm playing with clojurescript. is there any way to use console.log for output?
13:28thhellercompletely new to clojure and I really would like to see my data at certain points :P
13:29thheller(print x) only complains with "No *print-fn* fn set for evaluation environment"
13:29brehautim guessing (because i dont know clojurescript) but something like (.log console "message")
13:30thhellerah been there
13:30thheller(.log js/console "bla")
13:30thhellerthat works yeah, but though maybe i can get print&co hooked up somehow
13:33dgrnbrgthheller: could you try (defn *print-fn* [& strs] (.log js/console (apply print-str strs)))
13:33dgrnbrg(I've never used clojurescript
13:33dgrnbrg)
13:36thhellerprint-str doesnt work
13:37thhellerstr works
13:37thhellerbut ouput is useless
13:37thhellertoo many lines :P
13:38thheller(defn log [& args]
13:38thheller (.log js/console args))
13:38thhellerbut output is a cljs.core.IndexedSeq
13:38thhellerhow do i turn that into a list? :P
14:06dgrnbrgthheller: that is getting way further into clojurescript than I know
14:10ibdknoxthheller: if you want println to work you just need to add (set! *print-fn* #(.log js/console %))
14:11ibdknoxsomewhere toward the top of your cljs
14:11thhellerhmm that kinda works
14:12ibdknoxkinda?
14:12thheller(print {:hello "world})
14:12thhellerlogs as 5 lines :P
14:12thheller7 actually
14:13ibdknoxoh right
14:13ibdknoxjust a sec
14:14thhellervarargs in js seems fuzzy
14:15mfexthheller: how are you running clojurescript?
14:16thhellercompiled as js und in the browser
14:16thheller(chrome)
14:17mfexI just use a console.log, although not often in advande compiled js
14:18thhellerfor "native" js types that is fine yeah
14:18thhellerbut (.log js/console {:hello "world"})
14:18chrissbxAre there character functions or predicates like "lower-case?" somewhere?
14:18thhellerprints cljs.core.ObjMap
14:18mfexyou can use pr-str to print cljs type things
14:19mfexie compare (console.log {:a 2}) and (console.log (pr-str {:a 2}))
14:19thhellerah excellent
14:20thhellerthats what i was looking for :)
14:20ibdknoxwow
14:20ibdknoxthis is ridiculous
14:20thhellerthx
14:21ibdknoxit actually looks like the way the print-fn stuff was implemented is busted for the browser case
14:22thheller:P
14:22thheller(defn log [& args]
14:22thheller (.log js/console (pr-str args)))
14:22thhelleris close enough to what I had in mind
14:22ibdknoxyeah
14:23ibdknoxthat's what I did previous to print-fn existing
14:23ibdknoxit's actually kind of nice not to do that sometimes though
14:23ibdknoxfor example, you can inspect dom objects if you don't pr-str them
14:23ibdknoxwhich is often very useful
14:23thhellerhmm true
14:25thhellerbut i'm fairly solid on the javascript/dom side of things
14:25thhelleronly the cljs part is confusing
14:35ibdknoxpinot is getting dismantled :)
14:59mfexMJosa1
14:59mfexwhoops
15:07anttihI'm trying to use a library from clojure.contrib but nowhere does it say how I should install the package.
15:09anttihthe contrib homepage does not talk about this at all. Is there a reason for this? http://richhickey.github.com/clojure-contrib/index.html
15:09lazybotNooooo, that's so out of date! Please see instead http://clojure.github.com/clojure-contrib/index.html and try to stop linking to rich's repo.
15:09RaynesOnly half-helpful.
15:09anttihthat does not help at all
15:10anttihI've now tried to figure this out for an hour
15:10RaynesWell, it kind of does. You're on the wrong site first off. Second, you don't 'install' libraries and 'packages' in Clojure. Do you have Leiningen?
15:10RaynesThings work a little differently in Clojure. It can take you off guard.
15:11anttihRaynes: I have leiningen and know how to use it, but I don't know which jar to use.
15:11RaynesOkay. Clojure contrib was recently split up into multiple libraries. Which library specifically do you want to use?
15:11anttihRaynes: http.agent
15:12RaynesI'm pretty sure that library was deprecated. clj-http is an excellent HTTP client though. Let me pull it up for you.
15:12Rayneshttps://github.com/dakrone/clj-http
15:13RaynesThe latest released version is 0.3.1.
15:13anttihRaynes: ah, saw that one
15:13anttihok, thanks
15:13Raynesanttih: Have you created a project yet?
15:13anttihRaynes: I have
15:14RaynesI'll show you had to add the dependency, which is the equivalent of installing it in Clojure (these things are project-specific and hardly ever global).
15:14RaynesOpen project.clj in your text editor and add [clj-http "0.3.1"] to your :dependencies list.
15:14anttihRaynes: I know how to do that :-), but thanks
15:14RaynesAlright, cool.
15:15RaynesSorry you've had so much trouble. :(
15:33skelternetI am making this harder than it is.
15:50dgrnbrgIs there a way to merge maps and throw an exception if 2 keys collide (i.e. check disjointness of key sets) that's better than (merge-with #(throw (RuntimeException. "non disjoint")) map1 map2 map3)?
15:50arohnerdgrnbrg: that looks pretty good
15:51TimMcdgrnbrg: You could check if the clojure.set/intersection of their 'keys is non-empty.
15:51dgrnbrgwhich would be faster?
15:51TimMcWell, if you're merging anyhow, just use merge-with.
15:51dgrnbrgif i'm doing this of 1M sets that are disjoint
15:51TimMchah
15:51dgrnbrgand throwing an exception is ok?
15:51TimMcSure.
15:51dgrnbrgI keep going back and forth on exceptions in a functional language
15:51arohnermy guess is merge-with, because you'll stop at the first fail, rather than waiting for the whole intersection to finish
15:52dgrnbrgTimMc: I'm actually writing a cycle simulator now
15:52TimMcdgrnbrg: If you want to be fancy, you could use scgilardi's slingshot lib and pass info up that way on what the colliding key was.
15:53dgrnbrgI like slingshot, and I am already using it for other, more powerful things :)
15:53dgrnbrgyou had showed me your feedback project earlier
15:53TimMcIs this something that should never, ever happen unless there's a bug?
15:54dgrnbrgYes
15:58TimMcAssertionError.
16:01dgrnbrgTimMc: is it better to (throw (AssertionError. "non disjoint")) or (assert false "non disjoint")?
16:02TimMcthrow
16:02TimMcThere's no reason to do assert false.
16:18skelternetI don't see anything in noir to directly facilitate authentication. Is Sandbar pretty much the way to go?
16:20ibdknoxskelternet: what does directly facilitate authentication mean?
16:21ibdknoxall I ever end up doing is adding a pre-route here and there and adding some key to my session to determine if I'm auth'd
16:21daakucan't seem to figure out why travis-ci and one of my own machines fails with an almost identical java command with "java.lang.NoSuchMethodError: clojure.lang.KeywordLookupSite.<init>(ILclojure/lang/Keyword;)V"
16:22skelternetibdknox: well, in my dream world (add-middleware somemagic-that-forces-authentication-if-not)
16:22skelternetibdknox: given my newbieism, it is probable I am making it harder than it needs to be
16:22daakuthere seems to be a bunch of info available for that error via google, but nothing obvious about what is failing
16:23ibdknoxskelternet: have you taken a look at the blog example?
16:23_carlos_hi
16:23skelternetibdknox: for noir?
16:23ibdknoxskelternet: yeah
16:23skelternetibdknox: I've been googling all over compujre, noir, ring, sandbar.
16:24skelternetibdknox: the tutorial on the webnoir.org website?
16:24ibdknoxskelternet: it's a full sample project
16:24ibdknoxhm
16:25ibdknoxgithub seems to be having issues
16:25ibdknoxlol
16:25skelternetibdknox: oh, really? then that should let me figure out what namespace 'users/admin?' is coming from?
16:25daakuah, lein expects $HOME/.m2/repository/org/clojure/clojure/1.2.1/clojure-1.2.1.jar it seems :/
16:25skelternetibdknox: if I can just close one loop, I'm sure I can get some traction :)
16:26skelternetibdknox…will try to clone…hang on
16:27ibdknoxskelternet: https://refheap.com/paste/625 it's in models/user.clj :)
16:27skelternetibdknox: ok…now I see what you mean by github having probs
16:27Bronsaoh, then it's not just me
16:27ibdknoxskelternet: basically when you login, simply set a key i the session
16:27ibdknoxBronsa: nope, it's toast
16:27Bronsait took 2 minutes to push a commit
16:28Bronsai thought i had network problems
16:28ibdknoxit must've been me
16:28Bronsaahahah
16:28ibdknoxI pushed like 5 libs up in the past couple minutes ;)
16:28ibdknoxand it's back
16:28ibdknoxskelternet: https://github.com/ibdknox/Noir-blog/blob/master/src/noir_blog/models/user.clj
16:29skelternetibdknox: thanks. so it'shomegrown to the noir-blog example. not sophisticated. (which is fine)
16:29ibdknoxskelternet: yeah, it's usually specific to each app
16:29ibdknoxin some way
16:29ibdknoxI prefer the flexibility
16:29daakuibdknox: a clojurescript-y weekend for you
16:30skelternetI just didn't make the leap to mu. I figured that it users was coming from somehting in the stack: noir, compojure, ring...
16:30ibdknoxdaaku: yeah, people were yelling at me for not releasing my stuff :)
16:31skelternetibdknox: Thank you! you have de-snagged me.
16:31ibdknoxskelternet: awesome :)
16:32daakuibdknox: will check them out, i'm sure they're bad-ass
16:32ibdknoxwaltz is by far the coolest
16:32ibdknoxthe others are mostly the decomposition of pinot
16:32ibdknoxand a jQuery wrapper
16:32ibdknoxjayq does some really neat stuff to the jQuery object so that it acts just like any other clojure collection
16:36wyanis there an easy way to remap delete in paredit so that it fwd deletes?
16:42skelternet*sigh* github web site says "Something went wrong."
16:42skelternethard to argue with
16:46skelternetgithub looks back up here
16:47ibdknoxyep
16:47ibdknoxseems ok
16:50skelternetibdknox: I spoke too soon
16:51ibdknoxstill fine for me
16:51skelternetI'm seeing intermittent slothliness
17:01emezeskeibdknox: Would you be interested in a pull request for pinot that adds some more of hiccup's form_helpers and page_helpers stuff?
17:01ibdknoxemezeske: I would like such a thing for crate :)
17:02ibdknoxhttps://github.com/ibdknox/crate
17:02ibdknoxpinot is dissolving
17:02emezeskeI'm glad I asked, then!
17:03emezeskeI'm using hiccups right now, but it seems to be kind of a mess
17:03emezeskeSo if the hiccup stuff is going in crate, where is the dom stuff going?
17:03_carlos_was assert-true form replaced by another name
17:04ibdknoxemezeske: jayq
17:05emezeskeibdknox: so you are moving from goog to jquery?
17:05ibdknoxyessir
17:06ibdknoxthe goog libraries are terrible
17:06ibdknoxand I was rewriting jquery for absolutely no reason :)
17:06emezeskeyeah? I am using jquery right now in my project, just out of ignorance of goog
17:06ibdknoxall the arguments against jquery are also non-arguments
17:06ibdknoxI'll add the rationale to the readme at some point
17:06emezeskeI thought it couldn't be advanced-compiled?
17:07emezeske+1 to rationale, it would be great to hear from someone that's been in both trenches
17:07Raynesibdknox: Might want to spice up that readme a bit.
17:07ibdknoxemezeske: you shouldn't package jquery anyways, it should be google CDN'd (it'll already be cached)
17:08ibdknoxemezeske: given a wrapper, all the jquery names will appear exactly once
17:08ibdknoxthen the wrapper names will get munged
17:08ibdknoxso the size difference is in bytes
17:08emezeskevery nice
17:08ibdknoxand if you're optimizing at that level you shouldn't be using CLJS lol
17:08emezeske^_^
17:08emezeskeI'm not, I just thought that was one possible argument
17:08emezeske(devil's advocate)
17:08ibdknoxyeah, just giving my argument
17:09emezeskeis jayq usable at this point?
17:09Raynesibdknox: Wait, I shouldn't package jquery? Lies and slander!
17:09ibdknoxquite
17:09emezeskeI'm fine with alphatastic
17:09ibdknoxemezeske: I'm building really cool stuff with them, so yep :)
17:09ibdknoxRaynes: all of them need a lot of help.. I'm just putting them up for now, not really releasing
17:09emezeskeibdknox: That's great. jayq beats the pants off of my stupid-ass jquery stuff
17:10ibdknoxemezeske: using the jquery object like a clojure collection is pretty neat :)
17:10emezeskeibdknox: is any of your cool stuff open-sauce, for example code?
17:10ibdknoxemezeske: there's a fun example in the waltz readme
17:10emezeskeibdknox: great, thanks
17:10emezeskeibdknox: oh, pinot's remotes looked really cool; are you just using xhr for that directly now?
17:11ibdknoxemezeske: they're sticking around with a new addition
17:11ibdknoxa lazy-store
17:11ibdknoxworks like a map but fetches values from the server and caches them
17:11ibdknoxlib = fetch
17:11emezeskewhere will they go? jayq?
17:11emezeskewow nice
17:12ibdknoxhttps://groups.google.com/d/topic/clj-noir/wsCVajG0-YE/discussion
17:12emezeskeaha!
17:12emezeskethanks!
17:12ibdknoxI got the canvas stuff fast enough finally
17:13ibdknoxalso no more goog.dom.query dependency
17:13ibdknoxwhich is a huge win
17:13ibdknoxlol
17:13emezeskeI as actually just looking at pinot thinking, "this should be broken up into smaller pieces"
17:13ibdknoxwell now it is :)
17:13emezeskemind reader!
17:15emezeskethis is great. I was on the fence about reworking my app to use noir+pinot, but now I'm convinced, because I can do noir+the stuff I actually want
17:21Raynesemezeske: Did you just give drugs to ibdknox?
17:23emezeskeRaynes: Who's asking!?
17:23emezeskeYes!
17:23emezeskeNo.
17:23RaynesHaha
17:34tmciverIs it possible to def a var inside a funtion, or is this something only a macro can do?
17:34RaynesYou can, but you most likely don't actually want to.
17:35tmciverI was trying to be sneaky and do (def (symbol (str an-arg)) 5) inside a function. But I get an "First argument to def must be a symbol" error.
17:35ibdknoxtmciver: macro time
17:36ibdknoxbut Raynes's statement is probably true
17:36tmciverCan you define a macro inside of another macro? Does that even make sense?
17:36ibdknoxyou can, but it's starting to get into very difficult territory
17:36RaynesYes, you can. You can also tie yourself to a horse and slap it on the ass.
17:37RaynesYou probably don't want to that either.
17:37ibdknoxlol
17:37tmciverRaynes: that sounds like fun
17:37ibdknoxmacros writing macros is a scary evil place to be
17:37tmciverYeah, and I'm a noob at macros.
17:39raektmciver: you can do what def does at runtime using 'intern'
17:39amalloy(inc raek)
17:39raekbut you shouldn't do that at runtime
17:39muhoodoh http://dev.clojure.org/jira/browse/CLJS-141
17:39amalloybut also, probably better not to do any of those things
17:40raeksince modifying vars is not a thread safe operation
17:40raekand is probably bad for many other reasons
17:40tmciverYeah, that stuff sounds a little out of my league at this point.
17:41ibdknoxwtf is going on with github
17:42tmciverBut out of curiousity, why does (def (symbol (str an-arg)) 5) give me a "First argument to def must be a symbol" error?
17:42skelternetlots of tweets on it. dunno. may not be related but github had a party last night
17:42ibdknoxapparently their loadbalancer is freaking out
17:42ibdknoxhttps://status.github.com/
17:43amalloytmciver: because the first argument to def must be a symbol at compile-time, and you're giving it a list
17:43ibdknoxtmciver: because def doesn't evaluate its first argument
17:43tmciverAh, OK. Thanks.
17:43RaynesBecause amalloy said so.
17:44muhoowhat does github actually run on / written in?
17:44amalloymostly ruby, right?
17:44ibdknoxyes
17:44ibdknoxon rackspace
17:45RaynesTurtles all the way down.
18:11gtrakare you supposed to :import records?
18:13amalloyyes
18:22TimMctmciver: `(def ~name ~val-expr) in the macro
18:26RaynesYay! lein 2 native deps extraction.
18:26TimMctmciver: How goes the rewrite?
18:26TimMcRaynes: w00t!
18:48daakuit seems like my failure was this bug: https://github.com/technomancy/leiningen/issues/355 -- is there some way to exclude clojure from dev-dependencies as a whole instead of having to put a :exclude on each of my 4 dev-dependencies?
18:49daakuoh hey, :exclusions works for this. problem solved
18:53TimMcdaaku: If you had to use Maven for that, you'd have to exclude for each. :-(
18:54daakuTimMc: good thing i didn't :) travis-ci worked with this change
18:57RaynesLeiningen does not have any bugs.
18:57RaynesAnything that ever happens that isn't expected is a malfunction of your computer's hardware.
19:01ibdknoxRaynes: is your keyboard pluggedin? have you reset your router?
19:01RaynesHeh
19:03tmciverTimMc: eh, so so. I knew there was a reason I put off learning macros.
19:06TimMctmciver: I think this is probably a good usecase for pair-programming.
19:07tmciverYes. In fact...PM
19:07TimMcCurrently cooking, so may not be of *too* much use...
19:07tmciverWhat?! drop what you're doing and help me! ;)
19:08tmciverOK, I'll PM you - read it later.
19:08tmciverI wanted to follow the definition of import-field in the let,
19:08tmciveroop
19:16arohneris there a way to make git use a diffing algorithm that understands s-exprs? git merge always mangles my clojure
19:17TimMcarohner: Put your trailing parens on a separate line JUST KIDDING
19:18arohner:-)
19:22RaynesTimMc arohner: Psh. Real men put them in separate files.
19:24emezeskeibdknox: how up-to-date are the fetch/jayq/crate jars on clojars? they seem a bit old maybe
19:25ibdknoxone sec, I'll push all of them
19:25emezeskeyou da' man!
19:25ibdknoxeverything should be up to date
19:26ibdknoxyou'll have to clear out your ~/.m2/ cache for them though
19:27emezeskeryokai!
19:41gtrakis it alright to use repl-utils in dev-dependencies or is there a better way, like a global way?
19:43TimMcgtrak: I think you can 'require it in ~/.lein/init.clj or whatever it is
19:44TimMcor is it user.clj?
19:50gtrakTimMc: ah, thanks, I'll give that a go
19:56muhooiirc, git just calls the unix diff utility, no?
19:56gtrakoh, dammit, apropos is in clojure.repl :-)
19:56muhoothere may be flags to diff that handle lisps more elegantly. i'd imagine over the last 40 years someone would have come up with one.
19:56TimMcmuhoo: Yeah, but you can swap that out.
19:57TimMcOh, but it might require a line-oriented diff.
19:59TimMcIsn't it more like 50 years at this point? Kind of amazing.
19:59muhoodiff?
19:59muhoocan't be older than unix
19:59muhoowell, maybe it can. i dunno if it predated unix.
20:00TimMcOh, I thought you meant diff tools for lisp.
20:00TimMcnot the unix diff tool
20:01muhoodiff apparently was born in 1974. hmm, if there were a clojure-written diff tool that deallt with clojure code, and it could be plugged into git as a replacement for unix diff, that'd be kinda neat.
20:02TimMcI guess before that, people just diffed visually.
20:02gtrakmuhoo: once you start doing that, you might as well go full structural
20:03muhooheh, the unified diff format we know and love is only from 1990 (gnu)
20:04muhooi don't have time to try to write a diff/patch tool in clj that is semantically-aware of clojure and works with git, but it'd be a neat project.
20:05brehautdoesnt unix diff only so 2 point diff, and gits diff do 3 point?
20:05brehautstructural diffing is another usecase for the much discussed lossless reader
20:05Raynesdiff is my hero.
20:07clj_newb(ns ... (:import (foo.bar.doh Cat Dog))) ends up defining Cat, Dog in the local namespace. I want to be able to do foo.bar.blah.Cat foo.bar.blah.Dog, but not have Cat/Dog defined in the local namespace. How can I make this happen?
20:07clj_newbs/doh/blah/
20:09clj_newbbasically, I want to be able to :require java packages
20:10TimMcclj_newb: Just skip the import, then!
20:10TimMcIt totally works.
20:11TimMc,File
20:11clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: File in this context, compiling:(NO_SOURCE_PATH:0)>
20:11TimMc,java.io.File
20:11clojurebotjava.io.File
20:11clj_newbTimMc: how does this work
20:12clj_newbis the jvm , while interpreting clojure, is there like:
20:12clj_newbhmm, I see you need foo.bar.blah.Cat
20:12clj_newbso i'll just auto load it?
20:13TimMcclj_newb: I think so? Or maybe everything on the classpath is auotmatically loaded.
20:13TimMcAnyway, fully-resolved classnames simply work.
20:16amalloyevery class on the classpath is loaded as necessary
20:49oakwisehow do I properly wrap docstrings in clojure-mode emacs?
20:49TimMcAs in, rewrap the text?
20:49oakwiseyes
20:50oakwiseit seems to want to put wrapped lines at col 0
20:50oakwiseinstead of indented
20:50oakwisepossibly because I'm using evil mode's wrap and I don't know how to do it the emacs way :)
20:51TimMcHmm. I tend to not indent, actually.
20:52oakwiseTinMc: oh. Is that idiomatic?
20:53oakwisehm. core seems to indent afaict.
20:53TimMcNo idea. It seems readable, though, so I don't worry too much about it.
20:54TimMcoakwise: Core is a mish-mash of different coding styles.
20:54oakwisefair
20:54dgrnbrgwhat namespace is -?> in?
20:56gtrakI just popped the macro cherry
20:56gtrakwatch out, world!
20:57TimMcdgrnbrg: I don't think it made it out of contrib.
20:57dgrnbrgah
20:58dgrnbrgI have another way with if-let
20:58TimMcYou could write it yourself, too.
20:58dgrnbrgbrain...hurts...
20:58TimMcWait, there's a reference to "incubator" in my chat logs...
20:59TimMcdgrnbrg: https://github.com/clojure/core.incubator
21:00dgrnbrgTimMc: awesome, thanks!
21:10oakwiseTimMc: if you're curious, using technomancy's clojure-mode and then `M-x clojure-fill-docstring` did what I was looking for
21:11cliffordjamescan someone explain a clojure idiom for traversing a lazy-seq? like seq.each { ... } if you are familiar w/ ruby or groovy. Should i use recur?
21:11dgrnbrgcliffordjames: do you want each{} like in groovy or collect{} or inject{}?
21:12dgrnbrgthat is, do you want to have side effects be the purpose or do you want to build a new result?
21:12chjamesbuild a new result in this case
21:12dgrnbrggroovy's collect is clojure's map
21:12dgrnbrgapproximately, but clojure's is more powerful
21:12dgrnbrggroovy's inject is clojure's reduce, basically
21:12chjamesand that doesn't load the whole seq in memory right?
21:13chjamesok
21:13dgrnbrgit's all lazy
21:13chjamescool
21:13dgrnbrgyou can use doseq to force the evaluate of a lazy sequence RIGHT NOW and throw away the result (only side effects)
21:14dgrnbrgdoall does the same, but retains the head, so that the sequence is resident in memory
21:14chjameswell i am parsing a lazy seq from a csv library so basically i just want to map my 'parse' function onto the seq and return the result as a collection
21:15TimMcYeah, map is the answer.
21:15dgrnbrgif you want python-style comprhensions, check out for
21:21dgrnbrgI want to write this--how can I? (let [x [(fn [] x) 2]])
21:22dnolendgrnbrg: not possible
21:22dgrnbrgI see
21:23dnolendgrnbrg: I think Scheme-like letrec would make that work, but no one's stepped up with a patch
21:24dgrnbrgdnolen: That's what it seems like to me
21:24dgrnbrgI know that letfn has special recursion support
21:24dgrnbrgfor now, i'll use the fact that I have referential transparency to recur at a different level
21:43chjamesis there a way to make multimethods (declared with defmethod) private (like defn- does for funcs) ?
21:43gtrakso, if I want to run a macro a number of times in my ns, can I do it with a for?
21:43dgrnbrggtrak: no, since macros happen before code gets executed
21:44dgrnbrgchjames: maybe try (defmulti name {:private true} …)
21:44gtrakfor itself is a macro
21:44gtrakso, I should wrap the for in a macro and call it perhaps?
21:45dgrnbrgchjames: many def macros accept the meta list, and I think :private makes it private
21:45dgrnbrggtrak: what are you trying to do? what you've said so far doesn't make enough sense to me
21:45clj_newbis there a way to auto serialize defrecord ?
21:45gtrakdgrnbrg: basically I've made a macro that creates deftests for me based on a list of filenames, I'll paste in a sec
21:46chjamesok...i saw that in the clojure.java.io code here: http://bit.ly/zv35uZ that it was putting a bunch of defmethods for do-copy into the public ns
21:46gtrakdgrnbrg: ah, I think it was a name collision for my variable causing a problem, seems to work now
21:47chjames(at least it appeared to be...i'm new to clojure)
21:54gtrakdgrnbrg: so, now it's only doing the last in the list :-) https://gist.github.com/1742220
21:54gtrakbut it's printing all of them
21:54dgrnbrgexactly
21:55dgrnbrgremember, a macro returns a piece of code to get pasted in
21:55gtrakah,
21:55gtrakbut you can see what I'm trying to do :-)
21:56dgrnbrgyou need to do something like (def my-tests (map (fn [t] `(create-test ~t nil)) inputs))
21:56dgrnbrgthen, do `(do ~@my-tests) at the end of the create-tests macro
21:56gtrakyea, I was just thinking of wrapping the for in a do
21:56dgrnbrg(but use a let instead)
21:57gtrakwhy the splice? i haven't used one of those yet
21:57dgrnbrgthe map is making a list of the syntax bits that say (create-test t nil)
21:57dgrnbrgand you want to generate something like (do (create-test t0 nil) (create-test t1 nil) (create-test t2 nil))
21:58dgrnbrgso you splice all the syntactic bits into the do
22:00gtrakah, so is the splice just un-nesting a seq?
22:00dgrnbrgyeah
22:00dgrnbrgsuppose x = [1 2]
22:01dgrnbrgthen `(do ~x) is '(do [1 2])
22:01dgrnbrgand `(do ~@x) is '(do 1 2)
22:01gtraklike a apply kind of
22:02dgrnbrgit's really like a splice
22:02dgrnbrg;)
22:02gtrakthanks
22:06clj_newbthis is the question I should have asked ages ago. After defining (defprotocol IFoo ...), how do I check if a given object satisfies protocol IFoo ?
22:07dgrnbrg,(doc satisfies?)
22:07clojurebot"([protocol x]); Returns true if x satisfies the protocol"
22:11gtrakworks
22:13gtrakit's odd that macros are expanded at compile-time, but the run-time initialization can be scattered around it physically above and below in source code
22:17clj_newbdumb question
22:17clj_newbhow doesa functions vs protocls get resolved?
22:18clj_newbi.e. suppose I define a (IOpen ... (open [ ... ])) and a (defn open [... ])
22:18clj_newbhow does clojure figure out which open gets resolved?
22:18brehautprotocols create functions in the namespace they are defined in
22:18clj_newbbrehaut: are these "functions" really multimethods that dispatch solely on the first argument?
22:18brehautno
22:18brehautwhat would the point of that be? we already have multis
22:20clj_newbbrehaut: how are functions defined by protocols implemented?
22:20brehautmagic
22:20clj_newbgryffindor or slytherin magic?
22:21brehautalhazreds
22:21brehauta protocol creates a backing interface, a series of functions for each method in the protocl, and a protocol map thing
22:22brehautimplementations either a) directly implement the interface when defined (using deftype or defrecord frinstance and implementing the protocol in the definition) or b) use extend-type or extend-protocol which updates the protocol map thing
22:23brehautclj_newb: open up a repl, create a simple protocol and examining the objects and calling (class …) and (supers (class …)) on the various bits
22:25brehautmost of the magic happens inside the functions though; they (i think) use javas type directed polymorphism and implement call-site caches to determine the implementation function
22:25brehauts/function$/method/
22:25clj_newbbrehaut: "examine" an object <-- something more advanced than pprint?
22:26brehauteven simpler
22:26brehautjust enter the symbol and press enter
22:26brehautits particularly revealing for the protocol itself
22:27brehauteg, (defprotocol Foo (frobtz [this that])) Foo
22:27brehaut(class Foo) is also interesting
22:27clj_newbinteresting
22:27clj_newbI like how everything is basically a gigantic map
22:28brehautjoy of clojure has a good section on protocols
22:28brehauttheres some cool stuff on creating mixin implementations
22:29brehaut(which takes advantage of the fact that its all maps under the hood)
23:05chjamesarrg...i'm still unsure about the laziness in clojure...can someone tell me if this code is reading the whole lazy-seq from (csv/read-csv rdr) in memory in the (read-hitting-stats) f()? https://gist.github.com/1742587
23:07ibdknoxchjames: doall forces the lazy-seq to be realized
23:07brehautchjames: the doall in read-hitting-stats is going to fully realize the seq, effectively stripping out the laziness
23:07ibdknoxso yes
23:07ibdknoxhah!
23:07ibdknoxI won this time ;)
23:07brehautrats!
23:09chjamesok...that makes sense...i tried to write a lazy version and i kept getting IOExceptions due to the (with-open ...) closing the stream...so I think i HAVE to realize the collection unless i do everything with an iterator style approach and act on individual rows
23:11ibdknoxchjames: correct
23:17Raynesibdknox: You've been around more today than you have in your whole IRC career.
23:17ibdknoxtotally not true
23:17ibdknoxI used to be on a bunch for a while
23:17Raynestechnomancy_: is annoyingly absent today.
23:17RaynesI finally implement native deps
23:17ibdknoxlol
23:17RaynesHow dare he not be around to praise me!