#clojure log - Feb 04 2012

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:09 _phil: can i use a single quote as part of an identifier, i.e. (def a' 5)?

0:10 it seems to work but i dont know if there arent any implications, e.g. with macros

0:10 guns: _phil: there are clojure functions like +' and *'

0:10 _phil: guns: so no problem?

0:11 guns: _phil: I assume not. I use it all the time myself (nice mathy feel), but I'm pretty new to Clojure too

0:12 _phil: guns: haha, bad bad haskell :D

0:13 guns: silly to name iterations of a variable x, x1, x2 ...

0:13 jkkramer1: trailing apostrophes are supported in clojure 1.3+. doesn't work in clojure 1.2

0:15 _phil: jkkramer1: thx

5:07 tfaro: .

5:11 Raynes: ,

5:11 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>

5:23 AimHere: ,(Thread/sleep 1000000000000)

5:24 clojurebot: Execution Timed Out

5:24 AimHere: Heh

5:50 bkolobara: Hi 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?

6:04 raek: bkolobara: 'doc' is not in clojure.core since Clojure 1.3. you need to run (use 'clojure.repl) in the repl.

6:05 "lein repl" does that step automatically for the 'user' namespace

6:44 bkolobara: raek: tnx

7:12 cmajor7: if 'defn' just a macro that is the "Same as (def name (fn [params* ] exprs*))", how come:

7:13 " (def f-seq (map f (iterate inc 0))) " returns lazy results with caching

7:13 and " (defn f-seq [] (map f (iterate inc 0))) " does not?

7:14 raek: the (def f-seq (map f ...)) example does not match the (def name (fn ...)) pattern...

7:14 since (map ...) does not return a function

7:15 each time the second f-seq function you defined is called a new lazy-seq is constructed

7:15 cmajor7: raek: thank you. so why is def caches and defn does not in this case?

7:16 raek: (which is cached)

7:16 cmajor7: the first and second example are not of the same types!

7:16 the body of a (fn ...) expression is never cached

7:16 amro: cmajor7: your second example is missing a (fn ...)

7:17 er, first

7:17 cmajor7: amro: 'f' is a hypothetical (any function)

7:17 raek: as amro said, if you replace the first one with (def f-seq (fn [] (map f (iterate inc 0)))), _then_ they are equivalent

7:18 then, both versions are _functions_, which create _new_ lazy-seqs when they are called

7:19 cmajor7: right, and hence _not_ cached.. ?

7:19 raek: the particular lazy-seq that a function returns is cached

7:19 cmajor7: "(doall (take 3 f-seq))", and then "(println (nth f-seq 2)) ; uses cached result -> 2.0"

7:20 raek: so if you traverse that particular lazy-seq multiple times, f will only be called once per element

7:20 but each invocation of f-seq makes a new lazy-seq with its own caching

7:21 cmajor7: yes, but in that example you use the same lazy-seq object in both cases

7:21 cmajor7: right.. that is the caching I am referring to

7:22 raek: ok, then you have to keep a reference to the lazy-seq object you want to keep

7:22 cmajor7: I thought that 'defn' is just a "(def name (fn [params* ] exprs*))"

7:22 raek: it is

7:22 cmajor7: hence a confusion where I see def/defn resulting in different behavior

7:23 raek: but what it isn't is "(def name exprs*)"

7:23 do you see the difference?

7:23 (defn foo ...) = (def foo (fn ...)) is true, but you did not use that fact in your example at all

7:24 cmajor7: are 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?

7:24 raek: no, that part is a lazy-seq in both cases

7:25 but "f-seq" becomes a function in the first case and a lazy-seq in the second

7:25 function that take zero arguments are not the same as the values in their bodies

7:26 (defn x [] y) is the same as (def x (fn [] y)), that is, "x is bound to a nullary function that returns y"

7:27 cmajor7: does "(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?

7:27 raek: (def x y) is not the same, and means "x is bound to y"

7:27 cmajor7: yes, it does

7:27 cmajor7: aha.. I think I see it now

7:27 thank you!

7:27 raek: that's what (defn x [] y) --> (def x (fn [] y)) is all about!

7:28 cmajor7: I was a bit confused by the "undercover" wrapping :)

7:28 I see now it makes perfect sense: every time you call x, an underlying fn is reevaluated

7:29 vs. just a binding where the reference points to a lazy-seq

7:32 raek: yes, the body of the function is evaluated each time the function is called

7:33 (i.e. only the "y" part and not the whole "(fn [] y)" part)

7:33 cmajor7: raek: right, thanks!

7:38 echo-area: Is 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?

7:47 Hmm. `assoc' can operate on a vector.

8:04 AimHere: echo-area > if you're looking for an analogue for a function between collection types, then try the function you want the analogue of!

8:26 gfredericks: what're these three elisp files in my .emacs.d/swank directory? should I be versioning them or ignoring them?

8:38 the-kenny: gfredericks: I ignore them

8:40 gfredericks: the-kenny: okay, thanks

8:41 the-kenny: gfredericks: 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

8:42 gfredericks: noted

8:44 miniyuki: to extract the set of keys of a list of hash

8:45 it there a better way than (distinct (mapcat keys [{:prop1 "any"} {:prop2 "any"} {:prop1 "any" :prop3 "any"}]))

8:46 expected result (:prop1 :prop2 :prop3)

8:48 the-kenny: If you want a real set, use `set' instead of `distinct'

8:48 gfredericks: I'm trying to think if there are any performance issues with that...

8:48 probably laziness would make it okay

8:50 miniyuki: thanks

9:12 TimMc: gfredericks: This is a test of the code we were discussing: https://github.com/timmc/kpawebgen/blob/master/clj/test/kpawebgen/test/munge.clj#L40

9:12 gfredericks: And this is what implements it: https://github.com/timmc/kpawebgen/blob/master/clj/src/kpawebgen/munge.clj#L35

9:16 gfredericks: man I need a better way to get links out of a terminal

9:16 TimMc: I've never seen an ASCII graph drawn in comments before

9:25 the-kenny: I'm pretty sure emacs has support for this :)

9:25 TimMc: gfredericks: It was the only way I could keep it straight in my head.

9:38 pyr: hey! anyone used cascalog with s3 before ?

10:24 dribnet: Hi. Can anyone help me understand gen-class, specifically why I'm not making the constructor I think I'm making?

10:26 the-kenny: dribnet: Don't ask to ask.

10:27 dribnet: I have a very short :gen-class. It has :constructors {[] [foo]} and then later (defn -construct [] [[(thing)] ])

10:28 Yet when I try to call (class.) later to construct with no args, i get "No matching ctor"

10:29 obviously i have the wrong model of how this is supposed to work.

10:30 I don't understand how the (classname.) could fail to resolve at compilation if i've declared both :constructors {[] []} and the -init [] methods.

10:36 Basically my question is: what governs the type of constructor available in the class generated by gen-class?

10:38 If 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:45 is there an easy way to make lein launch the repl in 1.3.0 by default?

12:16 dgrnbrg: if 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:24 arohner: dgrnbrg: use a let to store the old version before binding the new one

12:24 clojurebot: Pardon?

12:25 arohner: (let [old-fn f] (binding [f new-fn] (f) (old-f)))

12:30 dgrnbrg: I did this: (let [old (bound-fn [args] (apply myfunc args))] (binding [myfunc old] (myfunc))

12:30 arohner, and that caused a stack overflow

12:31 I don't see why I can't use bound-fn here

12:33 Is there a way to make a defn ^:dynamic?

12:42 arohner: dgrnbrg: 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:42 dgrnbrg: I want to preserve the binding under a different binding

12:42 arohner: it's causing a stack overflow because you're calling the same fn recursively

12:42 dgrnbrg: It seems like the logic should work fine in both cases

12:43 I would expect the bound-fn to cause the recursive call to myfunc to use the old binding

12:43 since the bound-fn should save the binding from when I called it

12:43 arohner: it doesn't work like that

12:43 bindings are a thread-local stack. new calls to binding push values onto the stack

12:43 dgrnbrg: so bound-fn is just pushing onto the stack?

12:43 not replacing the stack?

12:44 arohner: let's talk about only binding for a second

12:44 binding pushes onto the stack

12:44 but bindings are only thread-local

12:44 so bound-fn is for situations where you want to take the binding stack, and use the same values in another thread

12:44 dgrnbrg: exactly

12:44 arohner: are you using another thread here?

12:45 dgrnbrg: I'd expect it to work by saving the stack at the time bound-fn is called

12:45 arohner: the standard, idiomatic answer here is to use a let to save the value you care about

12:45 dgrnbrg: and 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:46 but I guess it's not swapping the stacks, but instead just pushing the saved stack on top of whatever's already there

12:46 which is why it overflows

12:46 is that the correct interpretation?

12:52 tjgillies: does clojures STM have the same type of role as monads in haskell?

12:52 "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:52 brehaut: tjgillies: no

12:53 tjgillies: it has a similar role to the STM monad in haskell, not monads in general

12:54 tjgillies: i 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:54 which is the whole point of the persistent data structures, thats why i asked if they play similar roles

12:54 handling concurrency and side effects, not so much chaining

12:55 Scriptor: er, persistent data structures don't really do anything special to avoid side effects, I think

12:56 well, they avoid side effects

12:56 but they don't do anything special to handle them

12:56 brehaut: haskell has persistent datastructures to, and it doesnt use monads to implement them

12:56 arohner: dgrnbrg: it does save the stack, but you're still going to have a stack overflow

12:56 brehaut: all the things haskell uses monads for can be implemented without them and still have pure functional semantics (eg, let, for, do)

12:57 monads are just one (very elegant) way of defining them

12:58 tjgillies: brehaut: ah thanks

12:59 brehaut: tjgillies: look at algo.monads for a clojure implemenetation

12:59 tjgillies: brehaut: already was looking at it

12:59 dgrnbrg: Is there an implementation of a zipper that works on nested maps and vectors?

13:00 tjgillies: what does haskell use to update persistent data structures? do they have something like refs

13:00 brehaut: tjgillies: thats a confusing question

13:00 you dont update persistent data structure

13:00 thats the point

13:01 but haskell does have a variety of reference types that are similar to clojures reference types

13:01 tjgillies: brehaut: you don't update them? i thought they were a tree structure that had history of previous state

13:01 brehaut: IORefs in the IO monad, TVars in the STM monad, others for other contexts

13:02 tjgillies: i guess im using "update" wrong

13:02 brehaut: ,(let [one {:a 1 :b 2} two (assoc a :b 3}], [a b])

13:02 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unmatched delimiter: }>

13:02 brehaut: ,(let [one {:a 1 :b 2} two (assoc a :b 3)] [a b])

13:02 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0)>

