#clojure log - Apr 06 2012

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

0:16 unlink: How do I write a compojure route that accesses request and captures a parameter from the route?

0:17 What I would like: (defroutes (GET "/user/:uid" (fn [request uid] ...)))

0:17 er, defroutes my-routes

0:19 I understand I could do (GET "/user/:uid" [uid] ((fn [uid] (fn [request] ...)) uid)), but that seems like I'm fighting the API

0:19 (where the innermost (fn [request] ...) stands for a defn elsewhere)

0:32 yoklov: err, I don't use compojure but couldn't you do (GET "/user/:uid" [uid] ((fn [request] …) uid)) ?

0:32 unlink: and if that other function is elsewhere that would be (GET "/user/:uid" [uid] (otherfn uid)) which looks pretty natural to me, at least

0:33 unlink: yoklov: yes, actually I meant (defn get-user [uid] (fn [request] ...)) (defroutes ... (GET "/user/:uid" [uid] (get-user uid)))

0:33 yoklov: currying is not idiomatic clojure. if this was Haskell, I'd agree with you.

0:35 yoklov: *shrug*. i don't know how much I agree with you. the 4th parameter to GET needs to be a function?

0:36 unlink: yoklov: in order to be passed the request object, it needs to be IFn or IDeref. https://github.com/weavejester/compojure/blob/master/src/compojure/response.clj#L14

0:37 yoklov: okay, then i would try not to think of this as currying as much as just a function returning a function.

0:37 i wouldn't think of that as currying as much at

0:38 oh weird.

0:38 *just the first line.

0:38 unlink: yoklov: well, it's a function returning a function with the express purpose of closing over the first argument...currying.

0:39 yoklov: i'm not disagreeing that it's currying, i'm just saying you don't have to look at it that way

0:39 unlink: ah

0:40 yoklov: if the compojure api requires a function, thats what you have to give it.

0:40 you're taking data and building a function (which uses that data) to give to the api.

0:41 unlink: maybe #(get-user % uid) is what I should use.

0:41 yoklov: thats just how i'd think about that though, not necessarially the right way

0:41 oh

0:41 yeah

0:41 that is.

0:41 unlink: but that is more evidence that I'm doing it wrong. That couldn't be how the API was intended to be used.

0:42 xeqi: I think its rare to want the full request map

0:42 yoklov: i'd try to look at some (good) code which uses compojure in that case

0:43 muhoo: gawd, if i'd bought clojurebook.com a month ago, i could have saved a month of asking stupid questions :-/

0:43 his

0:43 unlink: yoklov: Most of what I'm coming across is from an incompatible previous release of Compojure.

0:43 yoklov: bummer :/

0:43 unlink: xeqi: I must be very special then, because I need it a lot.

0:44 yoklov: muhoo: yeah? i've been going back and forth on buying it

0:44 xeqi: what do you use it for?

0:45 unlink: Reading the body, checking the content type, checking the content length, dispatching on accept...

0:53 amalloy: unlink: i don't know what you've read that makes you think you need to do this

0:56 you can literally just do (GET "/user/:uid" [uid :as request]), i think, or something close ot it

0:56 *to

0:57 that's discussed in the compojure wiki, which is a good resource, but i found it just now by looking at https://github.com/weavejester/compojure/blob/master/src/compojure/core.clj#L81, which is used by GET

0:58 muhoo: yoklov: it's great

0:58 unlink: amalloy: ah yes you can.

0:59 muhoo: yoklov: very practical, very focussed on real-world tasks, more like a howto or documentation. i zip around looking for examples of how to do stuff, find what i need, and move on to getting it done.

0:59 unlink: amalloy: a bit creative destructuring, but sufficiently general nonetheless

0:59 amalloy: yeah, i don't love the asymmetry of his destructuring syntax, but i can understand it as a way to make the common case easy

1:01 muhoo: almost like a book-length FAQ

1:02 yoklov: hm, interesting

1:03 you might be convincing me, i was worried it would be like the joy of clojure. great, but not really a great reference

1:04 meaning i don't really end up read it

1:04 muhoo: yep, i got part the way through joy of clojure and couldn't finish it

1:05 yoklov: *reading. i think you're convincing me

1:05 muhoo: anyway, it worked for me. i guess someone with a deeper lisp background might enjoy other books instead. i'm mostly a sysadmin-turned-programmer, so i was totally lost until i found this book.

1:25 xumingmingv: i got a NPE , the stacktrace is:

1:25 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)

1:25 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)

1:25 at java.lang.Thread.run(Thread.java:679)

1:25 Caused by: java.lang.NullPointerException

1:25 at backtype.storm.daemon.nimbus$fn__370$exec_fn__1024__auto__$reify__388$iter__429__433$fn__434.invoke(nimbus.clj:810)

1:25 at clojure.lang.LazySeq.sval(LazySeq.java:42)

1:25 ... 15 more

1:25 muhoo: xumingmingv: refheap.com

1:26 xumingmingv: my question is: how to diagnose this kind of exception

1:27 i have checked (nimbus.clj:810)

1:27 nothing is nil..

1:27 any guidance?

1:27 and i have also checked LazySeq.java

1:28 seems some code in nimbus.clj used LazySeq

1:28 how can i determine who used the LazySeq?

1:29 muhoo: https://refheap.com/paste/1835

1:30 bowski: Hello @clojure. I was wondering how I could make my definition return a list. Right now it recursively dives into the function skip-list-keys and I'm able to print what I want, but they're backwards (i can use reverse function after this>) and in their own list (I want them all in the same list). Here's what I've got: (print (conj (skip-list-keys (last node)) (first (last node))))

1:30 Sorry, that's a boatload at once

1:33 xumingmingv: or a much simpler question

1:33 from the stacktrace: at backtype.storm.daemon.nimbus$fn__370$exec_fn__1024__auto__$reify__388$iter__429__433$fn__434.invoke(nimbus.clj:810)

1:34 can i find the real code from the $fn_xxx$fn_yyy ?

1:34 jpop: hello

1:35 how can I return something other than object from (doto object ... ) block ?

1:37 xeqi: jpop: doto always returns the first argugment; what are you trying to return?

1:37 bowski: where does skip-list-keys come from? try pasting your code and an example call on refheap.com

1:38 jpop: xeqi I thought I could override that with (return x) inside the block or something similar

1:38 guess not?

1:38 bowski: xeqi: thanks for helping. Here it is. https://refheap.com/paste/1838

1:39 amalloy: jpop: no, you seem to want to do something other than what doto is for. what structure did you have in mind?

1:39 bowski: I'm just trying to make the 3-17 in their own list

1:39 amalloy: bowski: short answer: user a vector or a lazy-seq, not a list

1:39 bowski: ah ok

1:40 amalloy: i haven't looked at the code, but just caught up with your question

1:40 bowski: contains? should work for that I assume

1:40 jpop: amalloy i am interfacing Qt's QProcess. I wanted to use doto to avoid having to assign it to a variable and repeat it's name. and I wanted to return result of readAllStandardOutput at the end

1:41 amalloy: wut

1:42 jpop: (.readAllStandardOutput (doto myObj (...) (...) ...))

1:42 jpop: yeah i guess that would work

1:42 amalloy: bowski: i don't understand your question, but assuming contains? will work for anything is usually a recipe for sadness

1:43 jpop: a bit odd looking having all the methods in the block except that one though

1:43 amalloy: so shuffle it around a bit, if you like

1:43 (-> my-obj (doto ...) (.readAllStandardOutput))

1:43 bowski: Heh, I hear ya. I was just looking at the contains? documentation and it says "for some reason lists do not work for contains? even though they are sequences"... should have looked earlier :)

1:43 amalloy: "for some reason"? who wrote that, i'm gonna delete it

1:44 bowski: Truely not very professional. now to make this a vector... thanks guys :)

1:44 jpop: is ... part of the syntax or something i should fill in?

1:44 amalloy: fill it in

1:45 jpop: I think i'll just write a doto that returns last form instead of object

1:46 amalloy: bowski: clojuredocs is not an official clojure documentation source. i mean, a lot of good stuff is there, but it's really not "the documentation for contains?"

1:46 so that line was added by some random user who didn't understand contains?

1:46 bowski: Ah I see. my professor was talking the other day about how the C++ official documentation took 10+ years to be released. I guess it makes sense

