#clojure logs

2010-02-08

01:51ajazzhello, I have map {:a 2 :b 4}, how I can multiply each value on 3 to get {:a 6 :b 12}? I have solution but it's ugly.
01:51ajazzhttp://pastebin.com/d76128f06
02:09hoeckajazz: I don't think your solution is ugly
02:17hoeck ajazz: however, if you're interested, here are two other ways: http://pastebin.com/m3136c152
02:18hoeckajazz: and, by the way, predicate taking functions have usually the function as the first argument and the sequences, maps, whatever as the second argument in clojure
02:41LauJensenGood morning
03:05ajazzthank you
04:44nedhttp://pastie.org/814387 does anyone know why that would happen?
04:44nedit was working fine previously, the exact same code, and now it doesnt seem to work
04:49LauJensenAre you sure that you evaluated process-line ?
04:50LauJensenAnd if you're running this from the REPL, make sure you're actually in the tokenize namespace
04:52nedLauJensen, that was it. thank you sir.
04:52LauJensennp
04:56sparievLauJensen: hi. Could you shed some light on state of reworked ClojureQL API ? Is it ok to use it now or I'll be better off with stable version
04:58LauJensensec
05:00LauJensenspariev: I am currently reviewing and extending on Meikels work on the 2.0 Frontend - I hope to complete that process within a couple of weeks. Once thats done, it will be the preferred version to work with, but now its not adviseable
05:01sparievlaujensen: ok, thanks
05:03LauJensennp
05:23ordnungswidrighi, all
05:25LauJensenyo
05:26achew22Is there a good tutorial on getting started with clojure?
05:28vu3rdddoes completions work for java classes in slime? It doesn't seem to work for me.
05:29LauJensenachew22: setting up IDE or actually coding?
05:29achew22I'm interested in writing code
05:30LauJensenachew22: http://www.bestinclass.dk/index.php/blog/
05:30achew22I'm having difficulty writing a function that does more than just return a single value
05:30achew22that is, I would like to check 4 or 5 if statements
05:30LauJensenThats my blog, there are many easy to follow tutorial style articles, if you have questions shoot them off in here - myself or someone else will be able to answer
05:30achew22and I don't exactly understand how to "return" something from a function
05:30achew22quotes because I'm not sure that's the best way to think of it, I have seen some stuff about "yielding"
05:31LauJensenok
05:31LauJensenhttp://www.bestinclass.dk/index.php/2010/02/clojure-list-comprehension/
05:31LauJensenStart with that one, shows you how to build lists using the for loop, mimics yielding
05:32achew22LauJensen: I also really liked reading the article on the reddit clone when it hit HN a few weeks ago
05:32achew22maybe more recently than that
05:32LauJensenThen try this one: http://www.bestinclass.dk/index.php/2009/12/beating-the-arc-challenge-in-clojure/
05:32LauJensenAlso super simple
05:32LauJensenachew22: Great :)
05:32achew22keep it up, that article was why I started looking at clojure over CL or straight lisp
05:33LauJensenAnd finally this one, which shows a lot of diversity http://www.bestinclass.dk/index.php/2009/12/rosetta-serving-dish-4/
05:33LauJensenAh really? Great - I'm glad to hear it!! :)
05:34achew22also, keep submitting it to HN or else I won't read it ;)
05:34achew22that's equally important
05:35LauJensenI never do
05:35achew22hrm... then someone is doing you a favor. You might try submitting it yourself then you will be able to read the feedback from those guys
05:37LauJensenWhen I start getting a lot of traffic, I usually drop by to check out the comments
05:40achew22Would this make more sense if I had a lisp or java background?
05:46LauJensenThat I don't submit links to HN? :)
05:46achew22No, Clojure as a general idea
05:47LauJensenFor Java Interop, a Java background helps of course. Lisp takes a while to learn, but the main principles are extremely simple - So practice gets you far
05:47LauJensenThe functional mindset takes a while to acquire, but is supremely important - this is where the actual work is
05:47achew22Okay, well I've been looking for a while. How do you typecast something to a string?
05:47LauJensen#¨String s
05:47achew22really?
05:48somniumachew22: http://java.ociweb.com/mark/clojure/article.html << might be useful
05:48LauJensenThats not casting as much as adding a hint, which many times is what you want
05:48achew22but the documentation talks about hinting
05:48achew22and it only has stuff for basic types (int, float, bool) excluding strings
05:48LauJensen,(apply str [\a \b \c])
05:48clojurebot"abc"
05:48LauJensenachew22: what I showed you first was a hint
05:48LauJensenSecond was characters to string
05:48LauJensen(str \a)
05:49achew22Is that a double quote after the #?
05:49LauJensenNo
05:50achew22do you have a preferred codepad?
05:51LauJensencodepad?
05:52achew22pastebin
05:52LauJensen~paste
05:52clojurebotlisppaste8, url
05:52Chousukethe reader macro for type hinting is #^, not #¨ :P
05:52achew22Okay, is this absolutely insane http://codepad.org/8dfzxain ?
05:53LauJensenah, sorry I hit the wrong key
05:53ChousukeI think there's an odd? predicate already
05:53Chousuke,(doc odd?)
05:53clojurebot"([n]); Returns true if n is odd, throws an exception if n is not an integer"
05:53LauJensenachew22: Read up on cond and condp
05:53LauJensen,(condp = 5 even? "Its even" odd? "Its odd" :else "huh?")
05:53clojurebotjava.lang.IllegalArgumentException: No matching clause: 5
05:54ChousukeI really can't tell what those ands are doing there
05:54LauJensenChousuke: Its a homemade cond
05:54somniumwouldnt that be nested ifs?
05:54Chousukebut it returns true if all of those return true
05:55Chousukealso, (int x) is not for converting strings to integers
05:56Chousukeyou'll want Integer/parseInt
05:56avarushello
05:58achew22Okay, so you said that #^String hints something to a string
05:58TheBusbyArg, so "(use 'clojure.contrib.http.agent)" now throws a state exception "bytes already refers to: #'clojure.core/bytes in namespace: user" in 1.1.0
05:58achew22but it says that an Integer can't be cast to a clojure.lang.IFn
05:59TheBusbyworks fine in 1.0, but is bugged in 1.1.0 ?
06:00TheBusbycan anyone else replicate this please?
06:00tomojreplicated
06:00tomoj,(doc bytes)
06:00clojurebot"([xs]); Casts to bytes[]"
06:00tomojif you like you could hide that
06:00TheBusbytomoj: do tell
06:00TheBusbyahh, :only?
06:01tomojI haven't ever needed to do this yet, but I believe in your ns declaration use (:refer-clojure :exclude (bytes))
06:01tomojsomething like that
06:01somnium,(require '[clojure.contrib.http.agent :as http])
06:01clojurebotnil
06:01somniumhttp/bytes
06:02somniumor like that
06:02tomojthat's what I've been doing
06:02TheBusbyso then http.http-agent?
06:03tomoj/
06:03tomojor, like you say, you could :use :only to pick out what you need
06:03TheBusbyI guess my lazy-ness regarding including everything is catching up to me
06:03TheBusbystill that's kind of a nasty surprise
06:03tomojI kind of like that or :require :as better since it makes it easier to tell where a function is coming from
06:03opqdonutany indentation guidelines?
06:03tomojthough M-. is amazing
06:03TheBusbyah, good point
06:04tomojclojurebot: style?
06:04clojurebotstyle is http://paste.lisp.org/display/81021
06:04tomojhmm
06:04tomojclojurebot: style guidelines?
06:04clojurebotHuh?
06:04konrI need to write a program that generates a pdf file, but Clojure's startup time makes a stand-alone program dedicated to that unacceptably slow. What are the alternatives? I'm considering creating a server, containing this and possibly other utilities, to minimize the problem.
06:04TheBusbynailgun
06:04TheBusbyhttp://martiansoftware.com/nailgun/index.html
06:05tomojopqdonut: http://mumble.net/~campbell/scheme/style.txt
06:05TheBusbytomoj & somnium: thanks!
06:05konrTheBusby: hmm, the same used by vimclojure, it seems... thanks!
06:11avaruskonr: if the pdf is simple you could use lout
06:11avaruskonr: that would be fast only with simple documents :)
06:12avarusor embed jetty!
06:12avarusand wait for a request :)
06:13avarusyou could use compojure as a web framework...makes embedding probably easier
06:13AWizzArdyes, the pdf producing code could be a RESTful webservice.
06:14AWizzArdThen your shell tool can make a http request to your localhost or a google apps application which generates in Compojure the pdf.
06:16tomojfacebook developer wiki has been down for.. must be at least 48 hours now :(
06:30avarusguys...clojure-mode is fine :)...I did the step and learned some emacs basics
06:43raekI want to make a subclass of Exception, (how do|should) I do it in clojure?
06:54raekhmm, what happened to gen-and-load-class?
06:56hoeckraek: its gen-class now, preferably used within (ns :gen-class <gen-class-args>)
06:57hoeckraek: for instant interface implementation, deftype is the way to go (in the latest 1.2-master branch)
06:58raek"When not compiling, does
06:58raeknothing."
06:58raekis this true for :gen-class too?
07:00hoeckraek: yes, you have to compile in order to generate a working .class
07:01raekmaybe deftype will simplify this...
07:02ordnungswidrigdoes anybody know about a validation lib for clojure?
07:05hoeckraek: it greatly simplifies implementing interfaces, and creates a named type when its AOT compiled
07:14esjtomoj: http://groups.google.com/group/clojure-dev/browse_thread/thread/d090b5599909497c
07:26tomojesj: cool, thanks
07:26tomojavarus: great!
07:44avarusit's really awesome how clojure-mode works
07:44caljunior,(let [boing (atom nil)])
07:44clojurebotnil
07:44avarusthat's not comparable to gedit, textmate etc...
07:44tomoj"Use (:property foo) to access objects, but (foo :property) to reach into collections. The difference communicates what you think foo is."
07:44tomojcan someone say that in different terms?
07:45tomojI don't understand what it means by "access objects" vs "reach into collections"
07:45caljunior(let [boing (atom nil)] (swap! boing assoc 1))
07:45tomojavarus: :P told you you'd see the light
07:45caljunior,(let [boing (atom nil)] (swap! boing assoc 1))
07:45clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$assoc
07:46avarushehe
07:46tomojI didn't know you could assoc nil
07:46avaruscan clojurebot also do swing guis? :P
07:46caljuniorhow do I swap the value of the atom?
07:46Chousuketomoj: in the former case, foo represents something opaque, while in the latter case it's just a collection (and you're allowed to mess with its contents freely)
07:47caljuniortomoj: you can if nil is in a vector or a set.
07:47tomojhmm, how is it things become able to be passed as the arg to a keyword function?
07:48tomoj,(assoc nil :foo :bar)
07:48clojurebot{:foo :bar}
07:48tomojthat's what I meant
07:48Chousuketomoj: keywords are functions of associative things.
07:48Chousuke,(ifn? :foo)
07:48clojurebottrue
07:49tomojso besides collections, that would be.. datatypes?
07:49ChousukeI think the things need to implement IAssociative
07:49somniumwow, you can assoc onto nil, is that accidental (seq {}) or something?
07:50Chousukesomnium: I guess nil is just treated as an empty map.
07:50tomojI'm just trying to think of examples where you're doing (:property foo) and foo is not a collection
07:50AWizzArdsomnium: convenience functionaliy
07:50AWizzArd+t
07:50Chousuketomoj: the difference between an object and a collection is purely logical
07:51Chousuketomoj: you might have {:foo bar} represent an object so you would access it as (:foo ...)
07:51tomojoh, "what you think foo is", I see
07:52tomojon the other hand you might have a map of ids -> objects or the like, which would be (foo :an-id), then?
07:52tomojI think I understand now, thanks
07:56avarusmhmh...
07:56avarus"clojure.contrib.sql/with-connection dbc (clojure.contrib.sql/transaction" <-- is there a "way" to make that short? :P
07:56tomojcaljunior: you mean just reset it, ignoring what it was before?
07:57tomojswap! wants a function to call with the value of the atom as a first arg
07:57tomojin your example, assoc takes at least 3 args and you only have 2 (nil and 1)
07:57tomoj,(let [boing (atom nil)] (swap! boing assoc 1 2))
07:57clojurebot{1 2}
07:58tomojand,
07:58tomoj,(doc reset!)
07:58clojurebot"([atom newval]); Sets the value of atom to newval without regard for the current value. Returns newval."
07:59Chousukeavarus: (require '[clojure.contrib.sql :as sql])?
07:59caljuniortomoj: I just want to reset it.
07:59avarusChousuke: oh! thx :)
07:59avarushaven't thought about that :=)
08:00caljuniortomoj: I guess reset! would work.
08:04tomojif you just want to reset it, why are you guessing?
08:04tomojthat's exactly what reset! does, in the simplest way I can imagine
08:14caljuniortomoj: yes. I guess your right :-)
08:15caljunioryou're
08:34jeffmesswhats the correct way to install a clojure library? I ran mvn install which resulted in a clojure-http-client-1.0.0-SNAPSHOT.jar file, I placed the file in my classpath but in clj when I run (use 'clojure.http.client) I get a java.io.FileNotFoundException. However this is definitely in my classpath, i can use clojure.contrib lib fine.
08:35jeffmessclojure noob, so im not sure if i'm meant to run another build tool on the lib?
08:36chouserFileNotFound is not what I'd expect -- can you paste the entire stack trace somewhere?
08:36chouserlisppaste8: url?
08:36chouserhm.
08:36jeffmessjava.io.FileNotFoundException: Could not locate clojure/http/client__init.class or clojure/http/client.clj on classpath: (NO_SOURCE_FILE:0)
08:36chouseroh. I guess that is what I'd expect. :-/
08:38jeffmesshmm, the jar file is in my .clojure file in the same dir
08:38chouserthe .jar itself needs to be named on your classpath, not just the directory where the .jar is.
08:38tomojjeffmess: lein :)
08:39jeffmesshmm, okay
08:43avarusI love lein
08:43avaruslein jar, thank you, let's go on!
08:46a_strange_guyhi there
08:46avarushi a_strange_guy
08:46a_strange_guyI need some advice
08:47a_strange_guytrying to write a pattern matching macro
08:47a_strange_guylike http://www.brool.com/index.php/pattern-matching-in-clojure
08:47a_strange_guybut without the limitations
08:48a_strange_guymatching sequential things works already
08:49a_strange_guybut before releasing it, i want to add matching against asossotiative things
08:49a_strange_guyso that it works like the builtin destructuring in clojure
08:51a_strange_guyis there a fast way to check if a map(or map-like ting) contains ONLY some specified keys?
08:52chouserI guess I'd use 'count' to make sure the map doesn't have too many keys, then check each of the ones I want to be there -- if they all are, it matched.
08:53a_strange_guyhmm, does (associative? x) imply that you can (count x)?
08:53chouserThat should be O(n log32 n) worst-case, O(1) best case. I don't think you'll get any better than that.
08:54chouserHm... Probably not in the abstract, but vectors, hash-maps, and sorted-maps are all 'counted?'
08:55tomojthey will all respond to count, at least
08:55a_strange_guyand for deftypes?
08:55a_strange_guyno guarantees?
08:56a_strange_guymatching against types is a really nice usecase
08:57somniuma_strange_guy: deftypes could implement associative or sequential
08:59chouserall Associative have a .count method which (count x) will use, so at least it will work, though as I said in the abstract that could be O(n)
08:59tomojjust looked to see that assoc is special-cased on nil to give a new array-map
08:59chouserso if a deftype extends Associative it ought to implement 'count'
09:02a_strange_guybut only if it does implement Associative
09:03cow-orkerit seems (Klass.) is more popular than (new Klass), any particular reason for this?
09:05chousercow-orker: two reasons I've noticed. One is it feels more declarative. The other is it plays nicer with ->
09:05a_strange_guycow-orker: and it's shorter xD
09:05chouser,(-> "5" Integer.)
09:05clojurebot5
09:05Chousukesilly use of -> though :P
09:06a_strange_guythanks everybody, will post the pm-macro soon
09:07ChousukeI wonder if (Integer. "5") is actually preferable to (Integer/valueOf "5") nowadays
09:08fdaoudor even (Integer/parseInt "5")
09:09avarusmhh... contrib.sql makes 'nextval(''users_seq'') out of "nextval('users_seq')"
09:10cow-orkerok, thanks!
09:12chouserChousuke: well, sure it's silly with nothing else in the pipeline.
09:12chouserChousuke: replace with the appropriate combination of Reader and Stream ctors as needed to be compelling. :-)
09:13fdaoud,(apply str (map (comp char +) (map int "Want FP without the fuss") [-3 17 11 -84 35 38 31 74 -2 9 -15 -72 -6 -1 -77 83 -84 -7 18 69 13 -6 -6 -14]))
09:13clojurebot"Try Clojure it's awesome"
09:14chouserheh
09:15fdaoud:-)
09:30LauJensenNice :) chouser, make the t-shirt !
09:30chouserhmm...
09:30chouserthat's a lot of numbers for a t-shirt
09:31LauJensen(iterate fn -3) - work out what fn is then
09:31chouser"q ¾r}e,ns'Ç m¹nnf"
09:31chouserI guess that's worse.
09:33avarushow can I escape
09:33avarusoops :)
09:34chouseravarus: try the ductwork. Always works in the movies.
09:34avarushow can I escape nextval('users_seq') properly? :)
09:35avaruswhen I put it in " contrib.sql even tries to escape the '
09:35avarusso it looks wrong to pgsql (of course)
09:37fdaoud,(apply str (map (comp char +) (map int "Want FP without the fuss") [-3 17 11 -84 35 38 31 74 -2 9 -15 -72 -6 -1 -77 83 -84 -7 18 69 13 -6 -6 -14]))
09:37clojurebot"Try Clojure it's awesome"
09:37fdaoudoops sorry that was supposed to be something different
09:40chouser,(apply str (map (comp char +) (map int (.toUpperCase "Want FP without the fuss")) (map int "Qe_ wZS~R]E,NS' MfyaNNF") (repeat -84)))
09:40clojurebot"TRY CLOJURE IT'↓MZj-@OE"
09:40chouserheh. oops.
09:42fdaoudlol
09:45chouser,(apply str (map (comp char +) (map int (.toUpperCase "Want FP without the fuss")) (map int "Qe_ wZS~R]E,NS'\207 MfyaNNF") (repeat -84)))
09:45clojurebot"TRY CLOJURE IT'S AWESOME"
09:46chouserfdaoud: very slightly shorter, but not really better than your original.
09:47fdaoudchouser: guess it's just a matter of taste, whether you're a chars person or a numbers person :)
09:48avarusah fuck, I create a trigger poh
09:48avarusthe db has to set the id :P
09:49ordnungswidrighmm, what is an easy way to the values of a map to a map of the mapped values?
09:49ordnungswidrig(map-map inc { :a 1 :b 2 }) -> { :a 2 :b 3 }
09:49ordnungswidrigs/easy/idiomatic/
09:50AWizzArdzipmap
09:50AWizzArd,(let [x {:a 1, :b 2}] (zipmap (vals x) (keys x)))
09:50clojurebot{2 :b, 1 :a}
09:50chouser,(let [m {:a 1 :b 2}] (zipmap (keys m) (map inc (vals m))))
09:50clojurebot{:b 3, :a 2}
09:52fdaoud,(apply str (map (comp char #(- % 1)) (map int "Qmfbtf!epo(u!txfbs!;.*")))
09:52clojurebot"Please don't swear :-)"
09:52ordnungswidrigchouser: thx
09:55avarusyes, my pgsql trigge is a nice workaround :)
09:55avarus*happy
09:56avaruseven cleaner as there is now no specific pgsql code in the "app"
09:57ordnungswidrigand how would I merge to maps so that { :a 1 :b 2 } { :a "a" :c "c" } would give { :a [1 "a"] :b [2] :c ["c"] }?
09:58ordnungswidrigI tried merge-with but I failed on the combinator
09:58chouser,(->> "Clojure" (map int) (map + (map int "ivatefk") (repeat -107)) (map char) (apply str))
09:58clojurebot"Awesome"
09:58avarusfreak
09:58fdaoudlol
10:00ordnungswidrigchouser: you'd better switch to #haskell or even #pfhaskell :-)
10:01chouseryikes. In that case, I take it all back.
10:03esjchouser: your outburst brings me into mind of having too much coffee, so I shall go brew some now.
10:03chouser,(reduce (fn [m [k v]] (assoc m k (conj (m k []) v))) {} (concat {:a 1 :b 2} {:a "a" :c "c"}))
10:03clojurebot{:c ["c"], :b [2], :a [1 "a"]}
10:03chouserordnungswidrig: that might work -- not sure if it's best.
10:04fdaoud,(apply str (map (comp char +) (map int "Haskell") [-5 11 -4 -1 16 6 -7]))
10:04clojurebot"Clojure"
10:04ordnungswidrigchouser: hmm, I just notice I need are different result: {:a [1 "a"] :b [2 nil] :c [nil "c"]}
10:05AWizzArdchouser: charge 50 cents per LOC ;)
10:05ordnungswidrigchouser: I could your result with merge-with… But I need the nil.
10:05AWizzArdyou can explicitly insert it
10:05tomojdoesn't merge-with only call the function when there are duplicate keys?
10:06tomojwould be nice to be able to also supply a function to wrap an unduplicated value
10:06chouseryeah, I don't think merge-with would work for either set of results
10:06tomojer, value for an unduplicated key
10:07AWizzArdmaybe this is so specific that a hand-written reduce/loop is the best route
10:07tomojordnungswidrig: do you really need them in order?
10:07tomojthe vectors in the result, I mean
10:08chouserAWizzArd: take it back!
10:08chouserreduce should be sufficient.
10:09AWizzArdTaking back what?
10:09chouseryour advice to use loop/recur. :-)
10:10ordnungswidrig(reduce (fn [m [k v]] (assoc m k [(m k) v])) { :a 1 :b 2} { :a "a" :c "c"})
10:10ordnungswidrig,(reduce (fn [m [k v]] (assoc m k [(m k) v])) { :a 1 :b 2} { :a "a" :c "c"})
10:10clojurebot{:c [nil "c"], :a [1 "a"], :b 2}
10:10ordnungswidrighere we go
10:11ordnungswidrigIn my case I need only the key are in the first map :-)
10:11AWizzArdchouser: I would suggest reduce, as this can pretty much solve any looping requirements. Just sometimes a loop can be more readable and less clumsy. But for this case yeah, reduce is a good choice.
10:11ordnungswidrighowever always having a seq values whould be nice...
10:11chouserordnungswidrig: gah. quit changing your requirements!
10:11chouserordnungswidrig: so you're satisfied?
10:12ordnungswidrigchouser: this is agile dev .-) Not pair-programming but irc-channel-croud-programming.
10:13chouserordnungswidrig: in that case you should have started with a test, right?
10:14ordnungswidrigthe test was wrong. final spec: (f { :a 1 :b 2 } { :b "b" :c "c" }) -> { :a [1 nil] :b [2 "b"]}
10:17ordnungswidrig,((fn [m1 m2] (map (fn [k] [(m1 k) (m2 k)]) (keys m1))) { :a 1 :b 2} { :b "b" :c "c" })
10:17clojurebot([1 nil] [2 "b"])
10:20ordnungswidrig,((fn [m1 m2] (apply hash-map (map (fn [k] [k [(m1 k) (m2 k)]]) (keys m1)))) { :a 1 :b 2} { :b "b" :c "c" })
10:20clojurebot{[:a [1 nil]] [:b [2 "b"]]}
10:20ordnungswidrigah.
10:21AWizzArdchouser: btw, did you see that I orgininally suggested reduce/loop? Maybe you misread it as recur/loop
10:21ordnungswidrigis the usage of hash-map fine, here?
10:21AWizzArdordnungswidrig: yes
10:21chouserAWizzArd: ah, indeed I did. sorry.
10:23AWizzArdchouser: btw, I made progress with the transaction stuff today and can hopefully report success tomorrow.
10:24chousercool
10:35DeusExPikachutaking a poll, how many people directly depend on the function start-repl in swank.clj in swank-clojure?
10:38chousernot me
10:42DeusExPikachuordnungswidrig, do you just use lein swank by typing "lein swank" and don't ever call start-repl yourself?
10:42tomojI didn't know there was a start-repl function
10:42tomojI don't even see it
10:43ordnungswidrigordnungswidrig: right.
10:44ordnungswidrigstarting clojure as a inferior-lisp started failing for me about 3 month ago. But I am fine with slime-connect and did not mind anymore.
10:52DeusExPikachuordnungswidrig, do you ever run multiple clojure lisps and switch between them?
10:53ordnungswidrigDeusExPikachu: umm, nope.
10:53ordnungswidrigDeusExPikachu: only accidentl, I assume
10:54DeusExPikachuordnungswidrig, I think using the slime-connect method is actually more flexible then inferior-lisp, and I'm starting to think that its worth doing even on a local machine
11:01LaPingvinohello
11:01AWizzArdHallo LaPingvino
11:01LaPingvinoI am in the compojure-chat as well
11:01LaPingvinobut everybody there seems asleep
11:02LaPingvinocan I ask a compojure-specific question here?
11:02AWizzArdTry it :)
11:02LaPingvinoare there people out here who could help me?
11:02AWizzArdlikely
11:02LaPingvinowell, it's actually quite stupid... I think I am missing some essentials of Compojure
11:03AWizzArdThough, the Compojure newsgroup is also very helpful.
11:03LaPingvinowhat is the normal way to get to the request-information?
11:03LaPingvinoand use it in your software
11:03AWizzArdWhat do you mean by that? What is request-information?
11:03LaPingvinothe information that is send as a request to the server
11:03AWizzArdEach handler that you write is a function which must take a request object (a hash-map).
11:04TcepsaLaPingvino: Do you mean the Get or Post parameters?
11:04LaPingvinoah okay
11:04LaPingvinohow does that look?
11:04underdevsexp is natural, sexp is fun, sexp is best when its one on one
11:04AWizzArdThis is how handlers look: http://compojure.org/docs/handlers
11:05tomojcompojurecasts.com is available :)
11:05LaPingvinoah okay
11:05AWizzArdAnd the documentation here lists some things that may be available in a request: http://compojure.org/docs/requests
11:05LaPingvinoand with defroutes?
11:06tomojAWizzArd: what's the deal with returning a vector as a response?
11:06LaPingvinoI get GET and POST distinguished with defroutes, but it seems that gets somehow in the way of passing the request...
11:06LaPingvinoit confuses me a bit...
11:06tomojI use [200 response-body], but I saw something else that had three elements
11:07tomojLaPingvino: I do stuff like this:
11:07tomoj(GET "/locations" locations/get-handler)
11:07AWizzArdtomoj: http://compojure.org/docs/responses
11:07tomojwhere locations is some other namespace and get-handler a function there
11:07LaPingvinosure
11:07AWizzArdAllowed is: map, integer and string
11:07LaPingvinoand how to pass the request data to the handler?
11:07tomojyou don't
11:07AWizzArdthat can be in the result vector, tomoj
11:07AWizzArdLaPingvino: this will be done by Compojure for you
11:08tomoj(defn get-handler [request] ...)
11:08LaPingvinoah okay
11:08tomojthe line above sets it up to pass the request to the function
11:08AWizzArdLaPingvino: just write functions that you want to call from a client (for example a .html page in a browser).
11:08LaPingvino???
11:08somniumI always return a map as the response {:status ... :headers ...}
11:08tomojAWizzArd: map is for headers?
11:09underdevcompojurecasts.com doesn't seem to exist
11:09AWizzArdList them in (defroutes LaPingos-Routes (GET "/resource1" function) (POST "/resource2" function2) ...)
11:09tomojunderdev: yeah, it's available
11:09AWizzArdtomoj: exactly
11:09tomojI see
11:09tomojwonder how multiple values of each type are handled
11:09LaPingvinoright
11:09tomojgotta find where compojure does this in the source..
11:09underdevcompojurecasts.com => Oops! This link appears to be broken.
11:09AWizzArdtomoj: they get added if possible, last value wins
11:10LaPingvinoand the functions you list there get called with the handler as first parameter?
11:10tomojaww
11:10LaPingvinoriiiiiiiiiight :)
11:10tomojlast value wins is I guess the least confusing way
11:10LaPingvinothanks a lot :)
11:10AWizzArdLaPingvino: yes, just write the hello-world function as given in the example
11:10tomojI assume then that assoc-session returns a header map
11:10LaPingvinoI will have to rewrite a bit then
11:10AWizzArdyes
11:11AWizzArdyou can start with the examples, and then do a minor modification
11:11LaPingvinoI got a nullpointererror because I had the details wrong...
11:11LaPingvinothanks a lot!
11:11AWizzArdyes, that will go away
11:11AWizzArdnp
11:11AWizzArdAre you from the east of the NL?
11:11somniumtomoj: the sessions are what got me to always return a map
11:11LaPingvinoAWizzArd: I am from Ede
11:11LaPingvinoaround the middle
11:12AWizzArdk
11:12tomojer, session-assoc I meant
11:12LaPingvinowhy?
11:12clojurebothttp://clojure.org/rationale
11:12AWizzArdwest DE here
11:12LaPingvinoah cool :)
11:12LaPingvinowhich city?
11:12tomojI found this way to do it somewhere: [(session-assoc :foo bar) {:status 200}]
11:12tomojnow I'm actually confused why that works
11:12somniumI wrote a tiny middleware to bind sessions/flash to dynamic vars so they can be accessed and set! downstream (doesnt work with in memory sessions)
11:13tomojsince {:status 200} should be interpreted as a header map and overwrite session-assoc's value
11:13LaPingvinosomeone should complete a course or write a book about compojure, as clear as Stu's book
11:13LaPingvinothink I get it now :)
11:13LaPingvinowill have to experiment a bit still, but you have helped me a lot :)
11:14somniumhopefully the sessions api will be better once they add it to ring
11:14AWizzArdLaPingvino: at first Compojure seems overwhelming. But it is amazingly trivial and powerful. There are just some very few core concepts which you need to learn.
11:14LaPingvinoAWizzArd: I begin to see it :P
11:14tomojhmm, session-assoc returns something like {:session foo}
11:14LaPingvinoCompojure is a bit more complex than just plain clojure :P
11:14tomojoh, guess the with-session middleware is changing the way that's interpreted
11:14LaPingvinobut it is great really :)
11:16tomojoi
11:16tomojI'm going to wait till after the refactor to try to understand this stuff in detail
11:17LaPingvinotomoj: where are you from? brasil?
11:18LaPingvinoand which languages do you speak?
11:19hiredmanoy is yiddish
11:19tomojLaPingvino: US, texas
11:19tomojjust english
11:20tomojlatin really slowly :P
11:20somniumtomoj: the with-session middleware looks for a :session key in the response (but in-memory sessions are broken currently, no way to invalidate a session) and then updates accordingly
11:20tomojok, but my response is a vector
11:20somniumooh, spoken latin
11:20tomojthis is why I am confused
11:21tomojer, I didn't mean spoken :(. unless writing and then reading it out loud counts
11:21somniumI dont get the vector mini language, I think its supposed to be sugar, but I got nothing but problems trying to use it
11:21tomojI guess somebody else is turning the vector into a map before with-session sees it
11:21tomojbecause sessions are working fine :)
11:22AWizzArdsomnium: what problems?
11:22tomojwell, hadn't tried invalidation yet
11:22AWizzArdIf you want that your handler returns 401 just return this
11:22AWizzArdif you want it to return 401 with more text return [401 "No auth data given"]
11:23AWizzArdA handler may return an int, a string or a map
11:23DeusExPikachuwhat's the inverse of hash-map?
11:23somniumso default is {:status :body} ?
11:23AWizzArdIf it is an int, then this is the status code for the response
11:23tomojthe thing that's confusing me is I'm apparently returning [{:session ..} {:status ..}]
11:23tomojboth maps
11:23AWizzArdthe string ensembles the body of the response, while the map allows you to add extra headers.
11:24tomojand neither are headers :D
11:24hiredmanrhickey: I've been digging through the compiler and as a learning exercise added a "jop" special form which lets you use java operators directly, example (jop + (int 1) (int 1)) compiles to an iadd instead of a call through Numbers.add, the latest iteration does away with jop and uses #^{:primitive true} (+ (int 1) (int 2)), I am wondering if you would be interested in this?
11:24somniumI ended up moving most things into middleware and just using defroutes to call fns
11:24AWizzArdsomnium: good
11:24tomojyeah, I did that too
11:24AWizzArdsounds good
11:24tomojwith my namespaces corresponding to restful resources
11:26rhickeyhiredman: I'm interested in the facility in general, as when we move to cinc, we will need a more generic way to invoke primitive ops. I'm not sure 'jop' is it. On my todo is to run with the experiment I've proposed here to moveto Long as base type
11:26rhickeyhiredman: be aware though that HotSpot turns the static call into the opcode so there is no perf benefit to what you are doing
11:26hiredmansure
11:27hiredmanperf is not my thing generally :)
11:27rhickeyso, is the objective just to get a guaranteed primitive op?
11:27hiredmanyes
11:27rhickeybecause if it has to unbox and rebox, there isn't much benefit to the primitive op
11:28rhickeyesp rebox
11:28hiredmanif Numbers.java becomes a protocol it has to bottom out somewhere
11:28rhickeyNumber.java much be the primitive interface
11:28rhickeymight be
11:29rhickeysubject to inlining when there is no hotspot-like thing
11:29hiredmanreally? it would not be written in clojure?
11:30rhickeydunno. If it was you'd need different bodies for different platforms
11:30rhickeyactual opcodes can't be Clojure
11:31hiredmanopcodes being? the Ops stuff in Numbers?
11:31tomojanyone interested in thrift?
11:32tomojI have this vague idea that compiling thrift files to deftypes and protocols could be really awesome
11:33hiredmanit seems like you wouldn't need different bodies, you just add #^{:primitive true} to calls you want to be primitive and the compiler would take care of what and how
11:37rhickeyhiredman: begs the question as to what 'primitive true' means
11:37hiredmannot a fn?
11:43hiredmanif we are talking about clojure on many hosts it would be up to the compiler on each host to determine what it means, but if we just talk about Clojure, then primitive for + means iadd,fadd,dadd,etc
11:52mengu_hi. should i develop my web application with clojure? why? why not rails or why not erlang?
11:53Chousukebecause Clojure is fun!
11:54mengu_that's it?
11:54cp2well mengu_, if we told you, we would have to kill you
11:55nubawhat did you expect? the answers for all life's questions chewed up for you?
11:55rhickeyhiredman: then the semantics would change, potentially
11:55Chousukewell, I can't give you a bullet-list of features, because taken individually almost every other language is capable of the same things.
11:55pjacksonmengu_: It's very capable too.
11:55ChousukeDSL's, concurrency, the JVM, functional programming, etc...
11:55nubago to #[whatever] and expect to hear [whatever] is better
11:56Chousukebut it's how all those things work together that makes Clojure special.
11:56nubayou should read and play with it a little
11:56tomojone problem I have with clojure is that we don't have the kind of community that e.g. rails has, yet
11:56tomojso for example I couldn't just script/plugin install something to make my compojure app take image uploads and resize them
11:56ChousukeThough I suppose the STM value/identity concurrency approach is somewhat unique
11:57tomojyet, I'm still sticking with clojure
11:57hiredmanrhickey: but they aren't going to be the same at that low of a level across hosts anyway
11:57tomojI feel like making up for that problem is easier in clojure than it would be elsewhere, and in the long run I will be more sane with clojure :)
11:57mengu_Chousuke: what i am building will be a social network. so it will be all about concurrency. for example rails is fun too. and i am happy with it. but then will i be happy, hopefully, when it grows?
11:58mengu_i don't want to make a switch after the run. i just start with the best fitting one at the beginning.
11:58fdaoudmengu_: what is compelling to me personally is functional programming and Clojure's simple, consistent syntax. now, when I look at Java, Ruby, Groovy, Python code, the enormous amount of syntax jumps out at me.
11:58Chousukemengu_: I wish I knew the answer. There is not enough data to say anything for certain yet
11:59rhickeyhiredman: integer add etc certainly could be made so. But only if a decision was made to guarantee that
11:59Chousukemengu_: but I think if you're looking to build something scalable, Clojure is not a bad bet.
12:00tomojI'm more concerned with the health of my code
12:00tomojno tentacles of state squirming around through all different parts of the code
12:00mengu_fdaoud: i can accept that for java & groovy but not for py and rb. however from what i have seen, clojure has a different approach to programming at the beginning.
12:02mengu_fdaoud: http://clojure.org/rationale that one i'm talking about by the way :9
12:02mengu_*:)
12:03fdaoudmengu_: you mean you don't accept that I think that py and rb have too much syntax?
12:03mengu_compared to java and groovy
12:03cp2i wouldn't really say too much syntax, personally i think its more of 'undesirable syntax'
12:04tomojthey both certainly have far more syntax than clojure, though
12:04fdaoudmengu_: compared to clojure
12:04fdaoude.g. ruby: => , sometimes () around params sometimes not, |x| for blocks, do end or { }, the list goes on and on
12:05tomojwe have, what, [] {} and #* ?
12:05alexyktomoj: (def *tentacles* :of-state) :)
12:06Ober2ruby you have too many options?
12:06mengu_i have another question. for example people build their applications, for say, php or django or rails. and then they say they make their front-end application communicate with a functional language like clojure or erlang. how do they do that?
12:06Ober2*cough*SOAP*cough*
12:06ChousukeWhich language has more "semantics" though?
12:06tomojto me it's more like, the structure of a clojure program is pretty damn simple for a computer to understand, and pretty uniform all over
12:07tomojwhich makes editing much more pleasant
12:07ChousukeClojure has few syntax elements, but each macro in effect creates a new semantic construct. :/
12:07Ober2reminds me of initial reviews of lisp code going "where's all the variables and state information?"
12:07mengu_tomoj: that got me, for example. http://paste.pocoo.org/show/175201/
12:08ChousukeThough in Clojure similar code elements usually mean similar things so it's mitigated.
12:08tomojcompared to metaprogramming in ruby, I'll take macros
12:09somniumand theres no macroexpand in ruby, just pain :)
12:09ChousukeCL suffers somewhat from the lack of different elements :P
12:09Chousukeyou have to use lists for everything
12:09Chousukeso their meaning is overloaded by necessity.
12:10tomojI wonder if other lisps before clojure added [] and {}
12:10Chousukewell, in some schemes [] are interchangeable with (), but I don't think that counts .)
12:10tomojapparently elisp has [] vectors
12:11tomojthat doesn't really count either, it's elisp :P
12:12Chousuke:P
12:12ChousukeI got a new monitor today
12:13ChousukeI must say, a 24" widescreen LCD looks enormous compared to a 17" CRT
12:13tomojI alternate between 24" widescreen and 10" netbook
12:13Chousukestill connected via vga though. the package didn't include a DVI cable. :P
12:15Chousukebut since it apparently can handle a fullhd signal I'll bear with it for a moment.
12:19hiredmanrhickey: just to be clear, is what you are saying is you would like Clojure's, uh, numerical interface, to be higher level and more abstract?
12:29cp2Chousuke: 24" is pretty big
12:29cp2i use 20" widescreen lcds, and they are plenty big for me
12:29Chousukecp2: yes it is.
12:29Chousukeit's got about twice the screen space compared to my old 17" crt :P
12:29cp2haha yeah
12:30cp2i have some ancient dell crt around somewhere
12:30cp2cant stand using it =P
12:30cp2makes my head hurt
12:32cp2speaking of upgrades, i love my new keyboard
12:33cp2got one of those unicomp model m remakes
12:33cp2it kicks ass =P
12:33esjcool
12:34esji just 'upgraded' to standing desk - tired of back pains
12:34esjlooking forward to foot pain instead
12:34cp2haha
12:34cp2i should really get a better chair
12:34cp2i think my back has had enough of this one
12:35rhickeyhiredman: no, I'm just saying it's probably premature to define the interface to low-level arithmetic bytecodes
12:41noidiI'd like to write a pure function that adds objects to a collection, returning the new version of the collection. I'd also like the function to return handles to the values in the collection. ...
12:42noidiis this something that monads are good for, or should I write a macro?
12:42hiredmanhandles?
12:42noidiindices to be exact
12:43somniumnoidi: could you give an example of the desired return value?
12:43noidiin an OO language I'd write something like foo = coll.add(something()); bar = coll.add(something());
12:43noidibut doing this in a purely functional way requires me to thread the changed state of the collection through the calls
12:44hiredmannoidi: if you are conj'ing stuff to a vector the index is (dec (count ...))
12:45hiredman,(let [a [] b (conj a 1) onedex (dec (count b))] [b onedex])
12:45clojurebot[[1] 0]
12:46noidihmm.. I'll try to come up with an example
12:47hiredmanit sounds like you want multiple returns values, which you can't have
12:48hiredmanyou could use binding to fake it
12:48hiredman(def *return1*) (binding [*return1* nil] (set! *return1* idx))
12:50hiredman,(doc binding)
12:50clojurebot"([bindings & body]); binding => var-symbol init-expr Creates new bindings for the (already-existing) vars, with the supplied initial values, executes the exprs in an implicit do, then re-establishes the bindings that existed before. The new bindings are made in parallel (unlike let); all init-exprs are evaluated before the vars are bound to their new values."
12:50noidihttp://gist.github.com/298397
12:50hiredmanbah
12:51hiredmanI think the docs for binding on the website explicitly talking about using binding to communicate up the stack, but it is more commonly used for implicit args
12:51tomojwhy don't you just do (let [foo (object/new ..) bar (object/new ..)] ...) and then (conj scene foo bar) ?
12:52KnekkGood morning
12:53noiditomoj, I don't want the objects themselves, I want handles that I can use to refer to specific objects in the scene
12:54tomojoh, bizarre
12:54tomojdoesn't the scene know enough to project the {:foo foo :bar bar} at the end?
12:54hiredmanwhy would you want handles, if not to get the objects?
12:55tomojer, I don't know what word was supposed to go where "project" is
12:55tomojconstruct?
12:55noidiyeah, it's all a bit weird at the moment, I'm trying to adjust to pure functional programming so I'm probably doing everything the wrong way :)
12:56noidihiredman, to create a new version of the scene with one object in the scene replaced with an updated version
12:56hiredmanah
12:58noidiof course I could simply use refs for the objects, and update their values
12:58noidibut I'd like to try pure FP and see what the fuss is about :)
12:59hiredmanyou could return pairs
12:59hiredmanlike [[1] 0]
13:02noidiyeah, I thought about that
13:03noidibut I was hoping that this problem could be solved using monads, somehow, so that I'd have an excuse to learn them :)
13:05noidiI guess I'll read Konrad Hinsen's tutorials and look into clojure.contrib.monads
13:07somniumnoidi: you could use the state monad
13:09noidisomnium, great, thanks
13:09noidifrom the first hit on google, http://www.haskell.org/all_about_monads/html/statemonad.html, it appears to solve the exact problem I have
13:10noidior at least I think it does, that horrible Haskell syntax always makes my brain freeze and eyes glaze over
13:12fmuwith clojure-mode, is there an easy way to dump the result of C-c C-e (lisp-eval-last-sexp) into the file, either plain or as a comment?
13:15fmuhmm the mode documentation looks wrong
13:28tomojfmu: eval-print-last-sexp
13:28tomojoh, no
13:29tomojthat does elisp only, I guess
13:33fmutomoj: yeah, i tried that. i think this would be a useful thing to have, in particular when demonstrating code to others.
13:33tomojaha
13:33tomojslime-eval-print-last-sexp
13:34tomojthat dumps it into the source file on the next line though, which seems odd to me
13:34tomojI remember seeing something that copied a sexp into the repl and evaluated it
13:34tomojbut don't remember where
13:34tomojer, it's slime-eval-print-last-expression
13:35tomoj(not sexp)
13:35tomojneeds slime, of course
13:35fmuthe sexp variant is useful for stuff that is not toplevel
13:36fmuanyway, working perfectly now. must have put slime into some weird state previously.
13:39tomojslime-pprint-eval-last-expression sounds attractive, but doesn't work for me
13:43scottjThere used to be a function str* (not sure if it was in clojure, contrib, or compojure) that would behave like str but call name I think on arguments that were named. I can't find it, did it get removed, renamed, replaced?
13:45arohnerscottj: as-str?
13:45lypanovhas anyone around played with clojure/terracotta?
13:46scottjarohner: thanks, maybe it was renamed to that.
14:11underdevi laughed so hard
14:12underdevhttp://tcltk.nfshost.com/quantifiedconception.png
14:12underdevgrabbed it from the paredit presentation
14:14cemerickunderdev: then you see hardcore scheme impls in perl, like this, and the cycles just keep on going: http://billhails.net/Book/
14:15tomojunderdev: where's the paredit presentation?
14:15cp2cemerick: oh my....
14:16tomojmudphone's?
14:16noidiunderdev, here's the original http://xkcd.com/224/
14:17RaynesIoke is painfully slow, and apparently that's expected and intended. :|
14:17RaynesWhich is a real mood killer.
14:17underdevtx
14:17underdevnoidi, tx
14:17underdevhttp://www.slideshare.net/mudphone/paredit-preso
14:18cemerickRaynes: it's by no means intended to be a production language
14:18lypanovRaynes: same crap as the ruby guys gave for years.
14:18cemerickAFAIK
14:19noidiunderdev, and, as always on xkcd, keep your mouse on the strip to see the second punchline
14:19Raynescemerick: After a little discussion with Ola, his interests aren't totally academic. He just doesn't seem to care about performance over expressiveness.
14:19cemericklypanov: no need to start flaming
14:19cemerickRaynes: that's about the point at which he'd probably say "patches welcome" :-)
14:21RaynesIf he has a choice between speed, and more expressiveness, he'll take the latter. I doubt contributions would be very helpful for this particular language. I'm very interested in see where this goes over the next couple of years, if the project holds up.
14:21RaynesEven with poor performance, it's still pretty awesome.
14:21RaynesNeeds moar concurrency.
14:21underdevpre-mature optimization and all that...
14:21cemerickeveryone has different motivations *shrug*
14:21underdevand cowbell
14:27Chousuke:P
14:28underdevone things for sure, you have to be impressed with kyle oba's command of metasyntatic symbols
14:28hiredmanbound-fn closes over dynamic scope, right?
14:31Mecdoes a jar file have to be added specifically to the classpath to use, or just the folder?
14:32stuartsierraMec: named on the classpath
14:32stuartsierraMec: Sun Java 6 permits -cp "folder/*"
14:37Mecthanks
14:45avarusre
14:52Raynes"DateTime now notice split("T") second split(":")" holy chain of messages. :>
15:18LauJensenTo all you Americans, Best In Class is now the 98.460.th most visisted page in the US!! :)
15:22alexykLauJensen: that probably makes it #1 Belgian-made website in the Universe :)
15:23triyono its Danish I think :)
15:23alexykand transitively Danish as well then :)
15:23LauJensenIts fun how many people are so ignorant of Danish - On of the first comments I got on the site was "Too dutch for me" ... :)
15:24alexykBelgians got the Chimay and the Trappist preserves, which must be more popular anyways :)
15:24triyoWhen I worked for IBM I flew to Copenhagen a lot
15:24alexykLauJensen: I was at a conference in Copenhagen in 2007, so I should have known
15:26alexykwhat with all the crossed Øs...
15:27LauJensenwell... its not too late to appologize
15:27alexykLauJensen: I bow before the Danish people collectively and you individually!
15:28LauJensenAlright - You are hereby pardoned by the sovereign pingdom of Denmark
15:28blakkiis there a better/nicer way to do this? http://pastebin.com/d1202e470
15:28triyomember:LauJensenn: I also worked for a Danish shipping company Mærsk
15:28alexykLauJensen: furthermore, I promise to spell København in its original script from now on
15:29alexykpingdom is something network-related, or souped-up cars
15:29alexyksouped-up cdr's I meant
15:29cp2LauJensen: what is this moonspeak? ahhh!!
15:30alexyktriyo: so you're the one koading all those reailway containers passing by everywhere and stacked up high next to Amazon.com in Seattle?
15:30alexykmust be pretty string then
15:30alexykstrong
15:31chouserok, so that's one downside of manual CPS in clojure ... exception handling.
15:32chouserif you're supposed to return a value, throwing an exception is an easy and handy way to report an error
15:32triyoalexyk: hhehe, pretty much about 3 years ago. Also if you ever had a shipment delayed. You can prob thank me :) (Wouldn't be the first time we had a freight sent to a wrong location.)
15:33chouserif you're supposed to call a callback, you need a secondary mechanism to report the error -- some shared state that you set, some other callback to call instead, some return protocol instead of a simple value, something...
15:34alexyktriyo: somebody has to make the world interesting
15:34somniumchouser: the error monad to the rescue!?
15:35neotykcongrats Lau
15:35LauJensenthx :)
15:36chousersomnium: I guess I need to know more about monads... :-/
15:36rhickeyanyone got a Google wave invite they'd like to send my way?
15:36neotykhow do I do callbacks idiomatic?
15:36xp_prghi all, I am a mere mortal and I need help understand how to make clojure programs creating a dynamic language with macros etc...
15:36neotykrhickey: everyone
15:37triyoalexyk: perishables were the funniest. Client needs it in Cape Town, South Africa and it lands up in Reo, Brazil. No rolling back that transaction.
15:38arohnerrhickey: sure. What's your email?
15:38chouserrhickey: sent
15:38rhickeythanks
15:39rhickeyI noticed in the twitter stream someone was holding a clojure conference on g.wave
15:39Chousukeneotyk: callbacks? aren't those just functions? :/
15:40Chousukexp_prg: if you need help, ask a question first :)
15:40neotykChousuke: true, but have seen agents (c.c.http.agent) used for it
15:41neotykso am wandering how to write real async http client idiomatic way
15:41chouserrhickey: in french, apparenly?
15:41triyoyup french seems like it ... http://bit.ly/afD0ck
15:42triyoI think thats the one in paris
15:43hiredmanhttp://googlewavebots.info/wiki/index.php?title=Main_Page#Wave_Language_and_Translation_Bots
15:43hiredman:D
15:45underdevhmmm, anyone know how i can configure paredit-mode and show-paren-mode on by default
15:45underdev?
15:46lancepantzdid the sql libs get removed from clojure-contrib?
15:46hiredmanclojurebot: translate from fr Syntaxe imbitable et la mauvaise
15:46clojurebotSyntax WET and poor
15:46hiredman:(
15:46chouserheh
15:47hiredmanclojurebot: translate from fr Je trouve la communaute Scala beaucoup plus interessante
15:47clojurebotI found the community much more interesting Scala
15:47hiredman:O
15:47chouserperhaps we're helpful but boring?
15:47triyounderdev: I have this http://gist.github.com/298569
15:48Tcepsaunderdev: Not sure, but seems like there should be some way to do it in your .emacs file
15:48blakkiAA
15:48triyounderdev that autoloads paredit-mode
15:49underdevTcepsa: ty, that's what i'm trying to do
15:50triyounderdev: the autoload part in -> http://gist.github.com/298569
15:50underdevtriyo: ty! this is much like the code i found on the web, but much cleaner
15:50Tcepsaunderdev: Hehe, okay, wasn't sure how far along the path you'd gotten.
15:51fanaticois there a clearer way to write (reduce f (reduce f list-one) list-two)?
15:51underdevtriyo: it also makes it more clear how to add the show-paren-mode
15:51underdevTcepsa: tyvm
15:51LauJensenfanatico: Check out the latest post on http://clj-me.cgrand.net
15:52underdevTcepsa: where would i store paredit.el so that autoload would find it?
15:52underdevTcepsa: yeah, im editing my .emacs in vim :)
15:52underdevis that wrong?
15:53the-kennyunderdev: Yes
15:53chouserunderdev: it's how work gets done.
15:53Tcepsaunderdev: The easiest place would probably be in the site-lisp folder under emacs, unless you want other users to NOT be able to use it
15:53the-kennyunderdev: You need "alias vim=emacs"
15:53triyounderdev: do you have ELPA installed?
15:53Tcepsaunderdev: As long as it doesn't garbage the file for you ^_^
15:53cemerickunderdev: oh, that's funny :-)
15:53underdevTcepsa: yeah, thats where it is by default
15:54underdevit was suggested i move it to ~/.emacs.d
15:54underdev'preciate it
15:54triyounderdev: if so the paredit will be already on necessary path. Then just place snippet in my link above in your .emacs, using emcs edit and not vi :)
15:55Tcepsaunderdev: That would work as well, and ensure that only you would be able to use it (assuming you had multiple users using the same emacs installation; if you're on your own home box it's probably less of an issue)
15:55underdevokay
15:55underdevcool
15:55underdevthanks guys
15:55cemerickhas anyone knocked together a FSM wrapper for agents?
15:55Tcepsanp ^_^
15:55fanaticoLauJensen: I don't use list comprehension enough. Thanks.
15:56LauJensennp
15:58Tcepsaunderdev: I suspect that you'll also want to add a corresponding (add-hook 'clojure-mode-hook <etc.>) if you want to have it automatically activate for Clojure files. Is that right, triyo?
15:59triyoTcepsa: yup spot on
15:59chouserthat french wave seems to repeat some common misconceptions. :-/
16:00triyoTceps: in the example, I have it hooked into my lisp-mode for CL dev. You'd need the clojure mode one of coruse
16:00kotarakfrench wave?
16:00Tcepsatriyo: Great, thanks!
16:00chouserthough it's hard to tell for sure through the translation.
16:00chouser"The lists have a lot of ways, for example (first lst) returns the first element. The methods and rec conj can add an item to the end and beginning of the list, respectively."
16:00triyoTceps: np
16:00Tcepsatriyo: (I'm also trying to set it up for my own environment ^_^)
16:00chouserkotarak: http://bit.ly/afD0ck
16:02hiredmanman, I am used to using machine translation with, say, Korean, which is just terrible, the french apears to be very good
16:03kotarakchouser: I'm not sure I understand.
16:03kotarakchouser: you don't have to explain
16:03chouserkotarak: you don't understand what?
16:03underdevw00t!!!
16:03triyoTcepsa: cool, have you used paredit before? Its great but can be quirky at first. Once you get use to it, you want look back :)
16:04triyochouser: dont understand french :)
16:04kotarakchouser: "french", "wave" and "misconceptions" Is about the content of the wave at the link? Google wave in general? Some involved technology? But it's too late and I'm too tired. So I will count the as another mystery in the wide open of the plane of things I don't understand. :]
16:05chouserkotarak: oh, sorry. The Google Wave at that link is all in French, and as best I can tell from the machine translation to English, that content includes some innaccuracies about clojure.
16:06kotarakchouser: ah. Ok. I could try with my long rusty french, but I don't have access to the wave. (I think... at least it says "limited" and "get an invitation")
16:07triyoany current guestimate as to when Clojure 1.2 is seen to be released and will deftype and defprotocol make it into the release?
16:07triyothis question prob pops up a million times. (I haven't been around)
16:08chouserkotarak: ah, sorry. :-/ Google wave's are only readable by people with a wave account. It's a shame, though I believe they plan to open up read access eventually.
16:08Chousuketriyo: types and protocols will be in the next release, but I don't know of any estimates for a release date :/
16:08avarusgood night
16:10chouserhiredman: are you using a wave translation bot, or something external?
16:10the-kennychouser: They will, someday....
16:10hiredmangoogle has some bots on xmpp for translation
16:10dakronechouser/kotarak: Either of you need a wave invite?
16:10hiredmanI am using one
16:11hiredmanhttp://blogoscoped.com/archive/2007-12-19-n41.html
16:11chouserhiredman: ok. I saw someone added "Translatey" and wasn't sure how to use it.
16:11triyoChousuke: been messing about with that branch, loving the additions, so was wandering when it will be in and also if it will remain, to a large degree, in form it is in now.
16:11hiredmanno idea
16:11hiredmanhttp://markfayngersh.com/post/333326632/clojure-bot-is-a-google-wave-robot-that-evaluates <-- I just added this
16:11hiredman(not my work)
16:12dakronePM me an email address if you'd like a Google Wave invite
16:12chouseryeah, I saw that too.
16:12Chousuketriyo: I think there might still be new stuff coming :P
16:12chouserhiredman: it used to work for me, but hasn't recently.
16:12hiredman:(
16:12Chousuketriyo: but I'm not the best person to ask
16:12the-kennydakrone: Same for me. Just PM me if you want one.
16:12hiredmanclojurebot does xmpp, and so does appengine, so maybe I could just proxy clojurebot's xmpp over appengine
16:13dakroneI'm coming into the middle of the conversation here, are you talking about wave robots in clojure?
16:13hiredmantangentally
16:15hiredmana french wave was found that supposedly is about clojure, but seems to be heavy pro scala
16:15chouserI think something about the phrase "french wave" tends to be misleading without context. :-)
16:16kotarakcould it be a swiss wave?
16:19somniumchouser: http://gist.github.com/298581 << is this similar to the kind of boiler plate for CPS exceptions you mentioned?
16:22chousersomnium: sure, I think that falls into the "return protocol" category I mentioned.
16:23chouserI think.
16:24somniumchouser: so, the monad just invisibly chains the protocol together, but can also make all preceding state in the chain available
16:24somniumI found a great video by the microsoft guy who interviewed rich
16:25somniumhttp://channel9.msdn.com/shows/Going+Deep/Brian-Beckman-Dont-fear-the-Monads/
16:25chouserBut I don't think I can allow that invisibility. Some of my functions need to pass the callback along to other functions, or store it somewhere, etc.
16:25somniumhmm
16:25chouserthough perhaps I still don't understand.
16:26chouserI think I have a solution for now. because of 3rd party apis, the callback takes a single arg.
16:27triyotalking about monads, I saw this questions few days ago on reddit "What Does Monad Mean?" and somewhat answered -> "Only possessing a single testicle."
16:27chouser(fn f [input done-callback] (done-callback (inc input)))
16:27nDuffchouser, for folks buying a prerelease of The Joy of Clojure -- are deltas available when previously-released chapters are updated?
16:27triyo* somewhat=someone
16:28hiredman#(done-callback (inc input))
16:28chouseractually, it's worse
16:28kotarakmonads rock sometimes, monads suck some other times. I'm not sure which times get the bigger share...
16:29chouser(fn f [input controller done-callback] (if (valid? input) (done-callback (inc input)) (do (.setFailed controll "invalid input") (done-callback nil)))
16:29chouserbut because I can control the inner layers here, I can support this instead:
16:30chouser(fn f [input _ done-callback] (if (valid? input) (done-callback (inc input)) (done-callback :error "invalid")))
16:30chouserwhich is at least a little less noisy.
16:30Tcepsatriyo: Sorry, had to step away for a bit there. I'm new to paredit, but I've heard very good things about it.
16:31chouserand although it's entirely legal for f to return without calling done-callback (because it has stored it for later use), it seems unlikely for f to throw an exception and then later try to claim successful completion, so I can catch exceptions thrown by it as a kind of special-case error.
16:31triyoTcepsa: takes a bit of getting use to. I found it a bit tricky at first.
16:31Tcepsatriyo: The few things I've seen so far look neat (the autoclosing, for example; I used to hate it in Eclipse, but this implementation looks like it behaves in a way that makes more sense to me)
16:33ChousukeTcepsa: it doesn't really "autoclose"... it just maintains a consistent structure, which happens to require matching parentheses
16:33somniumwhen fns have metadata it might open up some more options. anyway, just a suggestion (trying to get some value from recent haskell reading)
16:34TcepsaChousuke: Ah, that makes sense.
16:38chousernDuff: I don't think we can provide anything useful like that with the version of the PDF that's up now. That content will be substantially reorganized in an upcoming release.
16:39chousernDuff: However, we may have something like that later -- Manning has a system (that we're not really using for this book yet) to allow per-paragraph comments and change history.
16:41qbgRandom question: why does let do sequential binding?
16:42chouserqbg: because it's no less efficient on the JVM, and people would just write macros to do sequential binding anyway.
16:43chouserqbg: is that a sufficient answer? :-)
16:43triyoI see wikipedia entry on Macros, says "It is possible to force a capturing macro expansion, but this must be done explicitly. ". Out of interest how is this possible in CLojure? In CL its implicit behavior.
16:44triyoClojure wikipedia page that is -macros section
16:44hiredmantriyo: you have to use the right combination of quote and syntax-unquote
16:44qbgchouser: guess so; someone else asked me that question
16:44hiredmantriyo: you have to unsyntax-quote ad quoted symbol
16:45hiredmanan
16:45hiredmana
16:45triyohiredman: Oh I see, makes sense.
16:45hiredmanso you have to really want to capture that name
16:45chouserqbg: I guess another answer would be to ask: what would be the benefit of simultaneous binding for 'let'? you can already do it with destructuring and function calls, so no much benefit to yet another way.
16:46qbgThat helps even more
16:46qbgthanks
16:47chousersure
16:48triyohiredman: yup, I know what you mean. I know, 99% cases, variable (name) capture is not desired hence Clojure does the opposite of the way CL handles it. Just was curious how to go about it if need ever comes up and that there is no limitation in actually doing it.
16:54zenoliblakki: Here's a possible approach - http://pastebin.com/m1609944f - won't return the remainder as a chunk, though.
16:56mabeswhat is the best way to apply a hashmap into a function defined by defnk? Right now I am having to do: (apply foo (flatten (vec m)))
16:57mabesthe above works but seems clunky
16:57Chousukemabes: (flatten m) should work just as well
16:57kotarak(apply foo (mapcat identity m)) should do without external deps.
16:58hiredmankotarak: well he is already using defnk
16:58kotarakand he wants to apply a map there, no?
16:58mabesyes.. trying just flatten now...
16:58hiredmanif he wants no deps he could use map destructuring directly
16:59hiredmanand he could just pass the map
16:59hiredmanno need to apply
16:59mabessimply passing the map does not work
16:59ordnungswidrigre
16:59hiredmanmabes: if you used map destructuring directly it would
16:59mabeshow would I use destructuring in this context?
17:00hiredman~destructuring
17:00clojurebotdestructuring is http://clojure.org/special_forms#let
17:00hiredman,((fn [{:keys [a b]}] [a b]) {:a 1 :b 2})
17:00clojurebot[1 2]
17:00abrenkchouser: we talked about epub's of manning's clojure books a couple days ago
17:01mabeshiredman: but that is when you create a function.. I am passing the map in this case.. I didn't think you could use destructuring outsite of def and let
17:01abrenkchouser: imagine my horror when after downloading a pdf from http://ebook.manning-sandbox.com today and checking the "manning blog" linked to on the left side of the page and it talked about replacing the PDFs with DRM protected ThoutReader format...
17:02hiredmanmabes: I am saying if you used map destructuring directly when creating the function instead of defnk
17:02abrenkchouser: ...turned out it were blog entries from 2004/2005! I guess I should write them about removing those links.
17:02mabesahh, I see. Yeah, I didn't write this function (using congomongo)
17:03somniumtheres a thread on clojure-dev about unrolling keyword args being preferred style now? (or suggested as preferred)
17:03hiredmansomnium: unfortunately
17:03hiredmanbut they'll pry it from my cold dead fingers
17:05somniumIve been wondering about having a defnk derivative create a foo and a foo* where foo* just destructures a map, for this case
17:05ordnungswidrigre
17:06hiredmanor just don't use defnk
17:06somniumso (fn foo* [opts a b & cs]) can still be overloaded on positional args
17:07somniumhiredman: too late in congomongo's case
17:07hiredmansomnium: someone could file a bug
17:08kotarakthe map argument for destructuring is not Rich's favoriute
17:08somniumthats like filing a bug with php for adding goto to the language :p (which has been done)
17:08hiredmanI know this function takes a map, you know this function takes map, but it has been contrived not to take a map
17:08hiredmansomnium: goto is good
17:09hiredmanit will make writing a scheme to php compiler easier
17:09somniumjust what Ive always wanted
17:09hiredmanhttp://github.com/hiredman/php.lisp
17:10hiredman:D
17:10hiredmannot scheme though
17:10somniumhttp://bugs.php.net/bug.php?id=48669
17:10hiredmansomnium: the "goto considered harmful" is repeated without thought these days
17:11somniumhiredman: come on, that was kind of funny
17:11hiredmanif λ is the ultimate goto, and we can't have λ's, at least let us have goto's
17:12somniumfor compilers its handy, but I wouldnt want to see it in application code
17:13hiredmanwhy not?
17:13somniumhmm, because it would it mean I was reading php
17:14hiredmanI just think it's crazy
17:14hiredmanI know I am passing a map, the function obviously takes a map
17:15hiredmanbut for some reason we want it to not take a map?
17:15technomancyactually, that's one thing Ruby's crazy syntax is really nice for
17:16technomancyif the last argument is something like :foo => "bar", :baz => 3 then it wraps it up in a map
17:16technomancybest of both worlds (except for the fact that you need those noisy arrows)
17:20somniumhiredman: part of its in the declaration too, if you take umpteen keyword args, you also have to specify umpteen default maps, and maybe an arglist too
17:21hiredmanif you are passing umpteen billion arguments it's take to rewrite
17:21somniummy only complaint is defnk prevents arity overloads
17:21hiredmanand I certainly would not want to use destructuring on umpteen args
17:22hiredmanI haven't look at the source for defnk, but I bet it uses destructuring as well
17:22hiredman~defnk
17:22clojurebotPardon?
17:22hiredman~def defnk
17:22somniumhiredman: it does)
17:23hiredman*sigh*
17:28somniumpythons *args, **kwargs is nice
17:31ordnungswidrigIs there api doc for contrib on clojure.org somewhere?
17:31the-kennyordnungswidrig: http://richhickey.github.com/clojure-contrib/
17:31ordnungswidrigthe-kenny: thanks, I didn't manage to navigate there from clojure.org...
17:32the-kennyordnungswidrig: I always forget how to go to this doc. I have a bookmark for it :)
17:32kotarakordnungswidrig: http://clojure.org/API links there
17:33ordnungswidrigkotarak: to bad that the sidebar link "API" links to http://richhickey.github.com/clojure/
17:33kotarakordnungswidrig: I get two links, one for clojure, one for contrib
17:35kotarakordnungswidrig: ah ok. nevermind. misunderstanding. sorr
17:35kotaraky
17:35ordnungswidrigno problem
17:46opqdonutsomnium: no no, common lisp's keyword arguments are nice
17:46opqdonuti'd like to see a bit richer defn macro in clojure
17:46neotykhow do I list methods of java object in clojure?
17:47hiredman,(doc show)
17:47clojurebot"clojure.contrib.repl-utils/show;[[x] [x selector]]; With one arg prints all static and instance members of x or (class x). Each member is listed with a number which can be given as 'selector' to return the member object -- the REPL will print more details for that member. The selector also may be a string or regex, in which case only members whose names match 'selector' as a case-insensitive regex will be printed. Finally
17:47neotykhiredman: thanks
17:48hiredman,(map #(.getName %) (.getMethods (class {})))
17:48clojurebot("seq" "withMeta" "withMeta" "withMeta" "assoc" "assoc" "valAt" "valAt" "entryAt" "without" "assocEx" "asTransient" "asTransient" "count" "iterator" "containsKey" "capacity" "empty" "empty" "create" "equiv" "invoke" "invoke" "get" "put" "hashCode" "clear" "equals" "toString" "isEmpty" "values" "size" "entrySet" "putAll" "cons" "remove" "keySet" "containsValue" "applyTo" "call" "applyToHelper" "throwArity" "invoke" "invoke"
17:51hiredman,(map #(.getName %) (.getDeclaredMethods (class {})))
17:51clojurebot("seq" "withMeta" "withMeta" "withMeta" "assoc" "assoc" "valAt" "valAt" "entryAt" "without" "assocEx" "asTransient" "asTransient" "createHT" "equalKey" "indexOf" "count" "iterator" "containsKey" "capacity" "empty" "empty" "create" "create")
17:59sethshas anyone else using swank-clojure noticed that *out* points to the *inferior-lisp* buffer while an agent is running?
17:59sethsdisconcerting when you're expecting to see stuff at the REPL
18:00hiredmanI don't think I've used an agent in slime/swank and I know about this
18:02neotykseths: I've noticed it as well
18:02hoeckseths: yes, *out* is only bound properly in the slime-repl thread
18:11wlrseths: invoking (slime-redirect-inferior-output) supposedly redirects all output to the repl. can't *personally* vouch for all situations, however.
18:20hoeckwlr: didn't know about this one, thanks
18:23wlrhoeck: neither did i until reading one of bill clementson's blog entries. (don't have the exact one handy right now.)
18:44hoeckgood Bill, his blogposts really helped me with my first slime setups some years ago
19:11lancepantzboo
19:12joshua-choiI'm trying to figure out how to call Clojure code from Java code, but with AOT-compiled Clojure. Is the only way to use clojure.lang.RT?
19:12rhickeyjoshua-choi: use RT.var to get the vars for any fns you want to call
19:13rhickeyyou don't need any more of the Java API than that
19:13rhickeyi.e. you can get the var for require etc
19:13joshua-choiThe thing I'm afraid of is compiling the code every time I call RT.loadResourceScript(someClojureFilename);.
19:14joshua-choiWell, I think that happens, from what I understand
19:14rhickeywouldn't require just work?
19:14joshua-choiIs require a method in RT?
19:14underdevrhickey: its really cool that you are answering questions on the irc channel. ty.
19:14joshua-choiI'm looking at a tutorial (I can't find the API of RT).
19:14joshua-choiYes, it is really cool.
19:15rhickeyjoshua-choi: no, use RT.var to get the var for require
19:15joshua-choiAh.
19:15underdevim very interested in this topic
19:15rhickeyyou can call any clojure fn that way
19:16joshua-choiSo, RT.var("clojure.core", "require").invoke(clojureClassFilename); instead of RT.loadResourceScript(clojureScriptFilename);.
19:17rhickeywell, require would take (at least) the ns as a symbol
19:18rhickeyjoshua-choi: but in general, if you know a clojure fn that does what you need, RT.var it then invoke
19:18joshua-choiDo you mean after loading a script or requiring a class?
19:18rhickeysome RT and other Java API things can make that easier, but you don't *need* them
19:19rhickeyjoshua-choi: what would you do in Clojure code?
19:19scottjWith congomongo, is there a way to fetch a record based on it's id as a string not an ObjectId object?
19:19joshua-choi(require name.of.namespace) as long as name/of/namespace.clj or .class is findable
19:21ninjuddif i have a long running loop with recur, will previous persistent copies of data structures be garbage collected, or does that only happen after the loop is finished?
19:22RaynesI think I want to code something in Io now.
19:22joshua-choi@rhickey: So: RT.var("clojure.core", "require").invoke(clojureClassNamespace);, as long as the Clojure class is in the classpaths?
19:22rhickeyVar symbolFn = RT.var("clojure.core", "symbol");
19:22rhickeyVar requireFn = RT.var("clojure.core", "require");
19:22rhickeyrequireFn.invoke(symbolFn.invoke("name.of.ns"));
19:22joshua-choiOkay. I see now; thank you very much.
19:23rhickeysure
19:31ninjuddif i have a long running loop with recur, will previous persistent copies of data structures be garbage collected, or does that only happen after the loop is finished?
19:32rhickeyninjudd: should be collected
19:32rhickeyif in the loop locals
19:33ninjuddok, specifically, i'm using clojure.lang.PersistentQueue
19:34ninjuddit seems like the loop is getting slower and slower, and i wanted to rule out clojure as the problem
19:34rhickeyninjudd: with pqueue your productions/consumption ratio will affect collection
19:35somniumscottj: no, not if its a mongo-generated id. (ObjectId. "id-string") is all thats needed. (the reason is that :_id can hold anything, mongo-ids are just the default)
19:36ninjuddrhickey: right, the queue should never get bigger than a couple of thousand entries, but i'll look into it more
19:40scottjsomnium: sweet, thanks
19:58xp_prganyone want to tutor me on clojure?
20:10TcepsaI'm attempting to do an implementation of Conway's Game of Life such that each cell is aware of (has a set containing) its neighbors.
20:10TcepsaThat way, to determine what state each cell should be in, it can quickly check its neighbors' states.
20:11TcepsaDo I need to use refs to refer to the neighboring cells so that when they change state (from alive to dead or vice versa) their neighbors can see that change instead of still looking at an unchanged version of the cell?
20:11chouserif you're going to go that route, yes.
20:12Tcepsachouser: Thanks
20:14TcepsaIn that case, do I need to do something special to ensure that all of the cells change state at the same time? I don't want to update a cell before its neighbor knows what its state used to be.
20:16sethsif I use (last (partition _ coll)) is that going to realize the whole collection? in linear time?
20:20sethserr, I guess the linear time is mentioned in the docs for (last), sorry
20:20sethsstill curious about realizing everything tho
20:21ulfsterTcepsa: you could do a two-phase update und synchronize that
20:21Tcepsaulfster: You mean, store the next-state on the first pass and then make a second pass that copies that into the current state?
20:22ulfsterexactly
20:22ulfsterthat will work
20:22Tcepsaulfster: Awesome, I was just setting up to try that. Thanks for the confirmation! ^_^
20:22ulfsteri am not sure if you can do it easier
20:23Tcepsa~nods~ I'm not thrilled about walking the list twice, but at least it's still linear time.
20:30scottjHow do you undefine a function? Say you've defined a fn and you move it to a new namespace, in order to use that namespace now you need to undefine the original (or restart clojure).
20:31xp_prgso nobody wants to tuor me?
20:31hiredman,(doc ns-unmap)
20:31clojurebot"([ns sym]); Removes the mappings for the symbol from the namespace."
20:31scottjthanks
20:33sethsxp_prg: some good offline resources are http://en.wikibooks.org/wiki/Clojure and http://clojure.org/getting_started
20:40Tcepsaxp_prg: Most of the people here seem happy to help out with specific questions when they can, but there are lots of good resources on the web for learning the basics and getting your feet wet.
21:11TcepsaIf I'm inside a transaction, and I attempt to get the value of a ref that has been changed within that transaction, will the value returned be the value before the change, after the change, or will it throw an error?
21:11Tcepsas/error/exception
21:12rhickeyTcepsa: you will see your own changes inside a transaction
21:14Tcepsarhickey: Okay, thanks ^_^
21:15chouser,(let [r (ref 0)] (dosync (alter r inc) (prn :now @r)))
21:15clojurebot:now 1
21:16Tcepsachouser: Ah, I see.
22:05TcepsaIs there a way to use destructuring when passing a ref to a function (and/or is there a reason why that would be a bad thing to do?)
22:07arohner_Tcepsa: no there is not a way. I suppose it's possible, but a bit weird
22:08Tcepsaarohner: Thanks
22:11drewrTcepsa: you mean to deref straight to a lexical?
22:14Tcepsadrewr: Say I have a reference to a map with :fname and :lname keys. Rather than using something like (let [fname (:fname @map-ref) lname (:lname @map-ref)] body) I'd prefer to just have those bound to the scope of the function when they're passed in.
22:14TcepsaI'm still unclear enough on exactly what "lexical" binding means to know whether that's what I just described ~wry grin~
22:15drewrin that case you could do (let [{:keys [fname lname]} @map-ref] ...)
22:16TcepsaAhh, thanks, that's better than nothing ^_^
22:16radswhat is the advantage of using the upcoming deftype over a hash map? performance?
22:21drewrthat, and abstraction
22:22drewrI'm not sure how much faster it is over map access though
22:23drewrI think the main performance pain point deftype addresses is multimethod dispatch
22:24radscoming from an OO background, I'm not sure when to create a new type and when to leave it as a hash map
22:25radsin the context of functional programming, that is
22:27drewrI'm still developing a mental model myself
22:27danlarkinI haven't had occasion to use deftype myself :-/
22:27danlarkinStill looking out for the use case though
22:27drewrI've found it helpful to think in terms of protocols
22:27drewrwhat kinds of things do I want to *do*
22:28drewrmap out the methods, then add types as they encapsulate components
22:31radsisn't the use of objects discouraged in clojure?
22:33drewryou have to go out of your way to create objects that contain mutable state
22:33drewrwell, not that far out of your way
22:37radsI can understand using deftype like a struct, since defstruct is deprecated, but why would you add methods to a type in clojure when you have namespaces?
22:38drewrthink of it as multimethods where the most common usage, dispatching on type, is given some perf and sugar
22:40radsis it mostly for the clojure-in-clojure stuff? it seems much more complicated than what is already there
22:43drewryes, that was the primary catalyst
23:17DeusExPikachuI'm reading the definition for -main in core.clj in leiningen and I'm unsure why -main's argument list is as it is. What is the difference between [& [task & args]] and [task & args]?
23:18chouser[task & args] will throw an exception if you pass fewer than 1 arg
23:18DeusExPikachuah, ok
23:18chouser[& [task & args]] will bind both task and args to nil and not throw any error if no args are passed in.
23:27TheBusbyanyone using "Electric Ret" with Paredit (for emacs)
23:27TheBusbygreat screen demo of it here, http://img8.imageshack.us/img8/9479/openparen.gif
23:30boydAll it seems to do is put the closing parens in the wrong place
23:30TheBusbyer, well yes, on the following line
23:31boyd... which is great for, say, C
23:31TheBusbydefinitely a preference then
23:32boydSure. But closing parens on a seperate line is quite un-idiomatic in lisps
23:33_msthitting the close paren moves the paren back off its own line, I think
23:33TheBusbynotice at the end of the demo though
23:33TheBusbyyou just hit ) repeatedly to clean it up and make it look like normal lisp
23:33boydYes, but then why put them down there in the first place
23:33boyd?
23:34TheBusbymake it a little more clear while you're typing
23:34TheBusbyI find it useful...
23:35boydI can see the appeal. I think I am in the habit of watching the highlighted open parens when I close, so they seem a bit superfluous.
23:36TheBusbyI'd like to integrate "Electric Ret" w/ paredit, but am unsure how to do so though
23:41TheBusbyadded the code snippet to ~/.emacs.d/$(USER).el but no luck
23:44wlrTheBusby: Are you experienced with paredit? Seems to me, if you were, you'd declare Electric Ret functionality superfluous.
23:45TheBusbywlr: I've used it quite a bit, but I'm still far from having mastered it
23:46TheBusbyis there some paredit feature that makes electric ret superfluous
23:47TheBusbyI use ")" quite a bit to pull close-round to end of line, but find having the "mountain of parens" easier to navigate when adding code in a hierarchy
23:49wlrTheBusby: just a gut feeling. the focus in paredit is on editing the structure/form of the program and only incidentally on the textual aspects.
23:51wlri'm close to the point where old lispers say "What parentheses?" when newbies complain about Lotsa Irrelevant Stupid Parens.
23:52TheBusbywlr: I don't mind the parens, beginning to love them with paredit in fact, but you need to pay attention of them to determine which part of the code hierarchy you're in though
23:54TheBusbyby the sound of it I just need more practice with paredit as is ;)
23:54TheBusbywlr & boyd: thanks for the help!
23:55JonSmithhi
23:56JonSmithis there a way to do array access in scriptjure?
23:58arohnerJonSmith: you mean javascript array access?
23:59JonSmithyup
23:59arohneroff the top of my head, I think you can use the function call syntax for arrays