13:03 brehaut: ,(let [one {:a 1 :b 2} two (assoc one :b 3)] [one two])

13:03 clojurebot: [{:a 1, :b 2} {:a 1, :b 3}]

13:03 arohner: dgrnbrg: yes, zippers work on maps and vectors

13:03 dgrnbrg: arohner: I meant more of an existing API

13:03 it's tricky deciding what the API for traversing nested maps should look like in a zipper

13:03 arohner: tjgillies: 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:04 tjgillies: i.e. the "update" returns a new tree, but most of the tree that didn't change shares pointers with the existing tree

13:04 tjgillies: arohner: aaah. thnx

13:05 dgrnbrg: tjgillies: http://blog.higher-order.net/2010/08/16/assoc-and-clojures-persistenthashmap-part-ii/

13:05 pretty pictures of how it works

13:05 This image in particular is enlightening: http://blog.higher-order.net/files/clj/persistenthashmap-pathcopy.png

13:13 tjgillies: dgrnbrg: thnx

13:13 dgrnbrg: tjgillies: I found that post very illuminating

13:27 thheller: hey, I'm playing with clojurescript. is there any way to use console.log for output?

13:28 completely new to clojure and I really would like to see my data at certain points :P

13:29 (print x) only complains with "No *print-fn* fn set for evaluation environment"