1:47 amalloy: the official clojure documentation is basically your repl, but http://clojure.github.com/ is a precompiled list of those

1:47 ~contains?

1:47 clojurebot: contains? checks whether an indexed collection (set, map, vector) contains an object as a key. to search a sequence for a particular object, use the `some` function, which accepts a predicate. if you want to only match a certain object, you can use a set as the predicate: for example, (some #{5} (range)) finds the first occurrence of 5

1:48 mjijackson: Hi all

1:48 I'm getting a java.util.IllegalFormatConversionException when I try and do a (format "%.3f" rand)

1:49 bowski: wow, awesome

1:49 mjijackson: Thing is, that code works fine with other floating point numbers, just not rand

1:49 Any idea why?

1:49 xeqi: &(format "%.3f" (rand))

1:49 lazybot: ⇒ "0.737"

1:50 mjijackson: xeqi: thanks

1:50 just getting into clojure, still learning the basics :)

1:56 bowski: amalloy: so my list is being made like this with lazy-seq: (((((((17)14)13)12)7)4)3). Is there an "append" function like in scheme?

1:57 amalloy: i think you probably don't understand what i mean by "use lazy-seq", but (a) there's an append for lists, which is necessarily inefficient, and (b) conj adds to the end for vectors

2:01 xeqi: bowski: you're function you pasted looks close to what you want, but (print ..) returns nil

2:01 *your

2:02 bowski: I'm really trying to understand this. I'll look at the print functions, is that maybe why? like pr or something else

2:02 xeqi: what happens when you don't print it?

2:03 bowski: it looks like it's making a list for each individual item

2:03 so I guess it would return the last item if the function were called

2:06 no I don't think that's it... hmm

2:06 xeqi: and the recursive call is the second argument to cons

2:06 since you're returning (print ..) which is nil, this makes a new list for each call

2:06 but if you just returned then it would cons and have one list

2:07 amalloy: yes, well spotted

2:07 i kinda glazed over the print

2:07 bowski: hmm I've taken away the print, but My other test (contains? (skip-list-keys node0) 3) fail

2:08 xeqi: that gets to the ~contains

2:08 the idiomatic way to search for an item in the list is (some #{3} (skip-list-keys node0))

2:11 bowski: Awesome. it works. Thank you a lot for teaching me these things, dudes. I'm going to look up some right now

2:14 amalloy: &(doc some)

2:14 lazybot: ⇒ "([pred coll]); Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return :fred if :fred is in the sequence, otherwise nil: (some #{:fred} coll)"

2:14 amalloy: bowski: lazybot also provides repl services by /msg

2:56 senthil: i created a project with lein, and am trying to include clojure.contrib, but I'm getting java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword

2:56 (ns clj-play.core :use [clojure.contrib])

3:01 sritchie: senthil: the :use clause needs to be in its own list

3:01 (ns clj-play.core (:use [clojure.contrib]))

3:01 and you don't need the vector around clojure.contrib:

3:02 (ns clj-play.core (:use clojure.contrib))

3:02 senthil: sritchie: diff. error java.lang.ClassNotFoundException: src/clj_play/core.clj

3:02 i've contrib in my dependencies

3:03 sritchie: what file did you put that in?

3:03 senthil: vim src/clj_play/core.clj

3:03 sritchie: try saving it before compiling

3:04 senthil: sritchie: save what?

3:04 sritchie: that text file

3:04 the source file

3:04 senthil: sritchie: well ofcourse, hence the diff. error

3:05 sritchie: what do you mean by diff error? thought you meant different error

3:05 oh

3:05 clojure.contrib isn't a library

3:05 clojure.contrib.seq would work;

3:06 if you want to include clojure.contrib, you do that as a dependency in project.clj

3:06 fwiw, clojure.contrib is dead

3:06 senthil: sritchie: did that and compiled

3:06 laurus: Is there a way to comment out lines in Clojure mode in emacs?

3:06 sritchie: laurus: I used textmate-mode

3:06 senthil: sritchie: what replaced it?

3:06 sritchie: senthil: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go

3:06 it's broken up into modules now

3:07 anyway, you'd include [org.clojure/clojure-contrib "1.2.0"] in project.clj,

3:07 then you could do (:use clojure.contrib.macros) or whatever in ns

3:07 senthil: sritchie: what I want is clojure.contrib.server-socket

3:07 sritchie: (:use clojure.contrib.server-socket), then

3:07 laurus: sritchie, what about the command "comment-region"

3:08 sritchie: senthil: just make sure you add [org.clojure/clojure-contrib "1.2.0"] to your :dependencies in project.clj

3:08 senthil: sritchie: yea i did, compiled it too

3:08 laurus: I mean, why is it not bound to any key combination in Clojure mode?

3:08 sritchie: laurus: not sure

3:08 senthil: sritchie: but still same error

3:09 sritchie: senthil: restart your nailgun server

3:09 I think you have to have created the file before starting whatever process you're using for compilation

3:09 laurus: sritchie, ok thanks!

3:09 senthil: sritchie: i'm using "lein run", what's nailgun?

3:09 sritchie: senthil: sorry, thought you were using something w/ vim

3:10 senthil: not sure what' s up -- that error usually means you have a typo in the ns name

3:10 or you placed it at the wrong spot

3:10 make sure you can see it in the fs

3:10 senthil: sritchie: if i remove the :use line, it works

3:10 sritchie: hmm

3:11 what clojure version?

3:11 paste your project.clj

3:11 senthil: 1.3.0

3:11 sritchie: server-socket probably isn't 1.3 compatible

3:11 so that ns form is failing,

3:12 senthil: http://cl.ly/1Y0p0X2P0p1b1b0A0M1z

3:12 sritchie: would this help? https://github.com/clojure/tools.nrepl

3:12 how about "lein repl"

3:12 then "(use 'clojure.contrib.server-socket)"

3:13 senthil: sritchie: lein repl works

3:13 sritchie: switched to 1.2.0, still same error

3:14 sritchie: just to confirm, i do "lein compile && lein run" right

3:14 sritchie: you don't need to compile

3:14 since you don't have any AOT stuff

3:14 meaning, there's no (:gen-class) in any namespace

3:15 trying it here

3:15 senthil: sritchie: http://cl.ly/1V2D0f0S132f060U3V1A; I see 'hi' with 'lein run' before I get the exception

3:15 and since println is after the use, maybe its something else

3:16 sritchie: this might be a leiningen bug, or a clojure bug

3:17 I think it's a problem w/ the underscore

3:17 senthil: sritchie: (use 'clojure.contrib.server-socket), that doesn't work either; Exception in thread "main" java.lang.Exception: lib names inside prefix lists must not contain periods (core.clj:3)

3:17 ha! day 0 and i run into a bug

3:17 sritchie: hmmmm

3:19 oh!

3:19 I know why

3:19 for lein run to work, you need a function called -main in the namespace

3:19 otherwise, it wouldn't know what to do

3:20 add this: (defn -main [] (println "WORKING!"))

3:20 to that namespace

3:20 even with the require

3:20 err, with use

3:20 (ns clj-play.core (:use clojure.contrib.server-socket))

3:20 senthil: no bug, just me forgetting about what lein run does ;)

3:20 lein run calls the -main function of the :main namesapce

3:21 senthil: sritchie: awesome, it works!

3:21 sritchie: that's why lein repl worked, and probably put you right into the proper ns

3:21 senthil: phew

3:21 good luck, enjoy clojure!

3:21 senthil: sritchie: thx dude, really appreciate your help & patience

3:21 sritchie: senthil: no problem at all, the setup is the toughest part

3:22 the IRC channel was really great for me when I was learning

3:22 definitely take full advantage

3:22 senthil: does that fix make sense?

3:22 senthil: sritchie: yes, i did see something about main

3:22 but that error msg said class exception

3:22 p.s. are all errors msg this cryptic

3:23 sritchie: haha, this was a particularly cryptic one

3:23 I think leiningen tries to compile the :main namespace,

3:23 and doing that requires a -main function

3:23 so it didn't compile, and then couldn't find it

3:23 senthil: they're getting better, but they can be cryptic

3:23 clojure 1.3 does a good job

3:24 https://github.com/mmcgrana/clj-stacktrace

3:24 that will help

3:24 instructions at the bottom

3:24 senthil: good luck!

3:25 senthil: sritchie: thx!

3:34 ggreg: hi all

3:35 autodidakto: ggreg: hi

3:37 senthil: WARNING: spit already refers to: #'clojure.core/spit in namespace: clj-play.core, being replaced by: #'clojure.contrib.duck-streams/spit

3:38 (ns clj-play.core (:use [clojure.contrib server-socket duck-streams]))

3:38 I get the above error with the below line

3:38 Using lein

3:45 autodidakto: you need to alias (:as) duck-streams

3:46 with :require

3:46 amalloy: or, better, throw duck-streams into the garbage disposal

3:47 autodidakto: amalloy: What's that saying? "Code you garbage dispose, you don't have to debug" ?

3:47 amalloy: meh. many such sayings conveying that general intent exist

3:48 i like "the fastest code is the code you never had to write"

5:31 bowski: amalloy: thanks for the help. If you're interested, here's my final project - https://refheap.com/paste/1843 it's a basic skip-list in clojure. Thanks again

5:54 prasaadk1: I have a function that returns an element, I am calling that function in a loop and I want to create a sequence out of the return values, how should I achieve that?

5:55 muhoo: prasaadk1: for?

5:55 or map maybe

5:56 prasaadk1: ok, I am not able to create a sequence with return values, if I print return values, it works

5:56 how do I return the values, and make them a sequence?

5:56 is it possible to do that using map?

5:58 antares_: prasaadk1: that's what map is for

6:00 prasaadk1: antares_, muhoo: thnks, got it, I was trying to do a doseq and calling a func for every element. map looked better and worked

6:01 antares_: prasaadk1: doseq is for side effects. It discards results.

6:02 prasaadk1: side effects? didn't get that, any link that explains that plz ?

6:03 another question, this function is creating sequence with some numbers and some sub-sequences, is there any easy way to just flatten that out?

6:06 how to flatten out a sequence, that has sub-sequences and numbers

6:09 impressed to see the presence of the function "flatten"

7:17 solussd: what's the correct way to list all interfaces/protocols extended to/implemented by an object?

7:18 llasram: Hmm. You can get interfaces through reflection, but I don't think there's a way to know all the protocols an object supports

7:19 That information is kept by the book-keeping structures for the individual protocols

7:19 solussd: hmm… get all protocols and filter?

7:19 llasram: I don't think there's a way to do that either :-)

