#clojure logs

2011-09-18

00:37sridis there a reduce like primitive but for applying the function on the result only?
00:38sridbasically, to feed the result of a function to itself
00:39sriduntil it returns nil or something
00:43technomancysrid: iterate?
00:43sridoh nice
00:49sridso there is no 'iterations' (analogous to 'reductions' for 'reduce')
00:56tomojwhat would you expect it to do?
00:57pcavsDo people use etags for clojure source code in emacs or is there a better way?
00:58mrh0057__Use can use autocomplete
00:59mrh0057__https://github.com/m2ym/auto-complete
00:59pcavsmrh0057__: I want to be able to lookup definitions quickly and easily
00:59mrh0057__it will pull of the docs
01:00alandipertsrid: iterate returns a lazy-seq like reductions does, so in that sense they are similar
01:02mrh0057__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.
01:04mrh0057__pcavs: it C-c C-d C-d
01:04technomancyM-. jumps to definition
01:27zvrbacan somebody explain clojure's functions signatures? I find them extremely confusing
01:28zvrbafor example, documentation for cond gives ([ & clauses]) as arguments
01:28zvrbawhich makes me expect that it wants a vector of clauses, i.e., that (cond [x y, u z]) is the correct invocation
01:30tomoj&((fn [& clauses] clauses) 1 2 3)
01:30lazybot⇒ (1 2 3)
01:31zvrbatomoj: i don't get it.
01:31tomojthe extra () around the [& clauses] just wraps all the different signatures (cond has one)
01:31tomojdo you know what the & means?
01:32zvrbakinda, yeah. for introducing variable argument lists. but that's not what confuses me.
01:32zvrbahere's the signature for defn: ([name doc-string? attr-map? [params*] body] [name doc-string? attr-map? ([params*] body) + attr-map?])
01:33zvrbaso what is the list in the 2nd element of the vector
01:33zvrbanamely, ([params*] body)
01:33zvrbaahh
01:33tomojthat's a different (non-clojure) syntax for describing a signature
01:33zvrbai guess it's kinda regexp.
01:33tomojyeah, I guess the ones for defn are hand-written
01:34zvrba:/
01:34zvrba"great"
01:35tomojimpossible to describe defn's "signatures" in the standard syntax
01:35tomojno optional args, the + is funky, etc
01:35zvrbaok
01:41tomojnever really noticed that before
01:41tomojwould be unfortunate if you have a function with argument names ending in ?/*/+...
01:49zvrbaheh
02:20pcavsWhat's the proper way to take a variable number of function arguments and then apply each one to the same object?
02:23tomojjuxt
02:23tufflaxmaybe ##((comp - inc) 1) or ##((juxt - inc) 1)
02:23lazybot((comp - inc) 1) ⇒ -2
02:23lazybot((juxt - inc) 1) ⇒ [-1 2]
02:23tufflaxdepends on what you mean exactly
02:25pcavstufflax: 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
02:25tomojew
02:26pcavstomoj: yeah, I may be doing something not so hot right now
02:26tomojblame java
02:26pcavsTrying to hack in some transactions into the current clj-redis
02:26pcavswhich uses jedis, and that seems to be their transaction model
02:27tomojjuxt for side effects just seems weird
02:27pcavstomoj: yep...
02:33amalloypcavs: you might want doto
02:36pcavsamalloy: hmm maybeee
02:36pcavsI 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
02:42tomojwow
02:42tomojthat looks terrible
02:44tomojblazingly sane? doesn't look that way to me...
03:21amalloytomoj: i think i somehow managed to miss seeing the object of your derision
03:25tomojjedis
03:26tomojthis looks nice, an interface! https://github.com/xetorthio/jedis/blob/master/src/main/java/redis/clients/jedis/JedisCommands.java
03:26tomojbut https://github.com/xetorthio/jedis/blob/master/src/main/java/redis/clients/jedis/BinaryTransaction.java
03:26amalloyuhoh. a constant holder?
03:26amalloyno, an actual interface, i see
03:27tomojthen https://github.com/mmcgrana/clj-redis/blob/master/src/clj_redis/client.clj
03:27tomojlooks like a PITA
03:27pcavstomoj: it's not bad at all if you're not using transactions
03:28pcavsbut yeah, it's a bit troublesome
03:28tomojyeah, I was overly derisive
03:29tomojguess they wrote the regular stuff first and then added transactions on awkwardly
03:29amalloyheh. Queable, indeed
03:31pcavswhat'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?
03:33amalloywould you settle for "misguided, but nothing horrible about it"?
03:35amalloy(i don't actually understand your question, but the answer is probably ##(doc apply))
03:35lazybot⇒ "([f args* argseq]); Applies fn f to the argument list formed by prepending args to argseq."
03:35pcavsamalloy: ahh, that would probably be quite alright
03:36michaelr525hello
04:51neroothProblems with file upload and NullPointerExceptions - https://gist.github.com/1224883 - any ideas?
05:03thorwilnerooth: did you make sure (file :tempfile) is non-nil?
05:05nerooththorwil: nope
05:12nerooththorwil: 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
05:14shtutgartWhat's the difference between binding and with-redefs?
05:14thorwilnerooth: that comment makes no sense at all to me
05:15kumarshantanushtutgart: with-redefs changes the root binding (visible across all threads)
05:15thorwilnerooth: how about calling ds/copy on the repl, not with (file :tempfile) but with what is supposed to be a result of that?
05:15kumarshantanushtutgart: binding changes it just for the current thread
05:16nerooththorwil: it looks weird indeed, formatting got fudged in the comment, I added it at the top of the gist https://gist.github.com/1224883
05:17shtutgartkumarshantanu: ah, so it's for things like (with-redefs [foo bar] (future (foo)))?
05:17kumarshantanushtutgart: with-redefs might be useful mainly for unit-testing (mocking), because it restores the binding upon end
05:18nerooththorwil: that is a good idea indeed, but I don't know what the result is supposed to look like
05:22thorwilnerooth: 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
05:24shtutgartkumarshantanu: and behaviour of the binding remains the same? I heard there was talks about making threads inherit env
05:24nerooththorwil: 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?
05:25kumarshantanushtutgart: binding works the same, except that in Clojure 1.3 all vars are static unless they are declared dynamic
05:25shtutgartkumarshantanu: ok, thank you
05:26thorwilnerooth: none i'm aware of. i happens often enough that stacktraces make no sense to me
05:28shtutgartah, one more question: what does find-keyword supposed to do? "keyword exist" means that it's been used in the given ns, or what?
05:30nerooththorwil: 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.
05:31thorwilnerooth: (println file)
05:31thorwilnerooth: exactly where that is printed depends on your editor/environment
05:32nerooththorwil: that was simple enough, thanks :p
05:40otfromMorning. London Clojurians Incanter Hack Day checking in from beautiful Royal Festival Hall. :-D
05:40otfromWould Incanter chat and questions be better on #incanter?
06:27otfromI'm guessing everyone is busy at strangeloop today.
06:35tomojnot everyone :(
06:56otfromwell, you could always come to London and join us on our Incanter Hack Day. :-D
06:56otfromor just join in remotely
07:34shtutgarthm, so now it's preffered to name fns foo and foo' instead of foo and foo*?
07:42tomojcertainly not
07:42tomojwell.. "now"?
07:42tomojdid something happen I don't know about?
07:43tomoj&(let [foo' 3] foo)
07:43lazybot⇒ 3
07:43shtutgarttomoj: in 1.2 foo' just doesn't work, and there is +', -', inc', dec' in 1.3
07:44tomojah
07:44tomojhaven't moved yet
07:44tomojmaybe that's just cus +* and -* would look weird?
07:44shtutgartand it's meaning is nearly the same as in foo and foo* - same, but slightly different
07:44shtutgartyeah, and especially **
07:45tomojwere there ever any public ..* vars?
07:46tomojs/public//
07:46shtutgartbut there is no reason to have 2 different naming conventions for the same thing, imo
07:46shtutgarthm, let me think
07:46tomojI think I only ever used foo* inside the definition of foo
07:48tomojoh, there are internals like fn*, deftype* etc
07:49tomoj..which are really just for defining fn, deftype etc
07:51tomojnot sure what exactly the * in list* is supposed to mean
07:52tomojwith-bindings*, bound-fn*
07:52shtutgart(list* ...) is the same as (apply list ...)
07:53tomojso, same but different, or is the * suggestive of application?
07:54tomojinteresting that with-bindings* and bound-fn* both apply a fn arg
07:54tomojoh, but they're just functions for the macros
08:03shtutgartsorry, 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...
08:07shtutgartafter 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?
08:11cemericktomoj: foo* is generally taken to be an implementation detail of a public/supported foo function or macro
09:19Nocabit's incredibly easy to read (defn foo [seq s] ...
09:19Nocabas a function foo, which accepts one parameter s of type seq ;)
09:22otfromANN: London Clojure Dojo for September sign up page is up. https://ldncljdojo.eventwax.com/september-2011-london-clojure-dojo/
09:23otfromthough I think most of the currently online London Clojurians are sitting next to me hacking.
09:23michaelr525otfrom: what are you hacking?
09:24otfromwe're adding things to Incanter
09:24otfromthough 2 of us are building a little website for the next dojo
09:25michaelr525what things? and why you do it?
09:25otfromwhich will be a 20 questions kind of thing where you add to a knowledgebase.
09:25otfromI'm going to do something like the head command from unix (return 1st 10 lines)
09:25otfromother people are working on a summary function
09:26otfromothers are working on tests for the normal distrbution
09:27otfromwhy? well, why not get together and hack. :-D
09:27michaelr525why on incanter of all things?
09:27otfrom'cos stats are cool.
09:28michaelr525:)
09:29otfromwe'll be doing it every month at least until the end of the year. 3rd Sunday of the month.
10:52zvrbawhat's wrong with this code?
10:52zvrbahttp://pastebin.com/eyjfE1aK
10:52zvrbait says "wrong # of args passed to persistent vector (0)"
10:52zvrbawhen I call it with (adjoin-set 2 [1 3 4])
10:53zvrbawhen I try to execute the individual clauses manually, i get no error
10:54zvrbaor, adjoin-vset
10:56zvrbaok, found it. nevermind.
10:56zvrbais there a usable debugger for clojure?
10:59Bronsazvrba: ever tried swank-clojue?
10:59Bronsa*clojure
11:00zvrbayes, i'm using it
11:01zvrbaor, i'm using slime that's packaged with leiningen
11:01zvrbawhatever makes clojure-jack-in work
11:01zvrba(someone told me that swank-clojure isn't the backend for slime)
11:02zvrbaanyway, i get no useful info about the point at which the error occurred
11:02zvrbasomewhere on the stack sits my function and it says "no source"
11:02Bronsawell, if you use swank-clojure 1.4.0-SNAPSHOT, you will have CDT support
11:02zvrbacdt?
11:03Bronsaclojure debugging toolkit
11:03Bronsahttp://georgejahad.com/clojure/swank-cdt.html
11:03Bronsa^ see this
11:03zvrbasigh
11:03zvrbait should be forbidden by law to unleash languages unto the world w/o a complete toolchain. </rant>
11:04zvrbai got a message resembling this: java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to java.lang.Number (NO_SOURCE_FILE:0)
11:05zvrbai don't want to set manual catchpoints etc. i just want to get a clear indication of what went wrong. no manual labor.
11:05zvrbapossible or not?
11:06TimMczvrba: Got a stack trace?
11:08zvrbaTimMc: http://pastebin.com/sFRTC1HG
11:09zvrba(i have put the error back in the code)
11:09zvrbaTimMc: (there's much more on the stack, but I've pasted only the most relevant part)
11:12TimMcOoops, have to attend to stove.
11:13TimMcUsual tips: (.printStackTrace *e), macroexpand-1, and print statements
11:15zvrbaTimMc: but ptrintstacktrace from where?
11:24TimMczvrba: Are you in a REPL?
11:25TimMcIt'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:25TimMcI don't work from SLIME, so I don't know how to get line numbers, unfortunately.
11:26TimMc(I see you already have a stack trace, but it's not giving much info.)
11:26zvrbaTimMc: yes, i'm in repl
11:27zvrbathe error message is otherwise clear: it seems that it can't find the source for functions evaluated in a repl
11:28zvrbabut there is (should be) also loop on the stack as well as conj, which would make it easier to track down
11:28TimMcI think you'd have to post your code for anyone to help any more.
11:28zvrbasince the offending code is (loop ... (recur (conj .. (faulting-code))))
11:28TimMcOr maybe one of the SLIME users in here can give SLIME-specific debug tips.
11:29zvrbaTimMc: http://pastebin.com/eyjfE1aK
11:29TimMcI usually use the REPL for development of individual functions and use lein run to actually evaluate my code.
11:30zvrbaTimMc: anyway, the (rest (rest-of-vset)) -> at least the rest function should be on the stack
11:30zvrbabut it disappeared :
11:30zvrba:/
11:31TimMcis (rest-of-vset) correct?
11:31TimMcshould you be calling that as a function?
11:32TimMcYeah, that's it.
11:32zvrbaTimMc: no, it's not correct -- i've found the error.
11:32TimMcYou're trying to call a vector as a function of no arguments.
11:32zvrbaTimMc: but i've found it by guessing. it would have been much easier if I saw rest on the stack
11:32TimMcindeed
11:32zvrbaso, where did the call to "rest" disappear?
11:33TimMcWell, your code didn't have a chance to call rest.
11:33TimMcIt was trying to evaluate the arguments to rest, and that failed.
11:33zvrbaahh, i get it
11:34zvrbafunnily, i'm thinking lazily
11:34TimMcheh
11:34zvrbai thought that rest would force evaluation of (rest-of-vset) and therefore I expected rest on the stack
11:34zvrbait's funny because i've never programmed in a lazy language
11:35TimMcOnly if (rest-of-vset) were part of the generator of a lazy seq.
11:35zvrbawhich it wasn't
11:35zvrbabtw, when would one use lists in clojure?
11:35TimMcClojure isn't actually a lazy language, it just has some lazy features.
11:35zvrbavectors don't seem to have any downsides?
11:37zvrbabtw, (rest [1 2 3 4]) -> (2 3 4) .. why does it switch between vector and list?
11:38TimMcconj'ing onto a list takes constant time, I suppose
11:38TimMc,(type (rest [1 2 3 4]))
11:38clojurebotclojure.lang.PersistentVector$ChunkedSeq
11:38TimMcThat's a seq, not a list.
11:38TimMcLists and seqs behave *very* similarly, which is why they print the same way.
11:39TimMcrest calls seq on its argument
11:39TimMc,(rest "abcd")
11:39clojurebot(\b \c \d)
11:40zvrbaok
11:40TimMcseqs provide a consistent abstraction on top of the various collections (and are a collection type themselves)
11:41TimMcAnyway, I believe that lists are usually used when you only need sequential access.
11:41zvrbaoh. i though seq was just a unified interface. hence, my expectation that the type would be preserved
11:41zvrbaok
11:43TimMcWell, you can always call (vec (rest some-vector)) if you really need to.
11:44TimMcThere's not much point in that if you just need sequential access, of course.
11:44TimMc(Also, I bet vec is smart enough to peek under the covers and see that the seq is backed by a vector already...)
11:52Chousukevectors tend to be better for most use cases of regular lists in other lisps, but you still end up using seqs a lot.
12:41konrAny idea of what might be generating this (http://3d843a8c52457f13.paste.se/) cryptic error? My code is simple. http://3c0d402c0dc1bd28.paste.se/
12:43jkkramerkonr: passing nil to slurp on line 10?
12:43jkkramerer, line 12
12:44konrOh!
12:44konrOf course! Thank you jkkramer!
12:48jkkramerkonr: 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:49jkkramerkonr: clojure errors may seem cryptic at times, but they usually contain the info you need to troubleshoot
13:16rfgpfeifferIs 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:24coconautHello! Does IntelliJ IDEA supports ClojureScript projects?
13:26dnolencoconaut: I don't think any of the tools have good support for ClojureScript yet.
13:26devnSo, 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:26konrhttp://i.imgur.com/vQdQd.png Made with Clojure :)
13:26dnolenkonr: nice
13:27dnolendevn: you could extend that type to ISeq and (into [] ruby-array) should just work I think.
13:28rfgpfeifferdevn: I think RubyArray implements java.util.list
13:29devndnolen: rfgpfeiffer both good to know
13:29devnthanks.
13:29dnolenrfgpfeiffer: devn: if it implements java.util.List then (into [] ruby-array) will just work.
13:31rfgpfeifferdevn: sorry that was groovy not JRuby
13:31rfgpfeifferdevn: call to_java on it
13:32devnrfgpfeiffer: is that a RedBridge thing?
13:33devnrfgpfeiffer: undefined method for #<Haml::Engine:0x032490>
13:34devndnolen: It actually does just work I think...
13:35devn(take 2 (into [] (call-method (hamlize "%html") "methods")))
13:35devn;=>(#<RubySymbol html5?> #<RubySymbol options=>)
13:35NetpilgrimHi. 4clojure ops: The site is on the fritz again (502).
13:35devnNetpilgrim: #4clojure
13:36Netpilgrimdevn: Ah, didn't know about that channel.
13:36dnolendevn: if all you want to do is use sequence operations on it, no need for (into [] …) of course.
13:36devndnolen: *nod* -- really what I want I guess is to convert those RubySymbols to clojure keywords
13:37coconauthey guys, does anyone know if IntelliJ IDEA supports clojurescript? Thanks
13:37dnolencoconaut: no, not much good tool support for ClojureScript yet, a bit too early for that.
13:38coconautdnolen: thanks! I'll keep on using emacs then
13:40devndnolen: am I "doing it wrong"?
13:40devn(map #(keyword (call-method % "to_s")) (call-method (hamlize "%html") "methods"))
13:40devn;=>(:html5? :options= ...)
13:41dnolendevn: looks good to me.
13:41devndnolen: any thoughts on using meta to keep around the idea that they are #<RubySymbol>?
13:42devndnolen: I have no specific goal in mind at the moment, just experimenting with JRuby interop
13:43dnolendevn: well keywords can't take metadata
13:43devndnolen: yeah i was thinking about only doing it for homogenous sequences
13:46devndnolen: *shrug*, something to play with I guess -- my battery is dying -- sitting in the backseat on my way to strange loop
13:46devnhappy clojuring, all
13:46dnolendevn: cool cya in a bit then.
13:46coconautdevn: farewell!
13:46devnyou're going to be there, eh?
13:47dbushenkowhy the new swank does not open the repl? onlj clojure-jack-in makes it open
13:47devndnolen: going to the speaker's dinner?
13:47dnolendevn: yup
13:47devncool, pm'd you my #, ciao
13:48kzar4clojure's down, not sure if anyone noticed?
13:50sridi did. fire up a local server to solve problems meanwhile. :)
13:51Netpilgrimkzar: I've noticed and said so on #4clojure.
13:53kzarsrid: IIRC you only get problems up to 87 that way
13:53kzarsrid: cool idea though
13:54sridoh, hadn't noticed
13:55Netpilgrimsrid: Can you easily clone 4clojure from Github and run it locally?
13:55sridyes. see the README
13:55Netpilgrimsrid: Thanks. I'll have a look.
13:56sridif 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:59NetpilgrimHas anyone here solved the word chain problem (#82) in significantly fewer than 43 lines of code?
14:00kzarIs there a problem with having symbols like '.' in your project name?
14:00zvrbaNetpilgrim: which site_
14:00Netpilgrimzvrba: 4clojure
14:00zvrbaah
14:02NetpilgrimIt 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:02zvrba4clojure seems down, yes
14:02zvrbai just got bad gateway
14:03Netpilgrimzvrba: Me, too.
14:04zvrbai started going through sicp with CL, and switched to clojure just for the fun of it
14:05zvrbait became simple to write programs in cl on the sicp-level (i understood how do-iteration works, etc.)
14:06zvrbaand now, with clojure, it just feels like i'm fighting against the environment. unusable stack traces, unhelpful error messages, etc.
14:06zvrbaso. any tips? how to get a more pleasant experience using clojure?
14:08gfredericks4clojure is probably attending strangeloop
14:09Netpilgrimzvrba: 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:11zvrbaNetpilgrim: 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:12zvrbaNetpilgrim: clojure is sufficiently different from CL and scheme that you'd use a lot of energy to translate stuff from scheme to clojure.
14:13zvrbaNetpilgrim: 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:13Netpilgrimzvrba: I do have some experience with object oriented programming and should know enough about pointers (though I've never done anything in C).
14:13zvrbawhich is a shame, because i really do like how clojure, the language, is designed.
14:13zvrbafor example, collections can be used as functions to perform lookup.
14:15Netpilgrimzvrba: Is what SICP teaches interesting enough to make it worth the effort of translating it to Clojure?
14:15Netpilgrimzvrba: Under the assumption that I stay with Clojure for a while. :)
14:16zvrbaNetpilgrim: it is worthwhile to internalize what SICP teaches.
14:17zvrbai already knew a lot of that stuff, but i wanted a set of concrete exercises to solve with lisp.
14:17Netpilgrimzvrba: I'll look at it, when I'm through with The Joy of Clojure.
14:17dnolenNetpilgrim: I would just do SICP in Scheme/Racket. Clojure has existing / better answers for many of the things covered in SICP
14:18Netpilgrimdnolen: I'll keep that in mind.
14:19zvrbaNetpilgrim: 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:19zackhamzvrba: 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:19zvrbazackham: oh, thanks!
14:19dnolenzvrba: fair enough, but given the amount of production code out there using Clojure, I think a lot of people disagree.
14:20zvrbaand yes, I hate github. it has utterly f*up formatting of webpages. (nothing to do with clojure)
14:20zackhamzvrba: dont use it just git clone https://github.com/functional-koans/clojure-koans.git :P
14:20Netpilgrimzackham: I'm already doing the 4clojure exercises. I'm at problem 82 right now. I love that site.
14:20zvrbazackham: :)
14:20zvrbadnolen: i know that. fair enough.
14:21zackhamzvrba: environment feels pretty mature/functional in the typical emacs/slime/lein setup
14:21zvrbazackham: nope. stack traces are utterly unhelpful.
14:21zvrbazackham: earlier today I pasted an erroneous code example and stack-trace.
14:22zvrbazackham: i had to solve problem by staring and incremental searching in emacs.
14:22Netpilgrimzvrba: 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:23zvrbaNetpilgrim: http://pastebin.com/eyjfE1aK , http://pastebin.com/sFRTC1HG
14:23zvrbaNetpilgrim: tell me where the problem is
14:23zvrba(i've solved it, btw)
14:23zvrba++ for opera's history search :D
14:24zvrbaNetpilgrim: no locals (neither names nor values), no bigger context, nothing. it's "somewhere" in the adjoin-vset function
14:25Netpilgrimzvrba: For starters, NO_SOURC_FILE makes it a bit hard. I guess with a file you would get a correct line number.
14:25zvrbaNetpilgrim: i want to develop my functions and test them in REPL.
14:25dnolenzvrba: I spotted your error right away.
14:25dnolen(rest-of-vset)
14:27Netpilgrimzvrba: 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:27zvrbadnolen: ok :) i used approx 5 minutes to fix it. and 5 minutes is way too much.
14:27zackhamzvrba: i feel like in any language you deal with this.. some errors seem cryptic until you get used to them
14:27zvrbaNetpilgrim: right. and *exactly* at that stage, you need as much help from the environment as it can provide you with.
14:28zvrbazackham: c/c++ compiler would have provided me with rather accurate location in the file and the names involved in the offending expression.
14:28zvrbaCL compiler warns about wrong number arguments to a function invocation
14:28zvrbaclojure merrily does nothing.
14:29zackhamwell you arent invoking a function you are trying to invoke a persistentvector as a function =)
14:29zackhamtold you that pretty clearly
14:29dnolenzvrba: if you had compiled the file you would have been given a precise line number
14:30zvrbadnolen: http://pastebin.com/C2v1yNi8
14:30zvrbadnolen: no warning for definition of g. happy? :)
14:30Netpilgrimzvrba: 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:32zvrbaNetpilgrim: 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:32dnolenzvrba: advance warning would be nice, but the runtime error is pretty obvious.
14:33cemerickThat seems like real edge case to have a warning for.
14:33Netpilgrimzvrba: 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:33zackhamzvrba: might have something to do with supporting this too and the fact that its lazy, not sure: http://pastebin.com/NNBf38pM
14:35zvrbaNetpilgrim: do they get automatically loaded in REPL?
14:35upwardindexamalloy_: It would seem that 4clojure.org is down: 502 bad gateway
14:35upwardindexamalloy_: .com my bad
14:37shtutgartzvrba: but there is number lines in stacktraces... or do you want line when defining fn in the repl? is it even possible?
14:37Netpilgrimzvrba: 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:37zvrbashtutgart: no, it's not possible when defining in REPL. but I expect more sense in error messages. local variables, e.g.
14:40Netpilgrimzvrba: 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:41zvrba(defn entry2 [] (let [x []] (x))) -> compilation finished, no warnings. bleh.
14:41shtutgartzvrba: maybe cdt and c.c.trace will be helpful (haven't tried it myself)
14:44shtutgartzvrba: 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:45shtutgartand on the other hand haskell guys like the opposite, when "compiles" mean "works"
14:46zvrbai guess you're right. i'm in the latter group.
14:47Chousuke"compiles" doesn't mean "works" in haskell though. It just means you won't get errors at runtime for doing an illegal operation
14:47Chousukeit won't prevent you from doing something perfectly legal but stupid :P
14:47zvrbaI 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:48shtutgartChousuke: it won't, yet :)
14:48zvrbain the sense that they do not want #lisp to become a dwelling place for people who don't want to think for themselves.
14:50zvrbathe $10k question is: should I stick some more with clojure before discarding it?
14:51cemerickzvrba: You're probably inferring way too much from the particulars of what Clojure will and won't emit warnings for.
14:51shtutgartzvrba: 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:52Netpilgrimzvrba: 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:52technomancyzvrba: you must have done something to offend them if they sent you here from #lisp
14:53zackhamzvrba: 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:53zvrbatechnomancy: oh, no, that was my first question there :)
14:53zvrbatechnomancy: it was like /j #lisp, "hello, i want to learn a lisp dialect, what would you recommend" ... -> clojure
14:53zackhamzvrba: or go play with haskell that is fun =)
14:53cemerickThat might explain it. :-)
14:53shtutgartzvrba: but if you want to code some real programs in lisp dialect, you pick clojure :) imo
14:54technomancyzvrba: maybe you offended them by virtue of not being a guy who knows common lisp
14:54technomancy(it doesn't take much)
14:54neroothI've heard that Clojure aims to be platform-agnostic. What does that mean in practise for the coming year or three?
14:54zvrbatechnomancy: oh, no, they're very civil! :)
14:55technomancynerooth: depends on how you define platform
14:55zvrbazackham: go through sicp, get some practice with functional programming, personal projects.
14:55technomancynerooth: it is explicitly _not_ a goal to be portable across the JVM, JS, and the CLR
14:55zackhamzvrba: just use racket for sicp and you'll be doing exercises instead of translating exercises
14:55zvrbazackham: 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:56neroothtechnomancy: So what is meant when one says that clojure aims to be platform agnostic?
14:56zvrbaNetpilgrim: 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:57technomancynerooth: it means it runs anywhere the JDK runs
14:57technomancystay away from MIPS and you'll be fine
14:57neroothI see
14:57zvrbaNetpilgrim: but the more opaque the platform is, the better tool support you need.
14:57zvrbazackham: ah, i've gottten to the stage where I quite easily translate the code/write exercises to CL.
14:58zvrbabut i get the point, yeah.
14:59NetpilgrimHas 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:00technomancyNetpilgrim: I got that when I used a JRE instead of a JDK
15:00technomancybut I haven't used cdt in a while
15:00zvrbaNetpilgrim: 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:00dnolennerooth: or anywhere that JavaScript runs, which these days is everywhere.
15:01zvrbaNetpilgrim: so, tool support IS very important.
15:01zvrbafor me.
15:02ndimidukNetpilgrim: i get that all the time using sun's JDK on ubuntu
15:02Netpilgrimndimiduk: Yepp, that's my setup. Any idea what to do about it?
15:02Netpilgrimzvrba: I understand where you're coming from.
15:03ndimidukNetpilgrim: i installed tools.jar into my ~/.m2/repository and include it as a dev dep
15:03cemerickzvrba: 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:03Netpilgrimndimiduk: OK, I'll try that.
15:04Netpilgrimndimiduk: Where can I find the jar file?
15:04zvrbacemerick: i'm talking about the level of sbcl+slime, nothing fancy like racket or lispworks.
15:04ndimidukNetpilgrim: ${JAVA_HOME}/lib/tools.jar i think
15:04zvrbacemerick: but usable runtime and compile-time messages are *crucial*
15:05shtutgartis 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:05zvrbasbcl does not complain about missing file and is able to display local variables, for example, even for functions compiled from repl
15:05cemerickzvrba: I understand and agree. However, deciding upon a language because of its error messages is a…strange approach IMO.
15:05dnolenzvrba: the errors are usable … newbie friendly they are not … known issue and people want to fix it.
15:06Netpilgrimndimiduk: Thanks.
15:06technomancyone of these days I'll get around to integrating clj-stacktrace into swank
15:06zvrbacemerick: have you read what I've written to Netpilgrim . about scarce free time?
15:06zvrbacemerick: it might seem as a strange approach, but..
15:07zvrbathe goal is learning concepts from sicp. i'm more interested in fundamental knowledge than in particular language flavor.
15:07shtutgartRacket!
15:07dnolenzvrba: using Clojure for SICP doesn't make much sense to me
15:07zvrbadnolen: why?
15:08cemerickzvrba: 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:08dnolenzvrba: different language, seems like you're creating complexity
15:08zvrba(i think i can guess: completely different approach to mutable state, to start with)
15:08zvrbacemerick: ok, fair enough :)
15:09zvrbai want to learn that sicp-stuff so that I can think different about programming in C and C++. :)
15:09zvrbawhich is my pay-job.
15:09zvrbaso it seems instructive to implement, e.g., multiple dispatch from scratch.
15:10zvrbashtutgart: 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:10dnolenzvrba: you know about Geiser right?
15:11cemerickYou like good tools, but don't like racket? 0.o
15:12zvrbadnolen: i do. i think it only works under linux, though.
15:13dnolenzvrba: ? works on OS X just fine.
15:13zvrbawin7 !
15:13shtutgartzvrba: yeah there is geiser, quack for scheme
15:13shtutgartYou like good tools, but like win7? 0.o
15:13dnolenzvrba: not sure why it won't work on win7
15:14zvrbanative emacs, guile exists only as cygwin port, etc.
15:14dnolenGeiser doesn't need guile far as I know.
15:14dnolennot sure why it needs native emacs either
15:14shtutgartit supports both guile and racket, doesn't it?
15:15dnolenit does
15:15dnolenGeiser rocks
15:15zvrbashtutgart: win7 is a nice desktop!
15:15zvrbadnolen: hmm, ok, i'll take a look at it.
15:16zvrbashtutgart: 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:17zvrba+ sound playback from 2+ different programs simultaneously became possible just by the virtue of installing windows. :)
15:18zvrba(yes, I had a long, growing list of annoyances with linux before the copy-paste thing tipped me over the edge)
15:18Netpilgrimzvrba: Sound from different programs is no problem with pulse.
15:18robermannzvrba: did you check this: http://sicpinclojure.com/ ?
15:18shtutgartzvrba: I've heard there is so many problems with making emacs work under win
15:19shtutgartzvrba: 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:19zvrbashtutgart: IPC (pipes, etc) kinda sucks. the rest works fine. no problems though with sbcl+slime
15:19Netpilgrimshtutgart: I've actually installed a native emacs on a windows (2003 Server I think) and it worked out of the box.
15:20zvrbashtutgart: but all elisp packages work without a problem.
15:20robermannI'm using clojurebox under win7 without problems
15:21shtutgarthm, ok - haven't tried it myself, just heard people complaining about that...
15:21zvrbarobermann: yeah. but I have a paper-book
15:27Netpilgrimswank-cdt is cool! (http://georgejahad.com/clojure/swank-cdt.html)
15:28shtutgartso what's the right way to implement IFn with varargs support?
15:29shtutgart(if any)
15:32shtutgartI 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:33dnolenshtutgart: good excuse to learn about macros.
15:33shtutgartis there a macro for such purpose already?
15:35shtutgartdnolen: yep I don't mean implement by hand
15:38zvrbaanyway. /me off :-)
15:38zvrbathanks for your patience.
15:59Bronsauser=> (Object)
15:59Bronsajava.lang.Exception: Expecting var, but Object is mapped to class java.lang.Object (NO_SOURCE_FILE:0)
15:59Bronsauser=> (1)
15:59Bronsajava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn (NO_SOURCE_FILE:0)
15:59Bronsawhy do they print different error messages when the error basically is the same?
16:22raek,(Object)
16:22clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Expecting var, but Object is mapped to class java.lang.Object>
16:22raek,(Object.)
16:22clojurebot#<Object java.lang.Object@1740191>
16:23sridcan this be simplified further? #(if (nil? %) 1 (inc %))
16:24raek,((fnil inc 1) nil)
16:24clojurebot2
16:25sridcorrect, except that should be 0 not 1
16:26raekyeah. fnil can be very useful with update-in
16:50elio_hihi
16:51gtrakhoy, anyone know why cascalog yells "could not build flow from assembly" when I try to run a query?
17:38jlillyTrying 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:41jlillythe *swank* buffer seems to contain the source of SLIME. Not sure where to continue from here.
17:42duck1123M-x slime-connect
17:42duck1123you might be missing a package
17:43duck1123make sure you have slime-repl installed in emacs
18:07amalloyso 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:07brehautyes i think so
18:07amalloyeg something like ((*** inc #(assoc % :value 10)) [x y]))
18:07amalloyneat
18:08brehautyup
18:09brehautyeah totally
18:09zackhamthat a macro?
18:09brehautamalloy: think conduit uses a similar function
18:09zackhamcant find the definition of it so either not a fn or tough to find
18:10bluezenixanyone here using lamina ?
18:10amalloyzackham: it's a haskell function
18:10brehautzackham: roughly (defn *** [& fs] (partial map deliver fs))
18:10amalloy~anyone
18:10clojurebotPlease 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:10brehautexcept not with deliver
18:11brehautzackham (defn *** [& fs] (partial map #(%1 %2) fs))
18:11amalloybrehaut: perhaps easier by example: ((*** dec inc) [1 2]) => [0 3]
18:11brehautprobably right actually
18:12bluezenixI'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:12bluezenix (close chan))
18:12zackhambrehaut: 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:12amalloythough i wonder if it ought to be ((*** dec inc) 1 2), without explicit grouping, to fit with juxt
18:12brehautamalloy: nope, it should have the explicit grouping
18:13amalloybrehaut: okay, why?
18:13brehautso that the result of a juxt fn application can be the argument to *** application
18:14amalloybrehaut: but the result of *** can't be an argument to juxt; you'll need an apply
18:14brehaut((*** inc dec) ((juxt inc dec) 1)) ; => [3 -1]
18:14amalloyor you could rewrite juxt as &&&, and then make them both explicitly grouped
18:16brehautamalloy: 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:35amalloyew. i seem to have written the following at some point: (let [[best curr] [(or best curr) (or curr best)]] ...)
18:35brehautwhat on earth
18:36amalloybrehaut: 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:36amalloysurely there's a nicer way to do it
18:42brehautamalloy: you can do it without destructuring as (let [curr (or curr best) best (or best curr)] …)
18:43amalloyi guess. i don't really prefer that, though
18:43brehautits still pretty horrible
18:55bhenryamalloy: what is the context of specifying best and/or curr? function args?
18:56amalloybhenry: http://4clojure.com/leagues/golf/2?best=1&amp;curr=9
18:57amalloythen the params get parsed out, and passed on to an internal function, yes
18:59bhenryahh. arity overloading wouldn't really work then.
18:59brehautamalloy: (fn [& as] (map #(or %1 %2) as (reverse as))) ?
19:00amalloythanks, brehaut. i knew you'd find a way to convince me my existing solution isn't actually that horrible
19:00brehaut:)
19:04brehautamalloy: i tried to work out a horrific monady thing, but nothing came to mind
19:04cemerickRaynes: ping?
19:04Raynescemerick: Pong.
19:06brehautjoshnz: hi
19:08joshnzmorning
19:10joshnzI'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:10brehauthaha
19:10brehautyeah, freelancing has its up sides :)
19:17brehautjoshnz: what part of town do you work in?
19:17joshnzmy day job is in ham east
19:17brehautgrey st sort of area?
19:37miltondsilvasituationusing 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:37miltondsilvasituation using*
19:42amalloyi assume it has to do other stuff like figure out the dimensions of your matrix
19:43amalloywhereas (map - x y) has those assumptions baked in, so can be faster
19:44miltondsilvahmm... but then why provide minus pow etc? I thought the answer was in big matrix math... but no
19:44miltondsilvaperformance is the same in those cases
20:28megalomanHi. 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:39amalloyyou should just be able to (require) it
21:34technomancyjlilly: find me some time the next few days and I'll get you sorted out
23:21sridamalloy: 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:31amalloymeh. the behavior of reduce on zero-length lists is not something i've ever relied on