13:29 brehaut: im guessing (because i dont know clojurescript) but something like (.log console "message")

13:30 thheller: ah been there

13:30 (.log js/console "bla")

13:30 that works yeah, but though maybe i can get print&co hooked up somehow

13:33 dgrnbrg: thheller: could you try (defn *print-fn* [& strs] (.log js/console (apply print-str strs)))

13:33 (I've never used clojurescript

13:33 )

13:36 thheller: print-str doesnt work

13:37 str works

13:37 but ouput is useless

13:37 too many lines :P

13:38 (defn log [& args]

13:38 (.log js/console args))

13:38 but output is a cljs.core.IndexedSeq

13:38 how do i turn that into a list? :P

14:06 dgrnbrg: thheller: that is getting way further into clojurescript than I know

14:10 ibdknox: thheller: if you want println to work you just need to add (set! *print-fn* #(.log js/console %))

14:11 somewhere toward the top of your cljs

14:11 thheller: hmm that kinda works

14:12 ibdknox: kinda?

14:12 thheller: (print {:hello "world})

14:12 logs as 5 lines :P

14:12 7 actually

14:13 ibdknox: oh right

14:13 just a sec

14:14 thheller: varargs in js seems fuzzy

14:15 mfex: thheller: how are you running clojurescript?

14:16 thheller: compiled as js und in the browser

14:16 (chrome)

14:17 mfex: I just use a console.log, although not often in advande compiled js

14:18 thheller: for "native" js types that is fine yeah

14:18 but (.log js/console {:hello "world"})

14:18 chrissbx: Are there character functions or predicates like "lower-case?" somewhere?

14:18 thheller: prints cljs.core.ObjMap

14:18 mfex: you can use pr-str to print cljs type things

14:19 ie compare (console.log {:a 2}) and (console.log (pr-str {:a 2}))

14:19 thheller: ah excellent

14:20 thats what i was looking for :)

14:20 ibdknox: wow

14:20 this is ridiculous

14:20 thheller: thx

14:21 ibdknox: it actually looks like the way the print-fn stuff was implemented is busted for the browser case

14:22 thheller: :P

14:22 (defn log [& args]

14:22 (.log js/console (pr-str args)))

14:22 is close enough to what I had in mind

14:22 ibdknox: yeah

14:23 that's what I did previous to print-fn existing

14:23 it's actually kind of nice not to do that sometimes though

14:23 for example, you can inspect dom objects if you don't pr-str them

14:23 which is often very useful

14:23 thheller: hmm true

14:25 but i'm fairly solid on the javascript/dom side of things

14:25 only the cljs part is confusing

14:35 ibdknox: pinot is getting dismantled :)

14:59 mfex: MJosa1

14:59 whoops

15:07 anttih: I'm trying to use a library from clojure.contrib but nowhere does it say how I should install the package.

15:09 the contrib homepage does not talk about this at all. Is there a reason for this? http://richhickey.github.com/clojure-contrib/index.html

15:09 lazybot: Nooooo, 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:09 Raynes: Only half-helpful.

15:09 anttih: that does not help at all

15:10 I've now tried to figure this out for an hour

15:10 Raynes: Well, 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:10 Things work a little differently in Clojure. It can take you off guard.

15:11 anttih: Raynes: I have leiningen and know how to use it, but I don't know which jar to use.

15:11 Raynes: Okay. Clojure contrib was recently split up into multiple libraries. Which library specifically do you want to use?

15:11 anttih: Raynes: http.agent

15:12 Raynes: I'm pretty sure that library was deprecated. clj-http is an excellent HTTP client though. Let me pull it up for you.

15:12 https://github.com/dakrone/clj-http

15:13 The latest released version is 0.3.1.

15:13 anttih: Raynes: ah, saw that one

15:13 ok, thanks

15:13 Raynes: anttih: Have you created a project yet?

15:13 anttih: Raynes: I have

15:14 Raynes: I'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:14 Open project.clj in your text editor and add [clj-http "0.3.1"] to your :dependencies list.

15:14 anttih: Raynes: I know how to do that :-), but thanks