7:21 I suppose you could kick things off in an environment where the first thing you did was redefine defprotocol to keep a central record of all protocols defined

7:21 But, why?

7:23 oskarth: http://clojars.org/search?q=clj-time This is confusing. The official one is the last one that was published, but there are plenty others with higher version numbers. What does that mean?

7:28 llasram: Other people forked the project, and version numbers aren't consistent across the forks?

7:30 oskarth: right, but the official one is still "the one to use"? As an example it would seem weird if I could form say, twitter-bootstrap, and call it version 3

7:30 I was just confused about that, seeing as the project seems to have changed owner over the years

7:31 if I could fork* say

7:32 llasram: I don't know for certain, but looking at some of the repository histories, I get the impression that the original author didn't touch it for a long time, a few other people continued development in new forks, then at some point seancorfield's fork become the "official" one

7:33 oskarth: yeah, that makes sense, thanks

7:34 llasram: Glad to make things up, any time! :-)

7:59 fliebel: Where does leiningen get its classpath from when installed via apt-get? It has aal sorts of /usr/share/java on it, but not the one I want

8:14 llasram: The CLASSPATH for lein itself?

10:18 prasaadk1: I am trying to use a forkjoin.clj , I hv got it from github and I have pasted it in my workspace, how do I import or use functions from that file?

10:22 antares_: prasaadk1: it depends on how you pasted it and what do you mean by "workspace" but require and use functions are probably what you need

10:25 prasaadk1: by workspace, I mean in the same directory as my other clj files

10:45 lynaghk: Style question: What do you think about prefixing atom variable names with a bang? I'm used to seeing $element from my jQuery days, and I like that it makes "wrapped" values visually distinct.

10:51 jtoy: are clojars and conjars the same ting, just 2 different places to host at?

10:52 TimMc: Never heard of conjars

10:52 S11001001: jtoy: no, clojars is for clojure, conjars is for something else

10:53 Conjars is a dead easy community jar repository for open source *Cascading* libraries and extensions.

10:56 prasaadk1: I am still struggling to include forkjoin.clj that is in the same directory as other clj files, how do I use it?

10:56 llasram: prasaadk1: Are you using lein?

10:56 TimMc: prasaadk1: What does your :require form look like?

10:56 prasaadk1: llasram: no I am using ccw

10:57 (ns paralleldirsize

10:57 (:import java.io.File)

10:57 (:require fj))

10:57 llasram: Doesn't ccw use lein?

10:58 prasaadk1: llasram, dnt knw, may be not

10:58 TimMc: prasaadk1: That statement will only bring in fj.clj at the root of the Clojure source tree. Is that where it is? (It shouldn't!)

10:59 ~namespaces

10:59 clojurebot: namespaces are (more or less, Chouser) java packages. they look like foo.bar; and corresponde to a directory foo/ containg a file bar.clj in your classpath. the namespace declaration in bar.clj would like like (ns foo.bar). Do not try to use single segment namespaces. a single segment namespace is a namespace without a period in it

11:00 TimMc: Poor chouser, always getting highlighted by that unremovable factoid.

11:00 prasaadk1: its in the same directory as the paralleldirsize

11:00 TimMc: prasaadk1: Are they both directly in src/ ?

11:01 prasaadk1: yes

11:01 TimMc: That may cause you problems.

11:01 prasaadk1: TimMc, why so?

11:01 TimMc: I don't know if it's causing *this* problem, but you should fix it first.

11:01 prasaadk1: is it because, both have different namespace and are in same directory, which is the problem?

11:01 TimMc: I'm not actually sure. I have been told such by those who would know. :-/

11:02 prasaadk1: See the clojurebot factoid I pulled up above ^

11:03 devn: good morning fellow clojurians

11:03 fdaoud: S11001001: are there any other "dead easy community jar repositories"?

11:03 Cpt_HYPERFRITZ: devn,

11:03 llasram: good morning!

11:04 TimMc: fdaoud: Check for clojars forks. :-P

11:04 Cpt_HYPERFRITZ: What is your opinion on ##(symbol? (symbol "I worship His Shadow"))

11:04 lazybot: ⇒ true

11:05 fdaoud: TimMc: I thought maybe it was one of those things like stackoverflow that turns out to just be one of many from stackexchange

11:06 goodieboy: we have a leiningen plugin we're trying to test. It seems that, since we already have a previously published version installed (global plugin), lein test loads up the global plugin first, which is a problem. Anyone know a way around this?

11:07 fdaoud: goodieboy: just a shot in the dark-- specify the version number? published versions should *never* be changed.

11:08 goodieboy: fdaoud: well we don't actually specify our plugin as a dependency to iteself, it seems that because it's a global plugin (~/.lein/plugins) it is always automatically loaded

11:09 TimMc: You're trying to use it on itself?

11:09 In that case, depend on the previous version, I guess. (I think it's that simple...)

11:11 goodieboy: TimMc: no we're not trying to use it on itself, we want to avoid that so old code doesn't trump our development code. Leiningen appears to be loading the installed version for us though.

11:11 i'm trying to figure out how to not do that hmm

11:11 TimMc: Well, there's always lein2... :-)

11:13 goodieboy: OK, are you saying that you have some test project, and you have a dev-dependency on your plugin, but the .lein/plugins version is what you're getting instead?

11:14 goodieboy: TimMc: Sorry no. I am trying to test the actual plugin project.

11:14 TimMc: Oh, just lein test?

11:15 goodieboy: TimMc: Yes. When I do this, it seems that leiningen loads my installed plugin before the same plugin project i'm trying to test. Sorry if this is confusing!

11:16 TimMc: goodieboy: What happens if you do `lein trampoline test`?

11:16 goodieboy: TimMc: let me try that

11:16 (what does that do?)

11:17 TimMc: This might be a lein bug, but trampolining may help avoid it.

11:18 goodieboy: TimMc: I get: Warning: trampoline has no effect with :eval-in-leiningen.

11:18 TimMc: Oh! This may be beyond me.

11:18 jayunit100: hmmm

11:18 TimMc: goodieboy: It starts a new JVM for the task and allows lein to exit out.

11:18 jayunit100: (.toString nil)

11:18 ,(.toString nil)

11:18 goodieboy: TimMc: OK no problem, at least I know I'm not completely missing something

11:18 clojurebot: #<NullPointerException java.lang.NullPointerException>

11:19 jayunit100: thats unfortunate... im used to using my null + operator in java... it "simulates" a to string. Is there a syntactical equivalent in clojure ?

11:19 TimMc: ,(str nil)

11:19 clojurebot: ""

11:19 S11001001: jayunit100: more importantly, &(let [x (proxy [Object] [] (toString [] nil))] [(str x) (str (str x))])

11:19 jayunit100: yeah... i guess so . sill question

11:20 S11001001: er,

11:20 ,(let [x (proxy [Object] [] (toString [] nil))] [(str x) (str (str x))])

11:20 clojurebot: [nil ""]

11:20 jayunit100: S11001001: huh ?

11:20 S11001001: you have to call str twice if you want a guarantee :)

11:20 TimMc: str returns a Maybe String. :-)

