#clojure log - Sep 18 2011

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

0:37 srid: is there a reduce like primitive but for applying the function on the result only?

0:38 basically, to feed the result of a function to itself

0:39 until it returns nil or something

0:43 technomancy: srid: iterate?

0:43 srid: oh nice

0:49 so there is no 'iterations' (analogous to 'reductions' for 'reduce')

0:56 tomoj: what would you expect it to do?

0:57 pcavs: Do people use etags for clojure source code in emacs or is there a better way?

0:58 mrh0057__: Use can use autocomplete

0:59 https://github.com/m2ym/auto-complete

0:59 pcavs: mrh0057__: I want to be able to lookup definitions quickly and easily

0:59 mrh0057__: it will pull of the docs

1:00 alandipert: srid: iterate returns a lazy-seq like reductions does, so in that sense they are similar

1:02 mrh0057__: pcavs: there is a shortcut in emacs to lookup a symbol. I don't remeber what it is but you have to be running slime for it to work.

1:04 pcavs: it C-c C-d C-d

1:04 technomancy: M-. jumps to definition

1:27 zvrba: can somebody explain clojure's functions signatures? I find them extremely confusing

1:28 for example, documentation for cond gives ([ & clauses]) as arguments

1:28 which makes me expect that it wants a vector of clauses, i.e., that (cond [x y, u z]) is the correct invocation

1:30 tomoj: &((fn [& clauses] clauses) 1 2 3)

1:30 lazybot: ⇒ (1 2 3)

1:31 zvrba: tomoj: i don't get it.

1:31 tomoj: the extra () around the [& clauses] just wraps all the different signatures (cond has one)

1:31 do you know what the & means?

1:32 zvrba: kinda, yeah. for introducing variable argument lists. but that's not what confuses me.

1:32 here's the signature for defn: ([name doc-string? attr-map? [params*] body] [name doc-string? attr-map? ([params*] body) + attr-map?])

1:33 so what is the list in the 2nd element of the vector

1:33 namely, ([params*] body)

1:33 ahh

1:33 tomoj: that's a different (non-clojure) syntax for describing a signature

1:33 zvrba: i guess it's kinda regexp.

1:33 tomoj: yeah, I guess the ones for defn are hand-written

1:34 zvrba: :/

1:34 "great"

1:35 tomoj: impossible to describe defn's "signatures" in the standard syntax

1:35 no optional args, the + is funky, etc

1:35 zvrba: ok

1:41 tomoj: never really noticed that before