15:14 Raynes: Alright, cool.

15:15 Sorry you've had so much trouble. :(

15:33 skelternet: I am making this harder than it is.

15:50 dgrnbrg: Is 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:50 arohner: dgrnbrg: that looks pretty good

15:51 TimMc: dgrnbrg: You could check if the clojure.set/intersection of their 'keys is non-empty.

15:51 dgrnbrg: which would be faster?

15:51 TimMc: Well, if you're merging anyhow, just use merge-with.

15:51 dgrnbrg: if i'm doing this of 1M sets that are disjoint

15:51 TimMc: hah

15:51 dgrnbrg: and throwing an exception is ok?

15:51 TimMc: Sure.

15:51 dgrnbrg: I keep going back and forth on exceptions in a functional language

15:51 arohner: my guess is merge-with, because you'll stop at the first fail, rather than waiting for the whole intersection to finish

15:52 dgrnbrg: TimMc: I'm actually writing a cycle simulator now

15:52 TimMc: dgrnbrg: 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:53 dgrnbrg: I like slingshot, and I am already using it for other, more powerful things :)

15:53 you had showed me your feedback project earlier

15:53 TimMc: Is this something that should never, ever happen unless there's a bug?

15:54 dgrnbrg: Yes

15:58 TimMc: AssertionError.

16:01 dgrnbrg: TimMc: is it better to (throw (AssertionError. "non disjoint")) or (assert false "non disjoint")?

16:02 TimMc: throw

16:02 There's no reason to do assert false.

16:18 skelternet: I don't see anything in noir to directly facilitate authentication. Is Sandbar pretty much the way to go?

16:20 ibdknox: skelternet: what does directly facilitate authentication mean?

16:21 all 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:21 daaku: can'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:22 skelternet: ibdknox: well, in my dream world (add-middleware somemagic-that-forces-authentication-if-not)

16:22 ibdknox: given my newbieism, it is probable I am making it harder than it needs to be

16:22 daaku: there seems to be a bunch of info available for that error via google, but nothing obvious about what is failing

16:23 ibdknox: skelternet: have you taken a look at the blog example?

16:23 _carlos_: hi

16:23 skelternet: ibdknox: for noir?

16:23 ibdknox: skelternet: yeah

16:23 skelternet: ibdknox: I've been googling all over compujre, noir, ring, sandbar.

16:24 ibdknox: the tutorial on the webnoir.org website?

16:24 ibdknox: skelternet: it's a full sample project

16:24 hm

16:25 github seems to be having issues

16:25 lol

16:25 skelternet: ibdknox: oh, really? then that should let me figure out what namespace 'users/admin?' is coming from?

16:25 daaku: ah, lein expects $HOME/.m2/repository/org/clojure/clojure/1.2.1/clojure-1.2.1.jar it seems :/

16:25 skelternet: ibdknox: if I can just close one loop, I'm sure I can get some traction :)

16:26 ibdknox…will try to clone…hang on

16:27 ibdknox: skelternet: https://refheap.com/paste/625 it's in models/user.clj :)

16:27 skelternet: ibdknox: ok…now I see what you mean by github having probs

16:27 Bronsa: oh, then it's not just me

16:27 ibdknox: skelternet: basically when you login, simply set a key i the session

16:27 Bronsa: nope, it's toast

16:27 Bronsa: it took 2 minutes to push a commit