11:22 This can happen in Java as well, of course.

11:23 S11001001: honestly I think it's a mistake, str should be a fixpoint

11:27 jayunit100: oh a maybe string :)

11:27 yeah that is odd.

11:28 cjfrisz: What does it mean when an expression on the SLIME repl comes back with "; Evaluation aborted" but there's no stack trace?

11:28 jayunit100: can i filter a map function lazily ?

11:28 so that the mapper doesnt store all results, only the ones that pass a test.

11:28 S11001001: jayunit100: can your mapper return nil?

11:28 jayunit100: well - i think thats bad style.

11:28 id like to do

11:29 (map :filter (> 1 %) (+ .5) [0 .1 .4 .5 .6])

11:29 something like that

11:29 S11001001: first, filter is lazy, and map is lazy

11:29 so chaining them is also lazy

11:30 although filter is funky on chunked seqs, but you can't really count on non-weird laziness from them anyway

11:30 jayunit100: okay so if you put filter in the front, you get an optimal map

11:33 S11001001: jayunit100: depending on what your test means; in your example, your filter could go on either side, having different meanings

11:34 indeed, one of the most powerful consequences of the lazy sequences is you can chain maps, filters, and other stream processors together with wild abandon

11:49 jtoy: can someone tell me why the use doesn't work but require works here: http://pastie.org/3739574

11:50 i normally put all the dependencies in use, but it doesn't seem to work with clj-http

12:00 oliverro: Hi there

12:00 antares_: jtoy: not sure what does not work, but what you want is probably https://gist.github.com/7fb0947356d09a15ac6b

12:01 jtoy: no need to repeat :require and your example does not benefit from deep aliasing either

12:01 jtoy: antares_: the only part that does not work is calling (client/get "http://google.com") , all other method calls work

12:02 antares_: ok, i copied that from other people's source code, not sure what the right way is

12:02 antares_: jtoy: if you use clj-http.client, then get will shadow clojure.core/get

12:02 jtoy: define "does not work"?

12:02 your gist says "SUCCESS", why?