1:41 would be unfortunate if you have a function with argument names ending in ?/*/+...

1:49 zvrba: heh

2:20 pcavs: What's the proper way to take a variable number of function arguments and then apply each one to the same object?

2:23 tomoj: juxt

2:23 tufflax: maybe ##((comp - inc) 1) or ##((juxt - inc) 1)

2:23 lazybot: ((comp - inc) 1) ⇒ -2

2:23 ((juxt - inc) 1) ⇒ [-1 2]

2:23 tufflax: depends on what you mean exactly

2:25 pcavs: tufflax: sorry, to be clearer, I have a java object that I need to run multiple functions on. I do not want to compose them, I think juxt is closer to what I want. thanks

2:25 tomoj: ew

2:26 pcavs: tomoj: yeah, I may be doing something not so hot right now

2:26 tomoj: blame java

2:26 pcavs: Trying to hack in some transactions into the current clj-redis

2:26 which uses jedis, and that seems to be their transaction model

2:27 tomoj: juxt for side effects just seems weird

2:27 pcavs: tomoj: yep...

2:33 amalloy: pcavs: you might want doto

2:36 pcavs: amalloy: hmm maybeee

2:36 I think I'm going to try to hack up two or three different approaches and see which one I like best, thanks for the tip though

2:42 tomoj: wow

2:42 that looks terrible

2:44 blazingly sane? doesn't look that way to me...

3:21 amalloy: tomoj: i think i somehow managed to miss seeing the object of your derision

3:25 tomoj: jedis

3:26 this looks nice, an interface! https://github.com/xetorthio/jedis/blob/master/src/main/java/redis/clients/jedis/JedisCommands.java

3:26 but https://github.com/xetorthio/jedis/blob/master/src/main/java/redis/clients/jedis/BinaryTransaction.java

3:26 amalloy: uhoh. a constant holder?

3:26 no, an actual interface, i see

3:27 tomoj: then https://github.com/mmcgrana/clj-redis/blob/master/src/clj_redis/client.clj

3:27 looks like a PITA

3:27 pcavs: tomoj: it's not bad at all if you're not using transactions

3:28 but yeah, it's a bit troublesome

3:28 tomoj: yeah, I was overly derisive

3:29 guess they wrote the regular stuff first and then added transactions on awkwardly

3:29 amalloy: heh. Queable, indeed

3:31 pcavs: what's the proper way to deal with (&) rest arguments? Specifically if I'm writing a function that will take rest arguments, and I want to pass those alone to another function as regular arguments, i.e., not a list? I basically want unquote-splicing, but it's not in a macro…Or am I just horribly misguided?

3:33 amalloy: would you settle for "misguided, but nothing horrible about it"?

3:35 (i don't actually understand your question, but the answer is probably ##(doc apply))

3:35 lazybot: ⇒ "([f args* argseq]); Applies fn f to the argument list formed by prepending args to argseq."

3:35 pcavs: amalloy: ahh, that would probably be quite alright

3:36 michaelr525: hello

4:51 nerooth: Problems with file upload and NullPointerExceptions - https://gist.github.com/1224883 - any ideas?

5:03 thorwil: nerooth: did you make sure (file :tempfile) is non-nil?

5:05 nerooth: thorwil: nope

5:12 thorwil: I don't know if this is the right way to test for nil, but it still gives a NullPointerException https://gist.github.com/1224883#comments

5:14 shtutgart: What's the difference between binding and with-redefs?

5:14 thorwil: nerooth: that comment makes no sense at all to me

5:15 kumarshantanu: shtutgart: with-redefs changes the root binding (visible across all threads)

5:15 thorwil: nerooth: how about calling ds/copy on the repl, not with (file :tempfile) but with what is supposed to be a result of that?

5:15 kumarshantanu: shtutgart: binding changes it just for the current thread

5:16 nerooth: thorwil: it looks weird indeed, formatting got fudged in the comment, I added it at the top of the gist https://gist.github.com/1224883

5:17 shtutgart: kumarshantanu: ah, so it's for things like (with-redefs [foo bar] (future (foo)))?

5:17 kumarshantanu: shtutgart: with-redefs might be useful mainly for unit-testing (mocking), because it restores the binding upon end

5:18 nerooth: thorwil: that is a good idea indeed, but I don't know what the result is supposed to look like

5:22 thorwil: nerooth: that's ... not a good sign :) consider a println here or there to see what you actually dealing with, if you don't manage to take it apart on the repl

5:24 shtutgart: kumarshantanu: and behaviour of the binding remains the same? I heard there was talks about making threads inherit env

5:24 nerooth: thorwil: Indeed not :P Thanks for the help. Used to figuring it out from the error messages I guess. Any resources on how to do clojure debugging for a beginner?

5:25 kumarshantanu: shtutgart: binding works the same, except that in Clojure 1.3 all vars are static unless they are declared dynamic

5:25 shtutgart: kumarshantanu: ok, thank you

5:26 thorwil: nerooth: none i'm aware of. i happens often enough that stacktraces make no sense to me

5:28 shtutgart: ah, one more question: what does find-keyword supposed to do? "keyword exist" means that it's been used in the given ns, or what?

5:30 nerooth: thorwil: If I for example want to print out the contents of "file", how would I go about to do that? I know file is (get params "file") which comes from the file upload, but I don't understand how to access them.

5:31 thorwil: nerooth: (println file)

5:31 nerooth: exactly where that is printed depends on your editor/environment

5:32 nerooth: thorwil: that was simple enough, thanks :p

5:40 otfrom: Morning. London Clojurians Incanter Hack Day checking in from beautiful Royal Festival Hall. :-D

5:40 Would Incanter chat and questions be better on #incanter?

6:27 I'm guessing everyone is busy at strangeloop today.

6:35 tomoj: not everyone :(

6:56 otfrom: well, you could always come to London and join us on our Incanter Hack Day. :-D

6:56 or just join in remotely

7:34 shtutgart: hm, so now it's preffered to name fns foo and foo' instead of foo and foo*?

7:42 tomoj: certainly not

7:42 well.. "now"?

7:42 did something happen I don't know about?

7:43 &(let [foo' 3] foo)

7:43 lazybot: ⇒ 3

7:43 shtutgart: tomoj: in 1.2 foo' just doesn't work, and there is +', -', inc', dec' in 1.3

7:44 tomoj: ah

7:44 haven't moved yet

7:44 maybe that's just cus +* and -* would look weird?

7:44 shtutgart: and it's meaning is nearly the same as in foo and foo* - same, but slightly different

7:44 yeah, and especially **

7:45 tomoj: were there ever any public ..* vars?

7:46 s/public//

7:46 shtutgart: but there is no reason to have 2 different naming conventions for the same thing, imo

7:46 hm, let me think

7:46 tomoj: I think I only ever used foo* inside the definition of foo

7:48 oh, there are internals like fn*, deftype* etc

7:49 ..which are really just for defining fn, deftype etc

7:51 not sure what exactly the * in list* is supposed to mean

7:52 with-bindings*, bound-fn*

7:52 shtutgart: (list* ...) is the same as (apply list ...)

7:53 tomoj: so, same but different, or is the * suggestive of application?

7:54 interesting that with-bindings* and bound-fn* both apply a fn arg

7:54 oh, but they're just functions for the macros

8:03 shtutgart: sorry, was afk. "same but different" i think. On the other hand, I can't remember seeing list* in the real code, and it looks like in core foo* treated mostly as a helper for foo...

8:07 after all, it's a Scheme convention, not the clojure one! actually, i tend to prefer foo' because it doesn;t overlap with earmuffs (some newcomers find it confusing) and looks like math notation (it's cool!), wdyt?

8:11 cemerick: tomoj: foo* is generally taken to be an implementation detail of a public/supported foo function or macro

9:19 * Nocab keeps getting hindered by his typesafe background

9:19 Nocab: it's incredibly easy to read (defn foo [seq s] ...

9:19 as a function foo, which accepts one parameter s of type seq ;)

9:22 otfrom: ANN: London Clojure Dojo for September sign up page is up. https://ldncljdojo.eventwax.com/september-2011-london-clojure-dojo/

9:23 though I think most of the currently online London Clojurians are sitting next to me hacking.

9:23 michaelr525: otfrom: what are you hacking?

9:24 otfrom: we're adding things to Incanter

9:24 though 2 of us are building a little website for the next dojo

9:25 michaelr525: what things? and why you do it?

9:25 otfrom: which will be a 20 questions kind of thing where you add to a knowledgebase.

9:25 I'm going to do something like the head command from unix (return 1st 10 lines)

9:25 other people are working on a summary function

9:26 others are working on tests for the normal distrbution

9:27 why? well, why not get together and hack. :-D

9:27 michaelr525: why on incanter of all things?

9:27 otfrom: 'cos stats are cool.

9:28 michaelr525: :)

9:29 otfrom: we'll be doing it every month at least until the end of the year. 3rd Sunday of the month.

10:52 zvrba: what's wrong with this code?

10:52 http://pastebin.com/eyjfE1aK

10:52 it says "wrong # of args passed to persistent vector (0)"

10:52 when I call it with (adjoin-set 2 [1 3 4])

10:53 when I try to execute the individual clauses manually, i get no error

10:54 or, adjoin-vset

10:56 ok, found it. nevermind.

10:56 is there a usable debugger for clojure?

10:59 Bronsa: zvrba: ever tried swank-clojue?

10:59 *clojure

11:00 zvrba: yes, i'm using it

11:01 or, i'm using slime that's packaged with leiningen

11:01 whatever makes clojure-jack-in work

11:01 (someone told me that swank-clojure isn't the backend for slime)

11:02 anyway, i get no useful info about the point at which the error occurred

11:02 somewhere on the stack sits my function and it says "no source"

11:02 Bronsa: well, if you use swank-clojure 1.4.0-SNAPSHOT, you will have CDT support

11:02 zvrba: cdt?

11:03 Bronsa: clojure debugging toolkit

11:03 http://georgejahad.com/clojure/swank-cdt.html

11:03 ^ see this

11:03 zvrba: sigh

11:03 it should be forbidden by law to unleash languages unto the world w/o a complete toolchain. </rant>

11:04 i got a message resembling this: java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to java.lang.Number (NO_SOURCE_FILE:0)

11:05 i don't want to set manual catchpoints etc. i just want to get a clear indication of what went wrong. no manual labor.

11:05 possible or not?

11:06 TimMc: zvrba: Got a stack trace?

11:08 zvrba: TimMc: http://pastebin.com/sFRTC1HG

11:09 (i have put the error back in the code)

11:09 TimMc: (there's much more on the stack, but I've pasted only the most relevant part)

11:12 TimMc: Ooops, have to attend to stove.

11:13 Usual tips: (.printStackTrace *e), macroexpand-1, and print statements

11:15 zvrba: TimMc: but ptrintstacktrace from where?

11:24 TimMc: zvrba: Are you in a REPL?

11:25 It's a little hard to tell, but it sounds like you're getting an error message in a REPL after trying to evaluate something.

11:25 I don't work from SLIME, so I don't know how to get line numbers, unfortunately.

11:26 (I see you already have a stack trace, but it's not giving much info.)

11:26 zvrba: TimMc: yes, i'm in repl

11:27 the error message is otherwise clear: it seems that it can't find the source for functions evaluated in a repl

11:28 but there is (should be) also loop on the stack as well as conj, which would make it easier to track down

11:28 TimMc: I think you'd have to post your code for anyone to help any more.

11:28 zvrba: since the offending code is (loop ... (recur (conj .. (faulting-code))))

11:28 TimMc: Or maybe one of the SLIME users in here can give SLIME-specific debug tips.

11:29 zvrba: TimMc: http://pastebin.com/eyjfE1aK

11:29 TimMc: I usually use the REPL for development of individual functions and use lein run to actually evaluate my code.

11:30 zvrba: TimMc: anyway, the (rest (rest-of-vset)) -> at least the rest function should be on the stack

11:30 but it disappeared :

11:30 :/

11:31 TimMc: is (rest-of-vset) correct?

11:31 should you be calling that as a function?

11:32 Yeah, that's it.

11:32 zvrba: TimMc: no, it's not correct -- i've found the error.

11:32 TimMc: You're trying to call a vector as a function of no arguments.

11:32 zvrba: TimMc: but i've found it by guessing. it would have been much easier if I saw rest on the stack

11:32 TimMc: indeed

11:32 zvrba: so, where did the call to "rest" disappear?

11:33 TimMc: Well, your code didn't have a chance to call rest.

11:33 It was trying to evaluate the arguments to rest, and that failed.

11:33 zvrba: ahh, i get it

11:34 funnily, i'm thinking lazily

11:34 TimMc: heh

11:34 zvrba: i thought that rest would force evaluation of (rest-of-vset) and therefore I expected rest on the stack

11:34 it's funny because i've never programmed in a lazy language

11:35 TimMc: Only if (rest-of-vset) were part of the generator of a lazy seq.

11:35 zvrba: which it wasn't

11:35 btw, when would one use lists in clojure?

11:35 TimMc: Clojure isn't actually a lazy language, it just has some lazy features.

11:35 zvrba: vectors don't seem to have any downsides?

11:37 btw, (rest [1 2 3 4]) -> (2 3 4) .. why does it switch between vector and list?

11:38 TimMc: conj'ing onto a list takes constant time, I suppose

11:38 ,(type (rest [1 2 3 4]))

11:38 clojurebot: clojure.lang.PersistentVector$ChunkedSeq

11:38 TimMc: That's a seq, not a list.

11:38 Lists and seqs behave *very* similarly, which is why they print the same way.

11:39 rest calls seq on its argument

11:39 ,(rest "abcd")

11:39 clojurebot: (\b \c \d)

11:40 zvrba: ok

11:40 TimMc: seqs provide a consistent abstraction on top of the various collections (and are a collection type themselves)

11:41 Anyway, I believe that lists are usually used when you only need sequential access.

11:41 zvrba: oh. i though seq was just a unified interface. hence, my expectation that the type would be preserved

11:41 ok

11:43 TimMc: Well, you can always call (vec (rest some-vector)) if you really need to.

11:44 There's not much point in that if you just need sequential access, of course.

11:44 (Also, I bet vec is smart enough to peek under the covers and see that the seq is backed by a vector already...)

11:52 Chousuke: vectors tend to be better for most use cases of regular lists in other lisps, but you still end up using seqs a lot.

12:41 konr: Any idea of what might be generating this (http://3d843a8c52457f13.paste.se/) cryptic error? My code is simple. http://3c0d402c0dc1bd28.paste.se/

12:43 jkkramer: konr: passing nil to slurp on line 10?

12:43 er, line 12

12:44 konr: Oh!

12:44 Of course! Thank you jkkramer!

12:48 jkkramer: konr: FYI, I surmised that from the stacktrace. the error sounds like nil is getting passed to an IO function. slurp is an IO function, and near where the stacktrace points to: "lab2.clj:10"

12:49 konr: clojure errors may seem cryptic at times, but they usually contain the info you need to troubleshoot

13:16 rfgpfeiffer: Is there a way to use ring and plain sockets or socketchannels in the same ring app? I would like to use NIO scattering/gathering operations on some routes.

13:24 coconaut: Hello! Does IntelliJ IDEA supports ClojureScript projects?

13:26 dnolen: coconaut: I don't think any of the tools have good support for ClojureScript yet.

13:26 devn: So, I haven't done much with Java interop in the past -- if I get something back like #<RubyArray> [:xyz, :abc]> -- what's the best way to convert that to a plain Clojure vector?

13:26 konr: http://i.imgur.com/vQdQd.png Made with Clojure :)

13:26 dnolen: konr: nice

13:27 devn: you could extend that type to ISeq and (into [] ruby-array) should just work I think.

13:28 rfgpfeiffer: devn: I think RubyArray implements java.util.list

13:29 devn: dnolen: rfgpfeiffer both good to know

13:29 thanks.

13:29 dnolen: rfgpfeiffer: devn: if it implements java.util.List then (into [] ruby-array) will just work.

13:31 rfgpfeiffer: devn: sorry that was groovy not JRuby

13:31 devn: call to_java on it

13:32 devn: rfgpfeiffer: is that a RedBridge thing?

13:33 rfgpfeiffer: undefined method for #<Haml::Engine:0x032490>

13:34 dnolen: It actually does just work I think...

13:35 (take 2 (into [] (call-method (hamlize "%html") "methods")))

13:35 ;=>(#<RubySymbol html5?> #<RubySymbol options=>)

13:35 Netpilgrim: Hi. 4clojure ops: The site is on the fritz again (502).

13:35 devn: Netpilgrim: #4clojure

13:36 Netpilgrim: devn: Ah, didn't know about that channel.

13:36 dnolen: devn: if all you want to do is use sequence operations on it, no need for (into [] …) of course.

13:36 devn: dnolen: *nod* -- really what I want I guess is to convert those RubySymbols to clojure keywords

13:37 coconaut: hey guys, does anyone know if IntelliJ IDEA supports clojurescript? Thanks

13:37 dnolen: coconaut: no, not much good tool support for ClojureScript yet, a bit too early for that.

13:38 coconaut: dnolen: thanks! I'll keep on using emacs then

13:40 devn: dnolen: am I "doing it wrong"?

13:40 (map #(keyword (call-method % "to_s")) (call-method (hamlize "%html") "methods"))

13:40 ;=>(:html5? :options= ...)

13:41 dnolen: devn: looks good to me.

13:41 devn: dnolen: any thoughts on using meta to keep around the idea that they are #<RubySymbol>?

13:42 dnolen: I have no specific goal in mind at the moment, just experimenting with JRuby interop

13:43 dnolen: devn: well keywords can't take metadata

13:43 devn: dnolen: yeah i was thinking about only doing it for homogenous sequences

13:46 dnolen: *shrug*, something to play with I guess -- my battery is dying -- sitting in the backseat on my way to strange loop

13:46 happy clojuring, all

13:46 dnolen: devn: cool cya in a bit then.

13:46 coconaut: devn: farewell!

13:46 devn: you're going to be there, eh?

13:47 dbushenko: why the new swank does not open the repl? onlj clojure-jack-in makes it open

13:47 devn: dnolen: going to the speaker's dinner?

13:47 dnolen: devn: yup

13:47 devn: cool, pm'd you my #, ciao

13:48 kzar: 4clojure's down, not sure if anyone noticed?

13:50 srid: i did. fire up a local server to solve problems meanwhile. :)

13:51 Netpilgrim: kzar: I've noticed and said so on #4clojure.

13:53 kzar: srid: IIRC you only get problems up to 87 that way

13:53 srid: cool idea though

13:54 srid: oh, hadn't noticed

13:55 Netpilgrim: srid: Can you easily clone 4clojure from Github and run it locally?

13:55 srid: yes. see the README

13:55 Netpilgrim: srid: Thanks. I'll have a look.

13:56 srid: if you don't want to run it locally, the first 87 problems are here https://github.com/dbyrne/4clojure/blob/develop/src/foreclojure/data_set.clj#L4

13:59 Netpilgrim: Has anyone here solved the word chain problem (#82) in significantly fewer than 43 lines of code?

14:00 kzar: Is there a problem with having symbols like '.' in your project name?

14:00 zvrba: Netpilgrim: which site_

14:00 Netpilgrim: zvrba: 4clojure

14:00 zvrba: ah

14:02 Netpilgrim: It took me a lot longer than all the problems before, and I think no solution was longer than 10 or 15 lines. So I'm worried that I might have overlooked an easier solution.

14:02 zvrba: 4clojure seems down, yes

14:02 i just got bad gateway

14:03 Netpilgrim: zvrba: Me, too.

14:04 zvrba: i started going through sicp with CL, and switched to clojure just for the fun of it

14:05 it became simple to write programs in cl on the sicp-level (i understood how do-iteration works, etc.)

14:06 and now, with clojure, it just feels like i'm fighting against the environment. unusable stack traces, unhelpful error messages, etc.

14:06 so. any tips? how to get a more pleasant experience using clojure?

14:08 gfredericks: 4clojure is probably attending strangeloop

14:09 Netpilgrim: zvrba: I know about SICP but haven't looked at it yet. Would you recommend it for Clojure (and Lisp in general) beginners, or should I wait until I feel comfortable with Clojure (idioms, core functions, ...)?

14:11 zvrba: Netpilgrim: sicp+common lisp = go. sicp+clojure = no-go unless you have previous experience with programming. that is, you know about pointers and lists at least.

14:12 Netpilgrim: clojure is sufficiently different from CL and scheme that you'd use a lot of energy to translate stuff from scheme to clojure.

14:13 Netpilgrim: lastly, i'm on the verge of writing off clojure. the environmental facilities (debugging,error messages) are barely usable. it's back to printf-debugging.

14:13 Netpilgrim: zvrba: I do have some experience with object oriented programming and should know enough about pointers (though I've never done anything in C).

14:13 zvrba: which is a shame, because i really do like how clojure, the language, is designed.

14:13 for example, collections can be used as functions to perform lookup.

14:15 Netpilgrim: zvrba: Is what SICP teaches interesting enough to make it worth the effort of translating it to Clojure?

14:15 zvrba: Under the assumption that I stay with Clojure for a while. :)

14:16 zvrba: Netpilgrim: it is worthwhile to internalize what SICP teaches.

14:17 i already knew a lot of that stuff, but i wanted a set of concrete exercises to solve with lisp.

14:17 Netpilgrim: zvrba: I'll look at it, when I'm through with The Joy of Clojure.

14:17 dnolen: Netpilgrim: I would just do SICP in Scheme/Racket. Clojure has existing / better answers for many of the things covered in SICP

14:18 Netpilgrim: dnolen: I'll keep that in mind.

14:19 zvrba: Netpilgrim: but i'd turn your question upside down: personally, I think that clojure is not worth bothering with until the environment becomes more mature.

14:19 zackham: zvrba: if you're looking for material to burn through, https://github.com/functional-koans/clojure-koans and 4clojure (apparently down right now) are good fodder

14:19 zvrba: zackham: oh, thanks!

14:19 dnolen: zvrba: fair enough, but given the amount of production code out there using Clojure, I think a lot of people disagree.

14:20 zvrba: and yes, I hate github. it has utterly f*up formatting of webpages. (nothing to do with clojure)

14:20 zackham: zvrba: dont use it just git clone https://github.com/functional-koans/clojure-koans.git :P

14:20 Netpilgrim: zackham: I'm already doing the 4clojure exercises. I'm at problem 82 right now. I love that site.

14:20 zvrba: zackham: :)

14:20 dnolen: i know that. fair enough.

14:21 zackham: zvrba: environment feels pretty mature/functional in the typical emacs/slime/lein setup

14:21 zvrba: zackham: nope. stack traces are utterly unhelpful.

14:21 zackham: earlier today I pasted an erroneous code example and stack-trace.

14:22 zackham: i had to solve problem by staring and incremental searching in emacs.

14:22 Netpilgrim: zvrba: I've seen a lot of stack traces today, and they always showed me exactly where the problem was. But I'm not working on complex projects, just small exercises.

14:23 zvrba: Netpilgrim: http://pastebin.com/eyjfE1aK , http://pastebin.com/sFRTC1HG

14:23 Netpilgrim: tell me where the problem is

14:23 (i've solved it, btw)

14:23 ++ for opera's history search :D

14:24 Netpilgrim: no locals (neither names nor values), no bigger context, nothing. it's "somewhere" in the adjoin-vset function

14:25 Netpilgrim: zvrba: For starters, NO_SOURC_FILE makes it a bit hard. I guess with a file you would get a correct line number.

14:25 zvrba: Netpilgrim: i want to develop my functions and test them in REPL.

14:25 dnolen: zvrba: I spotted your error right away.

14:25 (rest-of-vset)

14:27 Netpilgrim: zvrba: And I'm no suitable candidate. I still need about half an hour to understand what other people's code does, even if it's just a few lines.

14:27 zvrba: dnolen: ok :) i used approx 5 minutes to fix it. and 5 minutes is way too much.

14:27 zackham: zvrba: i feel like in any language you deal with this.. some errors seem cryptic until you get used to them

14:27 zvrba: Netpilgrim: right. and *exactly* at that stage, you need as much help from the environment as it can provide you with.

14:28 zackham: c/c++ compiler would have provided me with rather accurate location in the file and the names involved in the offending expression.

14:28 CL compiler warns about wrong number arguments to a function invocation

14:28 clojure merrily does nothing.

14:29 zackham: well you arent invoking a function you are trying to invoke a persistentvector as a function =)

14:29 told you that pretty clearly

14:29 dnolen: zvrba: if you had compiled the file you would have been given a precise line number

14:30 zvrba: dnolen: http://pastebin.com/C2v1yNi8

14:30 dnolen: no warning for definition of g. happy? :)

14:30 Netpilgrim: zvrba: Well I guess, it partly depends on what you want to do with the language. I don't expect to write anything big and production-ready anytime soon. I just want to learn some functional programming. So it's not too bad, if I need a few minutes more to find errors in my code.

14:32 zvrba: Netpilgrim: SICP is not a big project. but I want to focus on solving problems, not on guessing about where errors are. yes, I can compile my files, but that defeats the point of having a REPL.

14:32 dnolen: zvrba: advance warning would be nice, but the runtime error is pretty obvious.

14:33 cemerick: That seems like real edge case to have a warning for.

14:33 Netpilgrim: zvrba: I don't know your setup but I always write my function in an emacs buffer and compile them. That doesn't slow me down at all.

14:33 zackham: zvrba: might have something to do with supporting this too and the fact that its lazy, not sure: http://pastebin.com/NNBf38pM

14:35 zvrba: Netpilgrim: do they get automatically loaded in REPL?

14:35 upwardindex: amalloy_: It would seem that 4clojure.org is down: 502 bad gateway

14:35 amalloy_: .com my bad

14:37 shtutgart: zvrba: but there is number lines in stacktraces... or do you want line when defining fn in the repl? is it even possible?

14:37 Netpilgrim: zvrba: When I add a new function, I call (use 'namespace). After that whenever I change something, I just compile (C-c C-k) and the REPL is updated.

14:37 zvrba: shtutgart: no, it's not possible when defining in REPL. but I expect more sense in error messages. local variables, e.g.

14:40 Netpilgrim: zvrba: I just checked, you can just switch the REPL to the same namespace you work in in your buffer and compiling is all you need, no extra calls to (use ...). I don't know, why I haven't realized that before.

14:41 zvrba: (defn entry2 [] (let [x []] (x))) -> compilation finished, no warnings. bleh.

14:41 shtutgart: zvrba: maybe cdt and c.c.trace will be helpful (haven't tried it myself)

14:44 zvrba: about compilation, i think it depends on your style of developing, e.g. I prefer when compiler just compiles it when i've tell him so (even if the code is obviously broken), so it doesn't disturbs and distracts from what I'm doing right now

14:45 and on the other hand haskell guys like the opposite, when "compiles" mean "works"

14:46 zvrba: i guess you're right. i'm in the latter group.

14:47 Chousuke: "compiles" doesn't mean "works" in haskell though. It just means you won't get errors at runtime for doing an illegal operation

14:47 it won't prevent you from doing something perfectly legal but stupid :P

14:47 zvrba: I asked on #lisp about learning a lisp dialect, and they recommended clojure. i'm starting to wonder whether it's their plot to get rid of incompetent people.

14:48 shtutgart: Chousuke: it won't, yet :)

14:48 zvrba: in the sense that they do not want #lisp to become a dwelling place for people who don't want to think for themselves.

14:50 the $10k question is: should I stick some more with clojure before discarding it?

14:51 cemerick: zvrba: You're probably inferring way too much from the particulars of what Clojure will and won't emit warnings for.

14:51 shtutgart: zvrba: well, maybe it's because clojure seems the most popular and practical lisp right now, but if you just want to learn new concepts etc, Racket will be just fine (simple, no java, batteries including ide)

14:52 Netpilgrim: zvrba: I guess I would first ask, if Clojure is the best Lisp dialect in terms of core language and libraries, and then look at the tools situation. Since Clojure is still young I guess better tools will come.

14:52 technomancy: zvrba: you must have done something to offend them if they sent you here from #lisp

14:53 zackham: zvrba: what are you trying to accomplish? if you dont care about the java interop and libraries available just use racket like shtutgart mentioned, or CL if you lean toward their choice on issues they differ from scheme in

14:53 zvrba: technomancy: oh, no, that was my first question there :)

14:53 technomancy: it was like /j #lisp, "hello, i want to learn a lisp dialect, what would you recommend" ... -> clojure

14:53 zackham: zvrba: or go play with haskell that is fun =)

14:53 cemerick: That might explain it. :-)

14:53 shtutgart: zvrba: but if you want to code some real programs in lisp dialect, you pick clojure :) imo

14:54 technomancy: zvrba: maybe you offended them by virtue of not being a guy who knows common lisp

14:54 (it doesn't take much)

14:54 nerooth: I've heard that Clojure aims to be platform-agnostic. What does that mean in practise for the coming year or three?

14:54 zvrba: technomancy: oh, no, they're very civil! :)

14:55 technomancy: nerooth: depends on how you define platform

14:55 zvrba: zackham: go through sicp, get some practice with functional programming, personal projects.

14:55 technomancy: nerooth: it is explicitly _not_ a goal to be portable across the JVM, JS, and the CLR

14:55 zackham: zvrba: just use racket for sicp and you'll be doing exercises instead of translating exercises

14:55 zvrba: zackham: i tried clojure as having java libraries seems a big bonus, but i can't go w/o decent tool support. at least decent runtime/compile-time messages.

14:56 nerooth: technomancy: So what is meant when one says that clojure aims to be platform agnostic?

14:56 zvrba: Netpilgrim: when you have a machine like C64, where you know the whole memory map and access to all internals, you can go w/minimal tool support. (hecek, even there a monitor program told you wrong # of args to an assembly instruction)

14:57 technomancy: nerooth: it means it runs anywhere the JDK runs

14:57 stay away from MIPS and you'll be fine

14:57 nerooth: I see

14:57 zvrba: Netpilgrim: but the more opaque the platform is, the better tool support you need.

14:57 zackham: ah, i've gottten to the stage where I quite easily translate the code/write exercises to CL.

14:58 but i get the point, yeah.

14:59 Netpilgrim: Has anyone here worked with swank-cdt? (use 'swank.cdt) gives me the following warning: “unabled to add tools.jar to classpath. This may cause CDT initialization to fail.”

15:00 technomancy: Netpilgrim: I got that when I used a JRE instead of a JDK

15:00 but I haven't used cdt in a while

15:00 zvrba: Netpilgrim: or, to put my attitude in perspective: i've been coding for 20 years now. i'm 8hrs daily on the job. i have other hobbies. free time is scarce. when I want to learn something new, I want to use my time on *effective learning*, not on fighting against the environment.

15:00 dnolen: nerooth: or anywhere that JavaScript runs, which these days is everywhere.

15:01 zvrba: Netpilgrim: so, tool support IS very important.

15:01 for me.

15:02 ndimiduk: Netpilgrim: i get that all the time using sun's JDK on ubuntu

15:02 Netpilgrim: ndimiduk: Yepp, that's my setup. Any idea what to do about it?

15:02 zvrba: I understand where you're coming from.

15:03 ndimiduk: Netpilgrim: i installed tools.jar into my ~/.m2/repository and include it as a dev dep

15:03 cemerick: zvrba: Clojure's 3+ years old at this point. It's going to take a while to get tooling up to the level of Lispworks and DrRacket.

15:03 Netpilgrim: ndimiduk: OK, I'll try that.

15:04 ndimiduk: Where can I find the jar file?

15:04 zvrba: cemerick: i'm talking about the level of sbcl+slime, nothing fancy like racket or lispworks.

15:04 ndimiduk: Netpilgrim: ${JAVA_HOME}/lib/tools.jar i think

15:04 zvrba: cemerick: but usable runtime and compile-time messages are *crucial*

15:05 shtutgart: is there a lib for handling optional args? i want something like (defn foo [a ^keyword b? c & more] ...), so when called (foo 1 2 3) b is nil and when (foo 1 :x 2 3) b is :x

15:05 zvrba: sbcl does not complain about missing file and is able to display local variables, for example, even for functions compiled from repl

15:05 cemerick: zvrba: I understand and agree. However, deciding upon a language because of its error messages is a…strange approach IMO.

15:05 dnolen: zvrba: the errors are usable … newbie friendly they are not … known issue and people want to fix it.

15:06 Netpilgrim: ndimiduk: Thanks.

15:06 technomancy: one of these days I'll get around to integrating clj-stacktrace into swank

15:06 zvrba: cemerick: have you read what I've written to Netpilgrim . about scarce free time?

15:06 cemerick: it might seem as a strange approach, but..

15:07 the goal is learning concepts from sicp. i'm more interested in fundamental knowledge than in particular language flavor.

15:07 shtutgart: Racket!

15:07 dnolen: zvrba: using Clojure for SICP doesn't make much sense to me

15:07 zvrba: dnolen: why?

15:08 cemerick: zvrba: Yeah, I saw. I think dnolen already mentioned how many of the topics discussed in SICP aren't really considerations in Clojure, for various reasons. You can do the problems, but you're just reimplementing bits of the Clojure/JVM runtime, libraries, etc.

15:08 dnolen: zvrba: different language, seems like you're creating complexity

15:08 zvrba: (i think i can guess: completely different approach to mutable state, to start with)

15:08 cemerick: ok, fair enough :)

15:09 i want to learn that sicp-stuff so that I can think different about programming in C and C++. :)

15:09 which is my pay-job.

15:09 so it seems instructive to implement, e.g., multiple dispatch from scratch.

15:10 shtutgart: i've tried racket, i didn't like the environment. i want emacs. and the most friendly environment is slime+sbcl, so i think i'll continue with that.

15:10 dnolen: zvrba: you know about Geiser right?

15:11 cemerick: You like good tools, but don't like racket? 0.o

15:12 zvrba: dnolen: i do. i think it only works under linux, though.

15:13 dnolen: zvrba: ? works on OS X just fine.

15:13 zvrba: win7 !

15:13 shtutgart: zvrba: yeah there is geiser, quack for scheme

15:13 You like good tools, but like win7? 0.o

15:13 dnolen: zvrba: not sure why it won't work on win7

15:14 zvrba: native emacs, guile exists only as cygwin port, etc.

15:14 dnolen: Geiser doesn't need guile far as I know.

15:14 not sure why it needs native emacs either

15:14 shtutgart: it supports both guile and racket, doesn't it?

15:15 dnolen: it does

15:15 Geiser rocks

15:15 zvrba: shtutgart: win7 is a nice desktop!

15:15 dnolen: hmm, ok, i'll take a look at it.

15:16 shtutgart: linux's downfall for me began when it became nearly impossible to use bitmap fonts. one day copy-paste between terminal and firefox stopped working, so I got fed up and installed windows.

15:17 + sound playback from 2+ different programs simultaneously became possible just by the virtue of installing windows. :)

15:18 (yes, I had a long, growing list of annoyances with linux before the copy-paste thing tipped me over the edge)

15:18 Netpilgrim: zvrba: Sound from different programs is no problem with pulse.

15:18 robermann: zvrba: did you check this: http://sicpinclojure.com/ ?

15:18 shtutgart: zvrba: I've heard there is so many problems with making emacs work under win

15:19 zvrba: hah, yeah i also have problems with sound (in tuxguitar, it just disappears sometimes), but i believe it's because of ubuntu, other distros are fine :)

15:19 zvrba: shtutgart: IPC (pipes, etc) kinda sucks. the rest works fine. no problems though with sbcl+slime

15:19 Netpilgrim: shtutgart: I've actually installed a native emacs on a windows (2003 Server I think) and it worked out of the box.

15:20 zvrba: shtutgart: but all elisp packages work without a problem.

15:20 robermann: I'm using clojurebox under win7 without problems

15:21 shtutgart: hm, ok - haven't tried it myself, just heard people complaining about that...

15:21 zvrba: robermann: yeah. but I have a paper-book

15:27 Netpilgrim: swank-cdt is cool! (http://georgejahad.com/clojure/swank-cdt.html)

15:28 shtutgart: so what's the right way to implement IFn with varargs support?

15:29 (if any)

15:32 I want to make instances of my record callable with various number of args; should I just impl invoke for every arity up to 20?

15:33 dnolen: shtutgart: good excuse to learn about macros.

15:33 shtutgart: is there a macro for such purpose already?

15:35 dnolen: yep I don't mean implement by hand

15:38 zvrba: anyway. /me off :-)

15:38 thanks for your patience.

15:59 Bronsa: user=> (Object)

15:59 java.lang.Exception: Expecting var, but Object is mapped to class java.lang.Object (NO_SOURCE_FILE:0)

15:59 user=> (1)

15:59 java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn (NO_SOURCE_FILE:0)

15:59 why do they print different error messages when the error basically is the same?

16:22 raek: ,(Object)

16:22 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Expecting var, but Object is mapped to class java.lang.Object>

16:22 raek: ,(Object.)

16:22 clojurebot: #<Object java.lang.Object@1740191>

16:23 srid: can this be simplified further? #(if (nil? %) 1 (inc %))

16:24 raek: ,((fnil inc 1) nil)

16:24 clojurebot: 2

16:25 srid: correct, except that should be 0 not 1

16:26 raek: yeah. fnil can be very useful with update-in

16:50 elio_: hihi

16:51 gtrak: hoy, anyone know why cascalog yells "could not build flow from assembly" when I try to run a query?

17:38 jlilly: Trying to setup lien + swank. Any hints on how to get it to start a repl after loading things? I have clojure-swank 1.4.0-SNAPSHOT, and clojure-mode 1.10.0.

17:41 the *swank* buffer seems to contain the source of SLIME. Not sure where to continue from here.

17:42 duck1123: M-x slime-connect

17:42 you might be missing a package

17:43 make sure you have slime-repl installed in emacs

18:07 amalloy: so brehaut, just to make sure my jealousy isn't misplaced: *** would be useful if i had a tuple/pair [x y], and i want to increment x and assoc some value into the map y?

18:07 brehaut: yes i think so

18:07 amalloy: eg something like ((*** inc #(assoc % :value 10)) [x y]))

18:07 neat

18:08 brehaut: yup

18:09 yeah totally

18:09 zackham: that a macro?

18:09 brehaut: amalloy: think conduit uses a similar function

18:09 zackham: cant find the definition of it so either not a fn or tough to find

18:10 bluezenix: anyone here using lamina ?

18:10 amalloy: zackham: it's a haskell function

18:10 brehaut: zackham: roughly (defn *** [& fs] (partial map deliver fs))

18:10 amalloy: ~anyone

18:10 clojurebot: Please do not ask if anyone uses, knows, is good with, can help you with <some program or library>. Instead, ask your real question and someone will answer if they can help.

18:10 brehaut: except not with deliver

18:11 zackham (defn *** [& fs] (partial map #(%1 %2) fs))

18:11 amalloy: brehaut: perhaps easier by example: ((*** dec inc) [1 2]) => [0 3]

18:11 brehaut: probably right actually

18:12 bluezenix: I'm trying to realize a sequence as a channel, this works but I'm guessing there's a better way: (task (doall (map #(do (Thread/sleep 1000) (println " Produce spread " %) (enqueue chan %)) (range 10)))

18:12 (close chan))

18:12 zackham: brehaut: gotcha thanks.. i played with haskell for a little while so its been fun trying to map some of the concepts over to clojure ( $ . partial application etc) haskell is just a little more terse =)

18:12 amalloy: though i wonder if it ought to be ((*** dec inc) 1 2), without explicit grouping, to fit with juxt

18:12 brehaut: amalloy: nope, it should have the explicit grouping

18:13 amalloy: brehaut: okay, why?

18:13 brehaut: so that the result of a juxt fn application can be the argument to *** application

18:14 amalloy: brehaut: but the result of *** can't be an argument to juxt; you'll need an apply

18:14 brehaut: ((*** inc dec) ((juxt inc dec) 1)) ; => [3 -1]

18:14 amalloy: or you could rewrite juxt as &&&, and then make them both explicitly grouped

18:16 brehaut: amalloy: haskell calls &&& 'fanout'; its so that you can have one argument split into two pipelines, and then you use *** to apply functions to each side of that pipeline in parallel

18:35 amalloy: ew. i seem to have written the following at some point: (let [[best curr] [(or best curr) (or curr best)]] ...)

18:35 brehaut: what on earth

18:36 amalloy: brehaut: i wanted to let you specify curr and/or best, and if you only give one then the other defaults to the same value

18:36 surely there's a nicer way to do it

18:42 brehaut: amalloy: you can do it without destructuring as (let [curr (or curr best) best (or best curr)] …)

18:43 amalloy: i guess. i don't really prefer that, though

18:43 brehaut: its still pretty horrible

18:55 bhenry: amalloy: what is the context of specifying best and/or curr? function args?

18:56 amalloy: bhenry: http://4clojure.com/leagues/golf/2?best=1&curr=9

18:57 then the params get parsed out, and passed on to an internal function, yes

18:59 bhenry: ahh. arity overloading wouldn't really work then.

18:59 brehaut: amalloy: (fn [& as] (map #(or %1 %2) as (reverse as))) ?

19:00 amalloy: thanks, brehaut. i knew you'd find a way to convince me my existing solution isn't actually that horrible

19:00 brehaut: :)

19:04 amalloy: i tried to work out a horrific monady thing, but nothing came to mind

19:04 cemerick: Raynes: ping?

19:04 Raynes: cemerick: Pong.

19:06 brehaut: joshnz: hi

19:08 joshnz: morning

19:10 I've got the day off, although I'm helping someone out all day, otherwise I typically wouldn't be here at this time on a monday. I'm not one of those lucky freelancer types :)

19:10 brehaut: haha

19:10 yeah, freelancing has its up sides :)

19:17 joshnz: what part of town do you work in?

19:17 joshnz: my day job is in ham east

19:17 brehaut: grey st sort of area?

19:37 miltondsilva: situationusing incanter: (time (dotimes [_ 1000] (doall (minus [1 2 3] [1 2 3])))) ~300ms replacing minus with map - and a doall... ~3ms... I thought incanter was a high perfomance lib? or am I missing something?

19:37 situation using*

19:42 amalloy: i assume it has to do other stuff like figure out the dimensions of your matrix

19:43 whereas (map - x y) has those assumptions baked in, so can be faster

19:44 miltondsilva: hmm... but then why provide minus pow etc? I thought the answer was in big matrix math... but no

19:44 performance is the same in those cases

20:28 megaloman: Hi. Two questions. How can I get the javadoc function in a leiningen project, and the same thing for the inspector namespace? I try clojure.java.javadoc but class not found, can't find a clojar, I don't know where this is.

20:39 amalloy: you should just be able to (require) it

21:34 technomancy: jlilly: find me some time the next few days and I'll get you sorted out

23:21 srid: amalloy: technically your solution to problem 60 is wrong https://gist.github.com/1225913 ... (reductions #(range 3) nil) returns ((0 1 2)) while your function returns (nil)

23:31 amalloy: meh. the behavior of reduce on zero-length lists is not something i've ever relied on

Logging service provided by n01se.net