16:28 i thought i had network problems

16:28 ibdknox: it must've been me

16:28 Bronsa: ahahah

16:28 ibdknox: I pushed like 5 libs up in the past couple minutes ;)

16:28 and it's back

16:28 skelternet: https://github.com/ibdknox/Noir-blog/blob/master/src/noir_blog/models/user.clj

16:29 skelternet: ibdknox: thanks. so it'shomegrown to the noir-blog example. not sophisticated. (which is fine)

16:29 ibdknox: skelternet: yeah, it's usually specific to each app

16:29 in some way

16:29 I prefer the flexibility

16:29 daaku: ibdknox: a clojurescript-y weekend for you

16:30 skelternet: I just didn't make the leap to mu. I figured that it users was coming from somehting in the stack: noir, compojure, ring...

16:30 ibdknox: daaku: yeah, people were yelling at me for not releasing my stuff :)

16:31 skelternet: ibdknox: Thank you! you have de-snagged me.

16:31 ibdknox: skelternet: awesome :)

16:32 daaku: ibdknox: will check them out, i'm sure they're bad-ass

16:32 ibdknox: waltz is by far the coolest

16:32 the others are mostly the decomposition of pinot

16:32 and a jQuery wrapper

16:32 jayq does some really neat stuff to the jQuery object so that it acts just like any other clojure collection

16:36 wyan: is there an easy way to remap delete in paredit so that it fwd deletes?

16:42 skelternet: *sigh* github web site says "Something went wrong."

16:42 hard to argue with

16:46 github looks back up here

16:47 ibdknox: yep

16:47 seems ok

16:50 skelternet: ibdknox: I spoke too soon

16:51 ibdknox: still fine for me

16:51 skelternet: I'm seeing intermittent slothliness

17:01 emezeske: ibdknox: Would you be interested in a pull request for pinot that adds some more of hiccup's form_helpers and page_helpers stuff?

17:01 ibdknox: emezeske: I would like such a thing for crate :)

17:02 https://github.com/ibdknox/crate

17:02 pinot is dissolving

17:02 * emezeske looks at crate

17:02 emezeske: I'm glad I asked, then!

17:03 I'm using hiccups right now, but it seems to be kind of a mess

17:03 So 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:04 ibdknox: emezeske: jayq

17:05 emezeske: ibdknox: so you are moving from goog to jquery?

17:05 ibdknox: yessir

17:06 the goog libraries are terrible

17:06 and I was rewriting jquery for absolutely no reason :)

17:06 emezeske: yeah? I am using jquery right now in my project, just out of ignorance of goog

17:06 ibdknox: all the arguments against jquery are also non-arguments

17:06 I'll add the rationale to the readme at some point

17:06 emezeske: I thought it couldn't be advanced-compiled?

17:07 +1 to rationale, it would be great to hear from someone that's been in both trenches

17:07 Raynes: ibdknox: Might want to spice up that readme a bit.

17:07 ibdknox: emezeske: you shouldn't package jquery anyways, it should be google CDN'd (it'll already be cached)

17:08 emezeske: given a wrapper, all the jquery names will appear exactly once

17:08 then the wrapper names will get munged

17:08 so the size difference is in bytes

17:08 emezeske: very nice

17:08 ibdknox: and if you're optimizing at that level you shouldn't be using CLJS lol

17:08 emezeske: ^_^

17:08 I'm not, I just thought that was one possible argument

17:08 (devil's advocate)

17:08 ibdknox: yeah, just giving my argument

17:09 emezeske: is jayq usable at this point?

17:09 Raynes: ibdknox: Wait, I shouldn't package jquery? Lies and slander!

17:09 ibdknox: quite

17:09 emezeske: I'm fine with alphatastic

17:09 ibdknox: emezeske: I'm building really cool stuff with them, so yep :)

17:09 Raynes: all of them need a lot of help.. I'm just putting them up for now, not really releasing

17:09 emezeske: ibdknox: That's great. jayq beats the pants off of my stupid-ass jquery stuff

17:10 ibdknox: emezeske: using the jquery object like a clojure collection is pretty neat :)

17:10 emezeske: ibdknox: is any of your cool stuff open-sauce, for example code?

17:10 ibdknox: emezeske: there's a fun example in the waltz readme

17:10 emezeske: ibdknox: great, thanks

17:10 ibdknox: oh, pinot's remotes looked really cool; are you just using xhr for that directly now?

17:11 ibdknox: emezeske: they're sticking around with a new addition

17:11 a lazy-store

17:11 works like a map but fetches values from the server and caches them

17:11 lib = fetch

17:11 emezeske: where will they go? jayq?

17:11 wow nice

17:12 ibdknox: https://groups.google.com/d/topic/clj-noir/wsCVajG0-YE/discussion

17:12 emezeske: aha!

17:12 thanks!

17:12 ibdknox: I got the canvas stuff fast enough finally

17:13 also no more goog.dom.query dependency

17:13 which is a huge win

17:13 lol

17:13 emezeske: I as actually just looking at pinot thinking, "this should be broken up into smaller pieces"

17:13 ibdknox: well now it is :)