12:03 jtoy: antares_: I run (use :reload-all 'interests.core) ; then (client/get "http://google.com") and get java.lang.Exception: No such namespace: client (NO_SOURCE_FILE:2)

12:03 oliverro: is there an easy way to do "multiple" update-in at once ? For example : (multiple-update-in {:a 1 :b 2} :a :b inc)

12:03 jtoy: antares_: then next I do (require '[clj-http.client :as client])

12:03 and then (client/get "http://google.com") and i get data back

12:04 antares_: jtoy: I am not sure :reload-all will pick up most recently added dependencies (that lein did not download)

12:04 jtoy: if you need an HTTP client example, take a look at https://github.com/michaelklishin/neocons/blob/master/src/clojure/clojurewerkz/neocons/rest.clj#L3

12:04 jtoy: I copied the require style from here: https://github.com/chunhk/cascalog-hope/blob/master/src/cascalog_hope/core.clj

12:06 S11001001: jtoy: "use" doesn't copy ns aliases from the ns you're using, you have to change to that ns if you want to use its aliases

12:06 antares_: jtoy: I think the issue is a missing artifact that REPL won't download, not a particular ns/require style

12:07 S11001001: iow, "client" is an alias valid *within* interests.core; it doesn't pollute other nses (like user) that just happen to "use" interests.core

12:07 the alternative behavior would be extremely annoying

12:07 jtoy: S11001001: why can I use the other aliases like json/parse-string ? I require and alias the exact same way

12:08 antares_: jtoy: did you add clj-http just recently?

12:08 jtoy: after you started REPL session?

12:09 jtoy: no, I added it in code and then lein repl && lein compile && lein repl

12:09 lein deps, first

12:38 dgrnbrg: hey technomancy, I have pushed some more code to dgrnbrg/guzheng on github. I wrote a tracer that traces which branches are taken and which are not taken, and has all of the data to generate a report on missing test branch coverage

12:42 strings: Is there a difference between 'defmacro' and 'defn' in terms of how they treat arguments?

12:43 jtoy: is slingshot commonly used? https://github.com/scgilardi/slingshot

12:44 mega: , (macroexpand '(defmacro a [c b] `(+ ~c ~b)))

12:44 clojurebot: #<Exception java.lang.Exception: SANBOX DENIED>

12:44 drewr: jtoy: yes

12:46 antares_: strings: if compile time vs run time evaluation counts for a difference, then yes

12:49 strings: 'defmacro' treats the argument as a symbol, while 'defn' treats it as a data structure or whatever it's being passed

12:50 dnolen: nice PersistentHashMaps for CLJS not far it seems: https://github.com/thomcc/persistent-hashmap/blob/master/persistent-hashmap.js

12:52 technomancy: dgrnbrg: wow, cool

12:52 dgrnbrg: technomancy: I'm going to try to finish it into a lein plugin

12:52 in the next week or so

12:53 technomancy: dgrnbrg: once you get it polished off I can point to it from the radagast readme

12:53 dgrnbrg: I'm not sure how to have it operate, though, since it needs to be given a list of test nses and a list of instrumented nses

12:53 TimMc: strings: They both define functions that take data. They can both destructure their arguments. The real difference is what they are passed -- macros receive syntactic structures, normal fns receive runtime data.

12:54 technomancy: dgrnbrg: should be able to construct a form to call eval-in-project on; if you have trouble I can probably set you straight

12:54 dgrnbrg: technomancy: I mean the CLI interface

12:54 since I've only ever seen things like lein test nses...

12:55 strings: TimMc: got it! Thanks.

12:55 dgrnbrg: lein guzheng instr-nses… -- test-nses...

12:55 ?

12:55 or maybe it just runs all the tests

12:55 technomancy: dgrnbrg: yeah, not sure it makes sense to support a subset of the tests

12:55 dgrnbrg: what if you're developing and broke some tests

12:56 and don't want their stupid errors

12:56 TimMc: dgrnbrg: What if it chained to another task?

12:56 dgrnbrg: or you want to see if you cover it from 2 perspectives, since you've organized your tests to test the same code w/ different plugins or something

12:56 TimMc: dgrnbrg: lein guzheng instr-nses... test test-args...

12:56 technomancy: dgrnbrg: hm; maybe so. but in that case it would make sense to read the lists from project.clj

12:56 since they're unlikely to change over time

12:57 dgrnbrg: that seems like a good way to do it

12:57 TimMc: Composability!

12:57 technomancy: is guzheng the instrument that guy plays in the first fight scene of the film Hero?

12:58 the one where everyone is playing Go and it's raining?

12:59 dgrnbrg: technomancy: I think so

12:59 I haven't seen that movies in ages

13:00 llasram: I don't believe I've seen that, but sounds intriguing. Is it one of these? http://en.wikipedia.org/wiki/Hero_(film)#Film

13:00 dgrnbrg: I am seeing this error and I don't understand what could trigger it: #<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/let, compiling:(REPL:101)

13:01 I think it's related to the way i'm rewriting a condp clause

13:01 technomancy: llasram: this one: http://en.wikipedia.org/wiki/Hero_(2002_film)

13:01 it's pretty great

13:01 mega: dgrnbrg: can you put the code in a gist?

13:02 llasram: I haven't seen a good wuxia film in forever. *queued*

13:02 technomancy: llasram: get the subtitled version if you can

13:02 elliottw: hi, day two of clojure

13:02 is there a reason why .string/split can handle dashes and .string/capitalize cannot?

13:03 dgrnbrg: the gist of the error: https://gist.github.com/2321318

13:04 llasram: elliottw: Could you provide an example of what you mean?

13:04 dgrnbrg: I think it's do-condp that fails

13:04 elliottw: this works

13:04 (clojure.string/split "scott moritz and thestreet.com’s million iphone la‑la land" #"\s")

13:04 technomancy: dgrnbrg: might need to var-quote on line 57

13:05 dgrnbrg: technomancy: oh snap!

13:05 that line is wrong

13:05 elliottw: but when i do capitalize, i get this: Thestreet.com⊙s

13:05 dgrnbrg: it got unquote-spliced, i think

13:05 elliottw: La⊑la

13:07 llasram: elliottw: Looks like some sort of encoding error... It works for me in my environment. How are you running the offending code?

13:07 &(clojure.string/capitalize "scott moritz and thestreet.com’s million iphone la‑la land")

13:07 lazybot: ⇒ "Scott moritz and thestreet.com’s million iphone la‑la land"

13:07 technomancy: works here too

13:08 elliottw: (defn cap-all [wordstring]

13:08 (if (not (empty? wordstring))

13:08 (cons (clojure.string/capitalize (first wordstring)) (cap-all (rest wordstring)))))

13:09 llasram: Well, I meant more what sort of interface, exception environment, etc. `lein repl` in a terminal, CCW, SLIME, etc

13:09 s,exception,execution,

13:11 elliottw: lein repl

13:12 mega: dgrnbrg: what is this code for??

13:12 lazybot: mega: Definitely not.

13:12 dgrnbrg: mega: it's a branch coverage analyzer

13:13 it rewrites namespaces as they're loaded to enumerate all possible branches and lazy code paths, and then it tracks which ones are executed by the tests

13:13 then it gives you a report of code paths you failed to test

13:14 elliottw: i just wanted to build something that turns normal text into titlecase

13:15 mk: what is function associativity?

13:16 mega: dgrnbrg: so this is you decorating the ns guzheng.sample?

13:16 dgrnbrg: yes

13:16 i think we found the error--it's a let that wasn't wrapped in parens

13:18 technomancy: elliottw: are you on a mac?

13:18 elliottw: yup

13:18 mega: dgrnbrg: yea thats probebly it

13:18 technomancy: elliottw: probably you're getting screwed by macroman encoding I guess

13:18 dgrnbrg: this rewriting ASTs gets funky

13:18 elliottw: damnit

13:18 i've got this installed on ubuntu, maybe i should start trying it out there

13:19 mega: dgrnbrg: instedd of outputting all the code in every path youst make a function call

13:19 technomancy: elliottw: or it could be jline; you could see if installing rlwrap fixes it if you haven't got that

13:19 mega: dgrnbrg: to a function in your ns

13:19 dgrnbrg: mega: i'll fix it later

13:19 :P

13:19 this is just sort a hack i want to put together

13:19 I actually have 2 other projects that are cooler

13:20 this is my "drunk weeknights toy"

13:21 mega: dgrnbrg: if you completly macroexpand the code insted you only probebly only need to care about if statements

13:21 dgrnbrg: dgrnbrg: that seems hard...

13:21 mega: that seems hard

13:22 also, it might be harder to understand the context

13:22 mega: dgrnbrg: theres a macroexpand-all function in clojure.walk

13:22 dgrnbrg: there's only cond, condp, if, fn, and defn

13:22 that I can think of

13:22 mega: dgrnbrg: and core.match + annything i make up

13:22 dgrnbrg: I won't be able to help w/ that :)

13:23 mega: dhrnbrg: you culd if it all comes down to if and fn* maybe

13:23 dgrnbrg: but im not shure about that :S

13:24 dgrnbrg: I don't think that the macro expand calls do a good job w/ line number tracking, iirc

13:24 i might be mistaken, though

13:24 elliottw: rlwrap?

13:24 technomancy: rlwrap?

13:25 technomancy: rlwrap.

13:25 it's for nicer command-line interaction

13:25 but it can't be included with leiningen since it doesn't run in the jvm

13:25 elliottw: looking into it now

13:25 man, ramp up with this language is slow going

13:26 technomancy: FWIW you don't need rlwrap in lein2

13:26 mega: and in emacs :D

13:27 elliottw: i'm using sublimetext2 and lein 1.7.1

13:28 technomancy: leiningen 2 isn't quite finished yet, so it's probably best to stick with lein 1.7 if you're getting started

13:28 just to let you know we're working on it =)

13:28 can't fix the insanity of macroman encoding unfortunately =(

13:33 lein 1.7 should warn you if you don't have rlwrap installed though

13:33 elliottw: i've gotten no warnings

13:35 technomancy: was there a ~/.lein/.jline-warn file created?

13:35 it only emits the warning once

13:35 elliottw: nope

13:36 mega: are annyone else here using x-forwading into a virtualbox with ubuntu and emacs

13:36 technomancy: elliottw: ok, so you must have rlwrap installed. in that case the problem must be with macroman

13:36 mega: maybe a website with ready images shuld be settup for easy starting with clojure

13:36 technomancy: mega: there's a vagrant project

13:37 https://github.com/Seajure/emacs-clojure-vagrant

13:37 that probably assumes emacs

13:37 err--assumes emacs -nw

13:38 mega: dont think it suports -X ?

13:38 technomancy: if it does it's by accident

13:39 the scripts were written with tmux in mind

13:40 honestly I'd just use tmux unless you need to view images or something like that

13:41 mega: i havent used it

13:43 elliottw: technomancy: just tried it in ubuntu and it worked like a charm

13:45 thanks for you help

13:46 technomancy: cool; no problem

13:53 autodidakt: cemerick: listening to The Changelog podcast. Are you a fan? Might be a good format (inspiration) for some most-lazy episodes

14:06 dgrnbrg: technomancy: I added a report generator and pushed it to github. In an hour I'll write a lein task, and then it'll be useful for anyone, I think

14:07 technomancy: excellent

14:08 dnolen: neat clojure-scheme now passing most of the CLJS tests

14:09 technomancy: is the clojure-scheme guy on IRC?

14:12 dnolen: technomancy: sometimes, I don't see him around now.

14:13 technomancy: would like to pick his brain re: compiling to elisp =)

14:13 dnolen: technomancy: haha! man that's a good idea :D

14:13 technomancy: I'm still not sure it is. =)

14:14 pjstadig: technomancy: https://twitter.com/#!/stuartsierra/status/187690421558845440

14:14 technomancy: most schemes make it easy to turn off mutability

14:15 pjstadig: ouch

14:15 pjstadig: that's what Steve Yegge has been saying for ages though

14:23 dotemacs: Hey guys, I'm trying to organise a Emacs Conference. If you're interested in how it should look like or what you'd like to see, please contribute: http://emacsconf.herokuapp.com/ thanks :)

14:24 mega: dotmacs: in sweden ? :D

14:28 dotemacs: mega: maybe london, uk :)

14:49 antares_: dakrone: you around? do you have a few minutes?

14:49 dakrone: antares_: what's up?

14:50 antares_: dakrone: I am investigating why clj-http did not handle a relative redirect. It looks like it does work great on master (as soon as I add a lein checkout). Were there fixes for it recently? should I upgrade or look into why it does not happen all the time?

14:51 dakrone: antares_: what version are you using?

14:52 antares_: dakrone: I think it is 0.3.4, via one of my REST clients

14:52 damn, now with 0.3.6 it works again

14:53 dakrone: ok, it must be that 0.3.6 for some reason does work :) thank you for your time

14:53 dakrone: antares_: I would be interested in knowing what's going on, there weren't any redirect fixes between 0.3.4 and 0.3.6, other than setting the max # to 20

14:54 antares_: dakrone: I have a gist of debug log I can PM you

14:54 dakrone: antares_: that would be great

15:05 mega: is there a benifit using tmux over just using emacs?

15:11 llasram: I know Emacs has only grown the ability to run entirely headless vaguely recently. Last... 2 years? So possibly historical/voodoo reasons

15:12 technomancy: oh, no I mostly do it since it makes it easier to share the session

15:12 which you probably don't care about

15:12 pipeline: still waiting for a working client/server model in emacs

15:12 you can have emcas clients issue commands to emacs

15:12 llasram: Oh, this is something technomancy is doing! Nm :-)