17:13 emezeske: mind reader!

17:13 * emezeske gives bumps to ibdknox.

17:15 emezeske: this 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:21 Raynes: emezeske: Did you just give drugs to ibdknox?

17:23 emezeske: Raynes: Who's asking!?

17:23 Yes!

17:23 No.

17:23 Raynes: Haha

17:34 tmciver: Is it possible to def a var inside a funtion, or is this something only a macro can do?

17:34 Raynes: You can, but you most likely don't actually want to.

17:35 tmciver: I 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:35 ibdknox: tmciver: macro time

17:36 but Raynes's statement is probably true

17:36 tmciver: Can you define a macro inside of another macro? Does that even make sense?

17:36 ibdknox: you can, but it's starting to get into very difficult territory

17:36 Raynes: Yes, you can. You can also tie yourself to a horse and slap it on the ass.

17:37 You probably don't want to that either.

17:37 ibdknox: lol

17:37 tmciver: Raynes: that sounds like fun

17:37 ibdknox: macros writing macros is a scary evil place to be

17:37 tmciver: Yeah, and I'm a noob at macros.

17:39 raek: tmciver: you can do what def does at runtime using 'intern'

17:39 amalloy: (inc raek)

17:39 raek: but you shouldn't do that at runtime

17:39 muhoo: doh http://dev.clojure.org/jira/browse/CLJS-141

17:39 amalloy: but also, probably better not to do any of those things

17:40 raek: since modifying vars is not a thread safe operation

17:40 and is probably bad for many other reasons

17:40 tmciver: Yeah, that stuff sounds a little out of my league at this point.

17:41 ibdknox: wtf is going on with github

17:42 tmciver: But out of curiousity, why does (def (symbol (str an-arg)) 5) give me a "First argument to def must be a symbol" error?

17:42 skelternet: lots of tweets on it. dunno. may not be related but github had a party last night

17:42 ibdknox: apparently their loadbalancer is freaking out

17:42 https://status.github.com/

17:43 amalloy: tmciver: because the first argument to def must be a symbol at compile-time, and you're giving it a list

17:43 ibdknox: tmciver: because def doesn't evaluate its first argument

17:43 tmciver: Ah, OK. Thanks.

17:43 Raynes: Because amalloy said so.

17:44 muhoo: what does github actually run on / written in?

17:44 amalloy: mostly ruby, right?

17:44 ibdknox: yes

17:44 on rackspace

17:45 Raynes: Turtles all the way down.

18:11 gtrak: are you supposed to :import records?

18:13 amalloy: yes