15:12 mega: i dont have freands :D

15:12 pipeline: but there can only be one X11 server right now :\

15:12 or rather, only one instance of the X11 libraires. you can open windows on multiple displays, from the same client location

15:13 llasram: pipeline: Are you sure that's true? I used to connect an Emacs session on my work workstation to my home X sever all the time

15:14 (which Emacs client was also talking to the workstation X server)

15:14 Emacs had a tendency to crash when it lost an X server connection though :-/ so I've switched to `emacsclient -t` instead

15:49 ibdknox: dnolen: what's the procedure for picking GSOC proposals?

15:49 dnolen: ibdknox: we'll have to figure that out - was going to put some thoughts together and post on the clojure-dev ML.

15:50 ibdknox: dnolen: sounds good :)

15:53 dnolen: wasn't there talk of a column preserving reader somewhere?

15:53 pipeline: llasram: you can't use a local emacsclient to talk to a remote emacs, and a local X server

15:53 llasram: the remote emacs X client will always be the one that gets used

15:53 llasram: also I've found that the non-gtk emacs behaves a lot better when it loses an X session unexpectedly

15:54 since I almost never have a use for non-bitmap fonts, not having GTK is not much of a loss to me

15:54 devn: i get tons of reflection warnings in my `lein` output -- how can i disable those?

15:55 kibit has a bunch via core.logic and clucy

15:55 lein-kibit i mean

15:58 dnolen: ibdknox: not just talk, there's a patch for Clojure - will need to wait for 1.5.0 of course.

15:59 ibdknox: seems like it would be useful info for any Clojure debugging tool.

16:03 chouser: oh. kv-reduce. huh.

16:05 ibdknox: dnolen: do you have a link to the patch?

16:06 dnolen: ibdknox: http://dev.clojure.org/jira/browse/CLJ-960

16:06 ibdknox: thank you sir!

16:07 dnolen: ibdknox: also, https://github.com/brandonbloom/clojurescript/compare/clojure:master...brandonbloom:track-pos

16:07 ibdknox: I've got something exciting brewing :)

16:08 dnolen: ibdknox: I wouldn't expect anything less at this point ;)

16:08 nDuff: How can I access a public interface or enum nested in a Java class from Clojure? Simply referring to package.OuterClass.InnerObject is resulting in a ClassNotFoundException.

16:09 oh, n/m

16:09 * nDuff hadn't read the java_interop page closely enough

16:12 prasaadk1: do import and require class? I am importing a java.io.File and :require some other file

16:12 *clash

16:16 technomancy: chouser: yeah, so much for the feature freeze

16:16 llasram: pipeline: (had wandered off); oh, I see what you mean. Makes sense

16:17 turbofail: does pallet have its own irc channel or should i ask questions here?

16:20 amalloy: technomancy: wow, and a checked-in (set! *warn-on-reflection* true). that's a disaster if it gets into a build

16:21 technomancy: amalloy: friends don't let friends, &c

16:22 jimduey: turbofail: #pallet

16:22 turbofail: jimduey: thx

16:23 jimduey: ibdknox: tease. :p

16:34 offby1: Is there an easy way to "trace" a function -- i.e., modify the function so that it prints out its name (and perhaps its arguments) when it's entered, and prints out something else (perhaps the return value) when it exits?

16:36 technomancy: offby1: two ways: slime has C-c C-t, or you can use the tools.trace library

16:36 offby1: *nod

16:43 nDuff: I'm trying to attach Java annotations to an AOT-compiled method in https://gist.github.com/422a11d822458acb2ce4 -- but calling getAnnotations() for catRev returns an empty array. Any hints on what I need to do differently?

16:44 jtoy: I'm learning about try/catch now, why can't I do this: (println (try (asdadsas) (catch Exception _ "test")))

16:45 S11001001: jtoy: because you never get inside the try, because your code doesn't compile

16:45 jtoy: S11001001: is there a way i can test try/catch on the repl?

16:46 S11001001: yes, do something other than code that can't compile

16:46 prasaadk1: parallel.clj is now deprecated, which is the new library now?

16:46 S11001001: like, (.toString nil) or something

16:47 you don't need try for code that doesn't compile; if you can compile your code, you can compile your code, and there is no place for a guard

16:47 daniel-renfer: try is for runtime, you're not even getting to that point

16:48 yoklov: does anybody else feel like cljs needs some new interop macros? (doto …) is nice, but a lot of javascript apis require set!ing peroperties, which is… awkward.

16:49 jtoy: ok, i think I see, wit try/catch, I should use that with let to try and set a variable and if doesn't then use the caught value , is this a normal clojure idiom?

16:49 S11001001: that "set a variable" stuff seems exotic to me

16:49 dnolen: yoklov: you mean like DOM stuff right?

16:49 yoklov: yeah

16:49 the dom is the biggest offender

16:49 technomancy: jtoy: I've always been partial to dividing by zero as my default intentional exception

16:50 dnolen: yoklov: hmm I don't personally have much of a problem w/ set!, what don't you like?

16:50 jtoy: technomancy: cool, I'll keep that in mind

16:50 S11001001: isn't let [name val] basically set variable?

16:51 TimMc: Does anyone actually use the binary version of reduce? I've always found myself using the ternary version.

16:51 llasram: nDuff: I haven't tried it, but I *think* you need to set the metadata on the method name symbol, not the method vector

16:51 technomancy: clojure doesn't have variables

16:51 S11001001: it's bind a name to a value; name isn't a variable, and you can't set it

16:51 TimMc: I think (reduce + ...) is the only time I use arity 2, and that's easily replaceable with (reduce + 0 ...)

16:52 yoklov: dnolen: mainly that it requires breaking up dotos, so something that might have been a single statement is now 3

16:52 jtoy: yes, its semantics, but all i mean is have a reference

16:52 ie, set a variable

16:52 or bind a name to a value

16:52 dnolen: yoklov: I'm imagine you have issue with Canvas code here.

16:53 yoklov: dnolen: haha, yeah

16:53 S11001001: "semantics" is half of what languages are all about

16:53 Raynes: 'variable' implies the value can vary.

16:53 llasram: nDuff: Oh man, but ^:static is on the signature vector. Kind of confusing

16:53 S11001001: things that mean different things mean different things

16:53 * Raynes puts his monocle on and smokes a pipe.

16:54 llasram: Hmm. Which means shady isn't handling it...

16:54 dnolen: yoklov: It's easy enough to write sets! or multi-set! macro here - I think Canvas is too specific to have a macro in core for it.

16:54 yoklov: dnolen: but other parts of the dom require set!ing things. clojure doesn't need anything like that because most java code provides setters

16:54 yeah

16:54 certainly it is

16:55 dnolen: yoklov: other bits of the DOM require some set!, but really Canvas is a bit extreme.

16:55 jtoy: ok, i will call it binding name to a value

16:55 S11001001: well, unless the calculation of that value causes an exception, said binding won't either

16:56 unless you then use the resulting binding in a way that compiles, but causes an exception at runtime

16:57 yoklov: dnolen: hah, yeah. i guess it's just frustruating that there's no cleaner option. clojure's amazing interop has spoiled me :p

16:57 jedmtnman1: jtoy: might be able to call it a locally bound ref, or symbol but most would know better than I.

16:57 yoklov: Maybe I should just cut to the chase and investigate the goog.graphics.* package.

16:58 dnolen: yoklov: goog Canvas stuff really stinks.

16:58 technomancy: refs and symbols are different things from locals

16:58 let works in terms of locals

16:58 yoklov: dnolen: does it? It sort of has an excessive-OO-abstractiony bullshit smell to it.

16:59 jedmtnman1: technomancy: thanks for the clarifcation

16:59 dnolen: yoklov: yeah ... and it's slow to boot.

16:59 yoklov: the low-level stuff is good I think, DOM stuff too - but the Canvas stuff - yuck.

17:00 yoklov: hah, damn. I won't waste my time with that then

17:05 jtoy: is there a way to overwrite a defonce defined symbol?

17:07 antares_: jtoy: a var?

17:08 jtoy: that's not really how you do things in clojure but the function you need is called alter-var-root

17:08 jtoy: (alter-var-root (var my-var) (constantly my-value))