18:22 TimMc: tmciver: `(def ~name ~val-expr) in the macro

18:26 Raynes: Yay! lein 2 native deps extraction.

18:26 TimMc: tmciver: How goes the rewrite?

18:26 Raynes: w00t!

18:48 daaku: it 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:49 oh hey, :exclusions works for this. problem solved

18:53 TimMc: daaku: If you had to use Maven for that, you'd have to exclude for each. :-(

18:54 daaku: TimMc: good thing i didn't :) travis-ci worked with this change

18:57 Raynes: Leiningen does not have any bugs.

18:57 Anything that ever happens that isn't expected is a malfunction of your computer's hardware.

19:01 ibdknox: Raynes: is your keyboard pluggedin? have you reset your router?

19:01 Raynes: Heh

19:03 tmciver: TimMc: eh, so so. I knew there was a reason I put off learning macros.

19:06 TimMc: tmciver: I think this is probably a good usecase for pair-programming.

19:07 tmciver: Yes. In fact...PM

19:07 TimMc: Currently cooking, so may not be of *too* much use...

19:07 tmciver: What?! drop what you're doing and help me! ;)

19:08 OK, I'll PM you - read it later.

19:08 I wanted to follow the definition of import-field in the let,

19:08 oop

19:16 arohner: is there a way to make git use a diffing algorithm that understands s-exprs? git merge always mangles my clojure

19:17 TimMc: arohner: Put your trailing parens on a separate line JUST KIDDING

19:18 arohner: :-)

19:22 Raynes: TimMc arohner: Psh. Real men put them in separate files.

19:24 emezeske: ibdknox: how up-to-date are the fetch/jayq/crate jars on clojars? they seem a bit old maybe

19:25 ibdknox: one sec, I'll push all of them

19:25 emezeske: you da' man!

19:25 ibdknox: everything should be up to date

19:26 you'll have to clear out your ~/.m2/ cache for them though

19:27 emezeske: ryokai!

19:41 gtrak: is it alright to use repl-utils in dev-dependencies or is there a better way, like a global way?

19:43 TimMc: gtrak: I think you can 'require it in ~/.lein/init.clj or whatever it is

19:44 or is it user.clj?

19:50 gtrak: TimMc: ah, thanks, I'll give that a go

19:56 muhoo: iirc, git just calls the unix diff utility, no?

19:56 gtrak: oh, dammit, apropos is in clojure.repl :-)

19:56 muhoo: there 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:56 TimMc: muhoo: Yeah, but you can swap that out.

19:57 Oh, but it might require a line-oriented diff.

19:59 Isn't it more like 50 years at this point? Kind of amazing.

19:59 muhoo: diff?

19:59 can't be older than unix

19:59 well, maybe it can. i dunno if it predated unix.

20:00 TimMc: Oh, I thought you meant diff tools for lisp.

20:00 not the unix diff tool

20:01 muhoo: diff 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:02 TimMc: I guess before that, people just diffed visually.

20:02 gtrak: muhoo: once you start doing that, you might as well go full structural

20:03 muhoo: heh, the unified diff format we know and love is only from 1990 (gnu)

20:04 i 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:05 brehaut: doesnt unix diff only so 2 point diff, and gits diff do 3 point?

20:05 structural diffing is another usecase for the much discussed lossless reader

20:05 Raynes: diff is my hero.

20:07 clj_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:07 s/doh/blah/

20:09 basically, I want to be able to :require java packages

20:10 TimMc: clj_newb: Just skip the import, then!

20:10 It totally works.

20:11 ,File

20:11 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: File in this context, compiling:(NO_SOURCE_PATH:0)>

20:11 TimMc: ,java.io.File

20:11 clojurebot: java.io.File

20:11 clj_newb: TimMc: how does this work

20:12 is the jvm , while interpreting clojure, is there like:

20:12 hmm, I see you need foo.bar.blah.Cat

20:12 so i'll just auto load it?

20:13 TimMc: clj_newb: I think so? Or maybe everything on the classpath is auotmatically loaded.

20:13 Anyway, fully-resolved classnames simply work.

20:16 amalloy: every class on the classpath is loaded as necessary

20:49 oakwise: how do I properly wrap docstrings in clojure-mode emacs?

20:49 TimMc: As in, rewrap the text?

20:49 oakwise: yes

20:50 it seems to want to put wrapped lines at col 0

20:50 instead of indented

20:50 possibly because I'm using evil mode's wrap and I don't know how to do it the emacs way :)

20:51 TimMc: Hmm. I tend to not indent, actually.

20:52 oakwise: TinMc: oh. Is that idiomatic?

20:53 hm. core seems to indent afaict.

20:53 TimMc: No idea. It seems readable, though, so I don't worry too much about it.

20:54 oakwise: Core is a mish-mash of different coding styles.

20:54 oakwise: fair

20:54 dgrnbrg: what namespace is -?> in?

20:56 gtrak: I just popped the macro cherry

20:56 watch out, world!

20:57 TimMc: dgrnbrg: I don't think it made it out of contrib.

20:57 dgrnbrg: ah

20:58 I have another way with if-let

20:58 TimMc: You could write it yourself, too.

20:58 dgrnbrg: brain...hurts...

20:58 TimMc: Wait, there's a reference to "incubator" in my chat logs...

20:59 dgrnbrg: https://github.com/clojure/core.incubator

21:00 dgrnbrg: TimMc: awesome, thanks!

21:10 oakwise: TimMc: if you're curious, using technomancy's clojure-mode and then `M-x clojure-fill-docstring` did what I was looking for

21:11 cliffordjames: can 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:11 dgrnbrg: cliffordjames: do you want each{} like in groovy or collect{} or inject{}?

21:12 that is, do you want to have side effects be the purpose or do you want to build a new result?

21:12 chjames: build a new result in this case

21:12 dgrnbrg: groovy's collect is clojure's map

21:12 approximately, but clojure's is more powerful

21:12 groovy's inject is clojure's reduce, basically

21:12 chjames: and that doesn't load the whole seq in memory right?

21:13 ok

21:13 dgrnbrg: it's all lazy

21:13 chjames: cool

21:13 dgrnbrg: you can use doseq to force the evaluate of a lazy sequence RIGHT NOW and throw away the result (only side effects)

21:14 doall does the same, but retains the head, so that the sequence is resident in memory

21:14 chjames: well 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:15 TimMc: Yeah, map is the answer.

21:15 dgrnbrg: if you want python-style comprhensions, check out for

21:21 I want to write this--how can I? (let [x [(fn [] x) 2]])

21:22 dnolen: dgrnbrg: not possible

21:22 dgrnbrg: I see

21:23 dnolen: dgrnbrg: I think Scheme-like letrec would make that work, but no one's stepped up with a patch

21:24 dgrnbrg: dnolen: That's what it seems like to me

21:24 I know that letfn has special recursion support

21:24 for now, i'll use the fact that I have referential transparency to recur at a different level

21:43 chjames: is there a way to make multimethods (declared with defmethod) private (like defn- does for funcs) ?

21:43 gtrak: so, if I want to run a macro a number of times in my ns, can I do it with a for?

21:43 dgrnbrg: gtrak: no, since macros happen before code gets executed

21:44 chjames: maybe try (defmulti name {:private true} …)

21:44 gtrak: for itself is a macro

21:44 so, I should wrap the for in a macro and call it perhaps?

21:45 dgrnbrg: chjames: many def macros accept the meta list, and I think :private makes it private

21:45 gtrak: what are you trying to do? what you've said so far doesn't make enough sense to me

21:45 clj_newb: is there a way to auto serialize defrecord ?

21:45 gtrak: dgrnbrg: basically I've made a macro that creates deftests for me based on a list of filenames, I'll paste in a sec

21:46 chjames: ok...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:46 gtrak: dgrnbrg: ah, I think it was a name collision for my variable causing a problem, seems to work now

21:47 chjames: (at least it appeared to be...i'm new to clojure)

21:54 gtrak: dgrnbrg: so, now it's only doing the last in the list :-) https://gist.github.com/1742220

21:54 but it's printing all of them

21:54 dgrnbrg: exactly

21:55 remember, a macro returns a piece of code to get pasted in

21:55 gtrak: ah,

21:55 but you can see what I'm trying to do :-)

21:56 dgrnbrg: you need to do something like (def my-tests (map (fn [t] `(create-test ~t nil)) inputs))