17:12 srid: is there a wiki page or something that contains list of libraries known to work on clojure 1.3 (and those that do not)?

17:13 i'm coming back to clojure after some time, and wondering if i should use 1.3 or 1.2 for my new project (web-based with cljs)

17:13 daniel-renfer: srid: by now, most of the good libraries are 1.3 compatible

17:13 technomancy: if something hasn't been updated for 1.3 it's probably abandonware

17:14 srid: ah, good to hear. this is not like python3 at all :)

17:15 jtoy: antares_: so if that is not how things are normally done, what do ppl use for simple fast testing on repl

17:15 technomancy: jtoy: for repl stuff just change defonce to def

17:15 and then change it back

17:15 antares_: jtoy: in the repl, definitely just redefine using def

17:15 jtoy: oh ok, cool

17:18 any of you guys come from imperative background before clojure? I'm wondering how long it took you to get assimilated, before being productive? i've read through clojure in action and have been coding for ~ 2 weeks, things are pretty slow , although making decent progress

17:19 daniel-renfer: Learning clojure is a series of "aha" moments

17:21 jtoy: it seems pretty cool so far, but a bunch of stuff i still think, "i don't see how someone could naturally want to program that way", probably bc not enough experience yet

17:24 for anyone who didn't see this yet: https://github.com/takeoutweight/clojure-scheme

17:29 beffbernard: Lets say I have a user-model that stores a user into a persistent store.. What's proper style with dealing with the connection? Do I pass it in or use something like (with-connection …) or is it ok if I have a global connection?

17:31 daniel-renfer: I think more often than not, something like that gets stored to a ref (or similar) and accessed that way

17:35 technomancy: probably a thread-local

17:37 beffbernard: ok

17:43 dgrnbrg: does anyone know why this lein plugin npe's in the loader (only see an NPE in line 1) of that file. Rest of source is at https://github.com/dgrnbrg/guzheng

17:44 technomancy: you probably know the answer

17:48 technomancy: dgrnbrg: lemme see

17:48 what file?

17:48 dgrnbrg: thanks :)

17:48 the gist has the plugin

17:48 it's @ src/leiningen/guzheng.clj

17:49 technomancy: I don't see a gist

17:49 dgrnbrg: I tried to follow the template in radagast

17:49 https://gist.github.com/2323127 :)

17:49 technomancy: oh... don't follow radagast; it will only work with lein1

17:49 haven't gotten around to updating it yet

17:50 dgrnbrg: ah

17:50 technomancy: in this particular case you're using leiningen 1 but calling eval-in-project using the arity from leiningen 2

17:50 dgrnbrg: got another template?

17:50 clojurebot: Pardon?

17:50 dgrnbrg: Or is this just a 1-liner?

17:50 technomancy: if you have leiningen 2, just do "lein new plugin lein-guzheng"

17:50 if you have lein1, you use the lein-newnew plugin

17:51 dgrnbrg: that makes it part of the current project?

17:51 technomancy: well the thing is in lein2 you can't have in-project code in the same jar as in-leiningen code

17:51 dgrnbrg: i see

17:51 technomancy: you need guzheng and a separate lein-guzheng jar

17:51 I'd recommend doing plugin development in lein2 and testing it in lein1 once it's working

17:51 dgrnbrg: do you have an example project I could refer to?

17:51 I've only ever used lein1

17:52 technomancy: "lein new plugin lein-guzheng" will spit out a sample you can work from

17:52 dgrnbrg: but I don't have lein2?

17:52 technomancy: clojurebot: plugin guide?

17:52 clojurebot: Huh?

17:53 technomancy: ok, you can install the lein-newnew plugin then if you want to keep using leiningen 1

17:53 dgrnbrg: I'll need to get that first, and then use the plugin system?

17:53 ok

17:53 technomancy: https://github.com/Raynes/lein-newnew/

17:53 dgrnbrg: so lein newenew plugin lein-guzheng?

17:53 technomancy: no, just "lein new"

17:53 https://github.com/technomancy/leiningen/blob/master/doc/PLUGINS.md <- lots of good stuff in here too

17:53 dgrnbrg: ok

17:55 jblomo: is there a way to generate a class with multiple fields? for java interop?

17:56 gen-class seems to just allow 1, defrecord doesn't let you inherit from another class

18:00 sritchie: jblomo: use a map for the state, then write setters and getters?

18:04 jblomo: sritchie: hrm, yea, I would like to add javax.validation.constraints to the fields, to fit in with the java framework. sounds like it may be easier just to write this part in Java

18:06 hrm, maybe another way to write is with defrecord. can one provide default values for fields?

18:09 mega: anny one whant to try out https://github.com/megakorre/cljs-event

18:09 have someone done annything simular?

18:50 dgrnbrg: technomancy: I've made a guzheng & lein-guzheng project on my github, but I don't understand the error in the lein-guzheng plugin

18:50 it seems to be unable to get guzheng

18:50 I've never done any of this packaging though, or really looking into lien's internals

18:51 technomancy: dgrnbrg: you'll need to add guzheng into the project's dependencies if it's not there already; lemme find an example

18:51 https://github.com/technomancy/swank-clojure/blob/master/lein-swank/src/leiningen/swank.clj#L59

18:53 dgrnbrg: I'm failing to have it run even w/in the plugin's dir itself