21:56 then, do `(do ~@my-tests) at the end of the create-tests macro

21:56 gtrak: yea, I was just thinking of wrapping the for in a do

21:56 dgrnbrg: (but use a let instead)

21:57 gtrak: why the splice? i haven't used one of those yet

21:57 dgrnbrg: the map is making a list of the syntax bits that say (create-test t nil)

21:57 and you want to generate something like (do (create-test t0 nil) (create-test t1 nil) (create-test t2 nil))

21:58 so you splice all the syntactic bits into the do

22:00 gtrak: ah, so is the splice just un-nesting a seq?

22:00 dgrnbrg: yeah

22:00 suppose x = [1 2]

22:01 then `(do ~x) is '(do [1 2])

22:01 and `(do ~@x) is '(do 1 2)

22:01 gtrak: like a apply kind of

22:02 dgrnbrg: it's really like a splice

22:02 ;)

22:02 gtrak: thanks

22:06 clj_newb: this 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:07 dgrnbrg: ,(doc satisfies?)

22:07 clojurebot: "([protocol x]); Returns true if x satisfies the protocol"

22:11 gtrak: works

22:13 it'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:17 clj_newb: dumb question

22:17 how doesa functions vs protocls get resolved?

22:18 i.e. suppose I define a (IOpen ... (open [ ... ])) and a (defn open [... ])

22:18 how does clojure figure out which open gets resolved?

22:18 brehaut: protocols create functions in the namespace they are defined in

22:18 clj_newb: brehaut: are these "functions" really multimethods that dispatch solely on the first argument?

22:18 brehaut: no

22:18 what would the point of that be? we already have multis

22:20 clj_newb: brehaut: how are functions defined by protocols implemented?

22:20 brehaut: magic

22:20 clj_newb: gryffindor or slytherin magic?

22:21 brehaut: alhazreds

22:21 a protocol creates a backing interface, a series of functions for each method in the protocl, and a protocol map thing

22:22 implementations 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:23 clj_newb: open up a repl, create a simple protocol and examining the objects and calling (class …) and (supers (class …)) on the various bits

22:25 most 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:25 s/function$/method/

22:25 clj_newb: brehaut: "examine" an object <-- something more advanced than pprint?

22:26 brehaut: even simpler

22:26 just enter the symbol and press enter

22:26 its particularly revealing for the protocol itself

22:27 eg, (defprotocol Foo (frobtz [this that])) Foo

22:27 (class Foo) is also interesting

22:27 clj_newb: interesting

22:27 I like how everything is basically a gigantic map

22:28 brehaut: joy of clojure has a good section on protocols

22:28 theres some cool stuff on creating mixin implementations

22:29 (which takes advantage of the fact that its all maps under the hood)

23:05 chjames: arrg...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:07 ibdknox: chjames: doall forces the lazy-seq to be realized

23:07 brehaut: chjames: the doall in read-hitting-stats is going to fully realize the seq, effectively stripping out the laziness

23:07 ibdknox: so yes

23:07 hah!

23:07 I won this time ;)

23:07 brehaut: rats!

23:09 chjames: ok...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:11 ibdknox: chjames: correct

23:17 Raynes: ibdknox: You've been around more today than you have in your whole IRC career.

23:17 ibdknox: totally not true

23:17 I used to be on a bunch for a while

23:17 Raynes: technomancy_: is annoyingly absent today.

23:17 I finally implement native deps

23:17 ibdknox: lol

23:17 Raynes: How dare he not be around to praise me!

Logging service provided by n01se.net