19:23 jayunit100: how can i get the values 1 through 4 in an map ? (i.e. i believe maps are ordered in clojure. right?)(

19:24 technomancy: jayunit100: no, maps aren't ordered

19:24 jayunit100: hmmm. but they are seqable ?

19:25 technomancy: yep

19:25 jayunit100: so does the seqable have a default ordering ?

19:25 I could use a java tree set

19:25 antares_: there is sorted-map

19:25 jayunit100: ah ok

19:25 technomancy: for a given immutable map, every call to seq will have a deterministic order

19:25 but as soon as you assoc something else in, no guarantee holds

19:26 jayunit100: oh ok, so its not a dynamic function implementing the ordering... its some other mechanism .

19:31 yoklov: does anybody know the reason behind the lack of complex numbers in clojure?

19:33 because goddamn i would kill to have those built in.

19:38 at least there's Ratio, but that's not nearly as useful as complex (in my opinion, at least)

19:39 Frozenlock: Lack of complex numbers is surprising. Advantage Emacs :P

19:39 mk: perhaps they simply haven't been implemented

19:39 offby1: so ... profiling. I see there's a clojure.contrib.profile, but I was hoping for something that would periodically sample the stack, so that I wouldn't have to stick probes all in my code ... is there anything like that?

19:40 yoklov: i'd be extremely happy if clojure got them in the future

19:40 mk: why not add them

19:41 yoklov: no way to do it with any hope of efficiency and still get to use + - * / etc.

19:41 algo.generic makes those into multimethods

19:42 it would have to be in the java side

19:42 (probably)

19:43 mk: I was thinking that it would be nice to have an approx+, approx* etc., which would cast numbers to floating points

19:43 if they were already floating point, the language wouldn't need to cast

19:45 ,[(+ (double 0.1) (double 0.2)) (+ (float 0.1) (float 0.2))]

19:45 clojurebot: [0.30000000000000004 0.30000000447034836]

19:46 yoklov: (defmacro approx+ [& forms] `(+ ~@(map #(list 'double %) forms)))

19:46 mk: that can't be right. And oddly, my clojure gives 0.3 for the second one

19:47 looks like that's due to the version

19:48 yoklov: not sure - the idea would be to have even true numbers implemented as floats

19:49 yoklov: ?

19:49 true numbers?

19:50 mk: proper numbers. The idea is that approx+ wouldn't do type conversion

19:52 yoklov: how would that be possible?

19:52 mk: unsure. Usually ratios are represented by two ints, but there's no reason they couldn't sometimes be represented by a float or double

19:53 yoklov: err

19:53 yeah there is?

19:53 ratios?

19:53 i mean

19:53 mk: right. Only some values

19:53 yoklov: the definition of rational number

19:53 from... math

19:53 mk: for example, 1/2 can be represented by float0.5

19:54 yoklov: oh, i thought you said *two floats or doubles

19:54 though, that would mean there's no point to the rational numbers

19:55 mk: well, it could also be represented by 1.0 and 2.0 (or 1.0 : 1.0), but I don't see why that would be an efficiency gain

19:55 yoklov: no it wouldn't.

19:55 it would be terrible in fact

19:56 the reason (or, at least, one reason) to have rational numbers is there are algorithms that only work if you have percise fractions.

19:56 mk: if we're about to throw a very complicated number into a lot of approx-math, then we can essentially pretend that the number is backed by floats (or doubles)

19:58 so the language might simply convert it to a float, do the approximate math, and then toss it back out - but, importantly, the type wouldn't change

19:58 yoklov: that's probably not possible

19:59 i don't know if you can go from exact -> inexact -> do some math -> exact

20:00 aperiodic: is it possible to create an enum type in clojure?

20:00 amalloy: it's trivial, if you are a wizard with a magically-enhanced FPU, yoklov

20:00 mk: unsure. You might compose all the steps into a single math step, check if all the math in there is approximate, and if it is, do a single typecast at the start, and a single typecast at the ned

20:00 amalloy: but otherwise probably not possible

20:01 yoklov: mk: right, lets say you can do that (composing the steps sounds hard but whatever), you still might get a wrong answer in the end

20:01 amalloy: mk: i think you're saying a lot of things that sound to you kinda like they would be cool individually, but don't have sufficient internal consistency for someone to convince you otherwise. perhaps you should try implementing something yourself, and come back when you have something more concrete to discuss

20:03 yoklov: when you go from rational -> double, say, you lose information, and the semantics of doubles aren't such that you can really expect the answer to be right at the end, or even particularly guessable.

20:03 i mean go for it :p, it will probably be nifty either way

20:04 mk: amalloy: if you have a solid reason against the idea, bring it up. I'm just thinking out loud and, I suppose, seeing what others think. That's a step towards having something more concrete to implement.

20:06 yoklov: you lose information, but you'd lose it even if you used approx+ on a rational. (approx+ 1/10 1/5) would yield the fractional representation of .30..04, for example

20:06 aperiodic: i found this old conversation in here between amalloy and seancorfield about it, but it seems that seancorfield was just reifying instances of an externally-defined enum type

20:06 yoklov: mk: yeah, i'm not sure if i see a need for approx+ either :p

20:08 mk: yoklov: because the programmer wouldn't think of numbers as being approximate, but as exact (even doubles), and the operations as being approximate

20:09 amalloy: aperiodic: i don't think you can create a jvm-style enum class from clojure

20:09 beffbernard: What does the convention of an asterisk suffix mean? e.g. with-bindings*, with-connection*

20:10 amalloy: "internal", roughly. or "helper" or whatever

20:10 beffbernard: amalloy: k

20:11 technomancy: it means "I couldn't be bothered to think of a good name for this function"

20:12 beffbernard: technomancy: lol, if that were the case, I'd have a methods like, foo********

20:12 amalloy: oh man. you just stole my exact joke, beffbernard

20:12 except i was going to accuse technomancy of having projects full of such functions

20:12 beffbernard: :D

20:12 * Frozenlock sweeps his *** functions under the carpet

20:12 mk: you don't even need the foo at the front

20:13 aperiodic: amalloy: could you explain what you mean by jvm-style? could i fake it somehow?

20:13 amalloy: you can write any number of "enum-like" things in clojure

20:13 aperiodic: well, i guess i need a completely jvm-style one

20:14 i need to convince hadoop it's an enum type that's contained in the class i'm creating with gen-class

20:14 mk: aperiodic: jvm-style enums are very similar to jvm classes with a private constructor, and a few static fields such as public static MyEnum foo = new MyEnum(...)

20:15 aperiodic: mk: sure, but can i forge an enum that's indistinguishable from the real thing to jvm consumers of my class?

20:15 yoklov: aperiodic: try putting :extends java.lang.Enum in the gen-class?

20:16 no clue if that will work

20:16 aperiodic: hmm. worth a shot.

20:16 beffbernard: aperiodic: Why not just write that part in java?

20:16 yoklov: because writing in java sucks!

20:16 beffbernard: :) but it would have been done by now ;)

20:17 aperiodic: beffbernard: well, no, because it needs to be an inner class/enum of the class i'm creating with gen-class

20:17 yoklov: that's horrifying, why does hadoop require something so specific

20:18 aperiodic: i suppose i could manually write a wrapper class that does essentially the same thing as the gen-class and just forwards stuff to the clojure implementation... but that sounds really boring to write

20:18 yoklov: this is how counters are implemented in hadoop. i think it's pretty dumb, too

20:18 yoklov: jeez

20:25 aperiodic: well, i can generate a class that's named like an inner class, and extends java.lang.Enum. so, that's a start

20:28 amalloy: i'd be surprised to learn that you can generate enums that way. let me know if it works

20:41 technomancy: why on earth is isUpperCase a static method on Character?

20:41 oh jabba, you so crazy

20:42 amalloy: technomancy: wait, why does that not make sense?

20:42 technomancy: why isn't it just a method?

20:42 amalloy: because 'x' isn't an object

20:42 * technomancy wants to use memfn

20:43 amalloy: "because primitives"

20:43 technomancy: whatever.

20:43 double and long are the only primitives that matter

20:44 when are we getting tagged fixnums anyway?

20:44 even elisp has em =(

20:44 amalloy: i read that JDK 10, or some such imaginary-future-vision version, is hoping to get rid of primitives

20:44 so you can tell your grandkids about how you had to deal with primitives

20:44 technomancy: well, I don't

20:44 personally

20:45 but I do have to deal with Character's static methods, so indirectly I suffer

20:45 amalloy: right

21:48 dgrnbrg: technomancy: got any ideas on why running lein guzheng fails to load? https://github.com/dgrnbrg/lein-guzheng

22:07 yoklov: jesus christ, -> makes s-expressions so much less horrible for arithmetic

22:09 (-> y (+ 0.5) (- y-center) (/ height)) is so much more clear than (/ (- (+ y 0.5) y-center) height)

22:12 mk: -> is useful whenever you are transforming a value

22:14 yoklov: i don't typically think of arithmetic as a transformation, but yeah that fits

22:17 mk: some arithmetic probably doesn't work that way, but in your example, I'd guess you're mentally moving a point around. I was trying to think of examples of this earlier, and string transformation is pretty common

22:18 if you're writing something like (divide (toDouble (replace (trim " 99% " "%","")), 100)

22:18 ...one of the brackets is misplaced there

22:19 anyway, I think this is a huge part of the reason people hate languages with a certain form of typing

22:20 halfway through that, you need to start calling the value a double, and changing the variable name

22:21 is there a more general term for what Rich calls "identity"?

22:29 yoklov: i don't think so

22:29 and even strongly typed languages don't care as long as that expression makes sense

22:29 input and output don't necessarially need to be the same

22:53 hobbyist: Hi y'all. In IntelliJ Idea 10, is it possible to open a REPL instance on the current clojure file?

23:01 yoklov: i don't know of anybody who uses intellij. can you get any sort of repl at all?

23:02 * offby1 was tempted to try it, out of blind hatred for Eclipse

23:03 arohner: is it possible to tell how many args a fn will take, ahead of time? in a way that doesn't lie (i.e. not arglist metadata)

23:04 yoklov: offby1: lies. you never considered leaving emacs for a second

23:05 offby1: well.

23:05 * offby1 glances around nervously.

23:05 * offby1 's reputation precedes him

23:08 yoklov: arohner: probably not, don't fns usually have the other arities defined and they just throw for them?

23:09 arohner: yoklov: yeah, all fns inherit from AFn which throws on all arities

23:09 yoklov: yeah, then I can't imagine it would be anywhere else but the metadata

23:10 which could be wrong.

23:10 how often does that happen though?

23:11 treehug: hobbyist: yes it is possible

23:20 hobbyist: treehug: hint? I have La Clojure (Idea 10.5). The Tools/Clojure /Load file to REPL is disabled. I assume it shouldn't?

23:20 treehug: hobbyist: start repl first, then load to repl should work

23:26 hobbyist: teehug: thanks. It appears to work as the file is now loaded. However symbols are not resolved though file compiles ok

23:27 Unable to resolve symbol: myFunc in this context, compiling:(NO_SOURCE_PATH:3);

23:27 NO_SOURCE_PATH..

23:28 yoklov: that means in the repl

23:29 what does the bit before the => say in the repl?

23:39 hobbyist: treehug: things good except fully qualified names are required. Anyway around that?

Logging service provided by n01se.net