#clojure logs

2010-06-11

00:24dnolenanyone have example of type-hinting deftype methods?
00:31mmarczyk(deftype Foo [x] Object (^boolean equals [self ^Object other] true))
00:31mmarczyk(.equals (Foo. 5) true) => true
00:32technomancywho wants a generic hook function extension system?
00:32technomancyanybody? http://p.hagelb.org/hooke-readme.html
00:34mmarczykI definitely want a hook extension system named after Robert Hooke
00:35dnolenmarczyk: hm, I keep running into issues where it doesn't it complains about the method if I've defined a protocol
00:35technomancysold! to the guy with the orange nick (in my client) http://p.hagelb.org/hooke.clj.html
00:36mmarczykno idea what colour nick I've got in your client, but thanks :-)
00:37mmarczykI think I'll have a use for that in a little while too, so that's pretty cool :-)
00:37technomancyoh?
00:37cemerickmmarczyk: sent in your CA yet? :-)
00:38mmarczykcemerick: heh, thanks for asking :-)
00:39mmarczykcemerick: will do today, it's printed and just waiting for me to go to the post office
00:39cemerickmmarczyk: good, I'll only have to pester you once more ;-)
00:39mmarczykcemerick: right :-)))
00:39mmarczykincidentally, any thoughts on whether I should include non-ascii chars or skipt them?
00:39ravaanyone know of a decent looking gui kit i can use for clojure?
00:40mmarczykI've decided to skip, but if it's a problem, could make another version...
00:40ravaswing is so very difficult to make look decent
00:40cemerickrava: SWT is really the only other option
00:40cemerickmmarczyk: non-ascii for what?
00:40mmarczyktechnomancy: if you're asking what sort of use for R. Hooke I had in mind, I'm not very clear on how the thing I can see using it work will work yet, so hard to summarise
00:41mmarczyktechnomancy: I'll be sure to let you know when/if I do use it though :-)
00:41mmarczykcemerick: there's one non-ascii letter in my first name and a couple in the mailing address
00:41mmarczykthe address is not a problem, it's perfectly normal to skip those
00:41cemerickmmarczyk: oh, leave them in, make it proper
00:41tomojso the metadata on the function has a ::hooks key which holds a list of hook fns?
00:41cemericklegal document, after all
00:42mmarczykright, though on the other hand, I've produced a number of legal documents in pure-ascii form
00:42mmarczykI believe my bank cards are pure-ascii too, Google wanted pure ascii for GSoC...
00:42mmarczykwouldn't want to make processing overly complex (and therefore I'm making it overly complex for me right now :-P)
00:43technomancytomoj: yeah
00:43technomancylimits it to 1.2+ unfortunately
00:43cemerickRich is doing the only processing, so *shrug*
00:43technomancybut hey, it's only 23 lines.
00:43mmarczykyeah, I guess I can always send another one if it matters somehow
00:44tomojhmm.. the bicycle and the tricycle. I approve.
00:44ravasaw these in a best in class blog: http://code.google.com/p/macwidgets/
00:45dnolenhmm so the the type hints have to be on the protocol?
00:45cemerickrava: those are swing AFAIK :-)
00:46cemerickplus some OS X-specific client properties
00:46ravacemerick: yes, but the prettyness work done for me :D
00:46cemerickright
00:46cemerickwell, I was assuming you were aiming for cross-platform :-)
00:46technomancywould renaming add-hook to add-hooke be too cute?
00:47cemerickheh
00:47technomancyprobably
00:47cemericktechnomancy: reminds me of wall-hack-*
00:47ravacemerick: those do render across platforms
00:47cemerickrava: oh, sure, but....stick out like a sore thumb elsewhere, no?
00:48cemerickI mean iTunes on Windows is there, but sorta awful.
00:48ravacemerick: meh, i don't care about looking like a native app
00:48cemerickfair 'nuff then
00:49ravawindows native = fugly anyway
00:56ysphdid lazy-xml/emit and emit-element move into clojure.xml in 1.2?
01:01tomojclojure.xml has emit and emit-element in 1.2, at least
01:08ysphit has before, but there were some issues that weren't present in lazy-xml/emit and emit-element, so i wonder if they were consolidated
01:09tomojlooks like not
01:09tomojlast changes to emit and emit-element in clojure.xml were in 2008
01:10technomancythe function that's like remove but takes an element instead of a pred is in contrib rather than core, right?
01:12mmarczykin case anybody wants to play with a Turing machine, http://github.com/michalmarczyk/turing-machines
01:56technomancyhttp://github.com/technomancy/robert-hooke
02:03Lajla$(apply append (map #(append %1 " ") (list "I" "worship" "his" "shadow"))
02:03sexpbotjava.lang.Exception: EOF while reading
02:04Lajla$(apply append (map #(append %1 " ") (list "I" "worship" "his" "shadow")))
02:04sexpbotjava.lang.Exception: Unable to resolve symbol: append in this context
02:13jrpIm looking around at getting started with clojure and os x. Is there a prefered way to get it working with vim? Ive found a few vim scripts, and Im wondering what people prefer.
02:16imran_srjrp: I use syntax highlighting, indenting and rainbow parens from vimclojure (but not the nailgun repl), and I use my own vimscript to send whatever I like to a repl (current line, current expression, function, entire buffer, (doc <this word), whatever). And I keep vim and the repl side by side in a vert split gnu screen
02:16imran_srwhew, thats it :)
02:17tomojLajla: maybe you're looking for clojure.contrib.str-utils/str-join ?
02:17jrphm, ok. ill give that a shot. I tried slimv but it was a bit problematic
02:17Lajla$(apply join (map #(join %1 " ") (list "I" "worship" "his" "shadow")))
02:17sexpbotjava.lang.Exception: Unable to resolve symbol: join in this context
02:17LajlaI give up
02:17Lajlatomoj, you do it
02:17LajlaOutperform me
02:17LajlaBe the third best programmer after me and Bill.
02:18tomojsomebody already did it
02:18tomojand it's in contrib :)
02:19hoeck,(apply str (interpose " " ["I" "worship" "his" "shadow"]))
02:19clojurebot"I worship his shadow"
02:19imran_srjrp: I found the idea (for vimscript to repl communication) here : http://technotales.wordpress.com/2007/10/03/like-slime-for-vim/
02:19imran_srjrp: there you'll find a simple slime.vim
02:20imran_srjrp: I rewrote my own version, for additional functionality (plus it now works with latest gnu-screen from git)
02:20imran_srjrp: but if you don't use gnu-screen, it won't really help you :(
02:25Lajlatomoj, you worship my shadow eh?
02:25Lajlatomoj, also, your function does a different thing
02:25LajlaMine ends on a space, yours doesn't.
02:26jrpimran_sr: I do use a bit of screen, perhaps I should use more
02:26tomojLajla: my function?
02:26imran_srjrp: best thing since sliced bread :)
02:26Lajlaerhh, hoecks.
02:26LajlaI misread.
02:26Lajlatomoj, will you ever be able to forgive me for my errings?
02:27tomojlike this, then?
02:27tomoj,(#(apply str (interleave %2 (repeat %1))) " " ["I" "worship" "his" "shadow"])
02:27clojurebot"I worship his shadow "
02:28hiredman,(doc interpose)
02:28clojurebot"([sep coll]); Returns a lazy seq of the elements of coll separated by sep"
02:30hoeckLajla: not ending in whitespace was intended :)
02:30Lajlahoeck, my shadow ends with blackspace.
02:31hoeck,(apply str (interleave ["I" "worship" "his" "shadow"] (repeat " ")))
02:31clojurebot"I worship his shadow "
02:31hoeckinterleave, interpose, I love them! :P
02:31LajlaI want to map over it.
02:32LajlaI worship His Divine Map.
02:51LauJensenGood morning all
02:52vIkSiThey LauJensen
02:55vIkSiThmm, in Clojure - how do you handle the class paradigm, with a bunch of local variables that are bound to it?
02:56tomojbound to what?
02:56tomoja class?
02:56vIkSiTyes
02:56tomojI certainly don't understand you
02:57vIkSiTwell, so lets assume I have a stack class
02:57tomoj,(let [x java.lang.String] x)
02:57clojurebotjava.lang.String
02:57tomojx is bound to String
02:57KirinDavevIkSiT: If you have something where it makes sense to tightly encapsulate the behavior that way
02:57vIkSiTthis contains say, 3 variables - a, b, and c. and 3 methods: push, pop and peek.
02:57KirinDavevIkSiT: Then these days you'd use deftype and a stack protocol (along with other collection interfaces)
02:57vIkSiThmm
02:57KirinDavevIkSiT: But clojure prefers you don't clutter the world with superfluous ontologies
02:58tomoj:D
02:58KirinDaveClojure is verb oriented.
02:58vIkSiTKirinDave, yes I understand how to use protocols, multimethods and deftypes
02:58vIkSiTthe question is - how does Clojure allow me to use verbs to define the same relationships?
02:59LauJensenprotocols, namespaces, hash-maps can all be used in some way to bundle behavior
02:59KirinDavevIkSiT: (pop stack), (push stack item), (count stack). And a namespace. Do you need more?
02:59vIkSiTLauJensen, hmm, you mean using a hash map to store variable info. hmm
03:00vIkSiTcould use that
03:00KirinDavevIkSiT: It may seem a little loosely bound if you're not used to it, but consider the monad library for a good example of how an opaque namespace can give the illusion of a unified interface if you don't know the details.
03:00LauJensenvIkSiT: When Clojure first came out, people basically substituted objects with hash-maps, which was why Rich had to rush to implement it, otherwise people wouldnt try Clojure :)
03:00LauJensenKirinDave: You said 'monad', now I have to ban you from the community
03:00KirinDaveLauJensen: Why?
03:01LauJensenThey're that terrible :)
03:01vIkSiTKirinDave, thanks, let me check it out
03:01vIkSiTLauJensen, heh I can imagine
03:01KirinDaveMonads are fantastically useful in a few limited situations. Those situations are rare.
03:01LauJensenKirinDave: And they all exist in Haskell
03:01tomojin clojure, you mean?
03:01vIkSiTKirinDave, any pointers to code here? http://bitbucket.org/kotarak/monad
03:01tomojrare in clojure, you mean?, I mean
03:01KirinDavevIkSiT: Just read the docs to the contrib monad library
03:01KirinDavetomoj: No, rare in life. You can use them to solve other things
03:01KirinDaveBut you shouldn't.
03:02RaynesLauJensen: You're a Haskell hater?
03:02Raynes:<
03:02LauJensenRaynes: Im a Haskell lover :)
03:02vIkSiThmmm. I see. So substitute a namespace for a class scope
03:02KirinDaveLauJensen: I'm confused.
03:02mmarczykmorning
03:03RaynesI'm confused.
03:03KirinDaveLauJensen: btw thanks for open sourcing your blog.
03:03LauJensenI just dislike monads - Primarily because they are a way of hiding state, not handling it. Which is why Clojure is already more popular because it provides a uniform solution to the state problem. And secondly, the name is just so uuuugly.
03:03LauJensenKirinDave: You're welcome
03:03KirinDaveLauJensen: They're great for implementing some specific things though. As a component for a parser for example.
03:03mmarczykI need to have the KirinDave / LauJensen two lines on monads and Haskell on a t-shirt
03:03KirinDaveAnd the maybe monad is pretty much universally useful.
03:03KirinDaveEven in my ruby days I pretended I had it with ||= chaining.
03:04LauJensenhehe
03:04brehautKirinDave: so is the list monad, though we call it for ;)
03:04mmarczykah, but monads are not only for dealing with state
03:04KirinDaveLauJensen: I bought http://fayr.am
03:04KirinDaveLauJensen: Which is my last name
03:04KirinDaveLauJensen: I figure that's a good place to host a blog.
03:04mmarczykI prefer to think of them as a means of adding complex behaviour to function composition
03:04LauJensenYea why wouldnt it be?
03:05KirinDaveToo bad my middle name isn't http://
03:05LauJensenmmarczyk: I think per definition, Scala is a means of adding complex behavior to function composition :)
03:05LauJensenKirinDave: Yea that would have been sweet
03:05KirinDaveha
03:05LauJensenKirinDave: My only regret, is that my blog is married to nginx
03:05KirinDaveMan I cannot wait for prim to go into main.
03:05LauJensenI might make a teepeedee2 branch :)
03:06mmarczykLauJensen: it certainly appears so from the syntax :-)
03:06brehautLauJensen: whats the problem with nginx?
03:07KirinDavebrehaut: It's a sort of pain of the ass for a small installation.
03:07jrpimran_sr: are you still around? Im trying to get slime.vim working, and wondering what sort of modifications I need to make
03:07LauJensenbrehaut: No problem, its fantastic. I just didnt want the blog to be married to it. And I think teepeedee2 has 2 advantages: 1) serves 6500 customers per second, 2) written in Lisp
03:07brehautKirinDave: oh really? i was looking at using it when ive rebuilt my site
03:07KirinDaveHmm.
03:08LauJensenKirinDave: ?!
03:08LauJensenA pain?
03:08LauJensenIts quite the opposite
03:08KirinDaveLauJensen: Not in my experience.
03:08LauJensenApache is like that elefant which everybody tries to bring to every party
03:08KirinDaveLauJensen: I'm not advocating apache
03:08LauJensen(I know I know, only Raynes actually bring elephants to parties)
03:08KirinDaveHum, what lens to rent for this architectural shoot?
03:09LauJensenOk - I just find nginx to be very lean and clean, easy to set up and runs completely problem free
03:09brehautive been tossing up between lighty and nginx
03:09KirinDave24mm tiltshift
03:09LauJensenIve never had to restart or anything
03:09KirinDaveor 14-24mm?
03:09LauJensenhttp://github.com/vii/teepeedee2
03:14brehautanother clojure for web question; how much ram would you expect the JVM to need to operate comfortably for a small (personal scale) site?
03:14imran_srjrp: sorry, was away. If you using the latest gnu-screen (I don't know what version your linux distro has packaged for you, but I build from git sources), then I would suggest that you dump the way the original slime.vim was communicating with screen
03:15imran_srInstead, try this: write text to a file -> read it into a screen register -> dump register to stdin of desired screen window
03:16imran_srI really ought to cleanup my vimscript, and put it online.
03:16jrpi dont think I am
03:16jrpyeah, Im using a version from oct 06
03:16jrpapparently
03:16imran_srok, so if you look at slime.vim from that webpage I posted
03:16jrpyep, got it installed
03:17imran_srits basically doing this (to send text from vim to screen)
03:17jrpdo I need to modify the -X stuff part?
03:17imran_srtext -> escape awkward chars -> inserting into it a screen stuff command -> run screen stuff
03:17jrpyep
03:17imran_srI changed the method of communicating with screen to instead do this: write text to a file -> read it into a screen register -> dump register to stdin of desired screen window
03:17imran_srthat works flawlessly
03:18KirinDaveHm, I'm trying to decide if http://twelvesouth.com/products/bookbook/ is awesome or tacky.
03:18imran_srjrp: but without cleaning up my own slime.vim, I'm not helping you much :(
03:18KirinDaveI have a http://www.dodocase.com/ and its totally awesome (and not tacky)
03:19KirinDaveBut the bookbook is a little more ostentatious.
03:21vIkSiThmm, what does a (def +something+ 3) imply?
03:21vIkSiTa local variable?
03:22brehautvIkSiT: yes http://clojure.org/vars
03:22KirinDavevIkSiT: It's a var in the current scope.
03:22imran_srjrp: tell you what. I can send you my slime.vim as it is. You just have to pop it into ~/.vim/plugin/, and try it out.
03:22LauJensenimran_sr: That depends on how much the app consumes. If you have an app that at any point holds 350Mb in memory, then you need more than that. If its just for simple interfaces run on a Jetty servlet, then 128mb should be fine. But there's no answer that fits all. So far Best In Class is doing _quite_ well with 256m
03:22vIkSiTah
03:22vIkSiTthanks
03:22brehautvIkSiT: 'local' variables are normally defined with let forms
03:22vIkSiTah right..
03:23KirinDavevIkSiT: Let me confuse you even more: vars are mutable by assignment. :)
03:23vIkSiTthis would be in the current ns, I believe
03:23bartjer, is it possible to use back-references for regular expressions in Clojure ala Perl, etc?
03:23imran_sroh well
03:24brehautbartj: its anything you can do with a normal java regexp
03:24vIkSiTKirinDave, well, they're thread-local right?
03:24KirinDavevIkSiT: yes.
03:24KirinDavevIkSiT: Well, generally they are.
03:25brehautbartj: http://www.regular-expressions.info/java.html
03:26jrpimran_sr: there we go, im very sorry. Could you paste whatever you said from when you were explaining how slime.vim work until now?
03:27vIkSiTLauJensen, re your statement about using maps to store variable information
03:27vIkSiTcan such maps/structs be made part of a protocol?
03:28LauJensenvIkSiT: Yea I suppose they can be wrapped, though Im not sure if there's any idiomatic support for doing it yet
03:28vIkSiThmm..
03:29vIkSiTwould you have pointers on something that does this?
03:29vIkSiTor actually - here's what I'm trying to do
03:29vIkSiTimperatively, I'd have a class called Tuple, that would have a map as a local variable, and a few supporting methods that act on it
03:30vIkSiTso each tuple would carry its instance of the map
03:30brehautvIkSiT: instead of having a class or type contain the map, just pass the map around
03:31vIkSiTbrehaut, hmm, as in?
03:31brehautsay i have a blog post with a title, a description and a timestamp
03:31brehautinstaed of defining a type
03:31tomojwhat do Tuples do that vectors don't?
03:32vIkSiTtomoj, this is a database tuple btw. not a pair class..
03:32LauJensenvIkSiT: To me it sounds like the description of a standard protocol
03:32tomojoh, I see
03:32tomojso a Tuple is a mapping from field names to values?
03:32brehautid just create a new hash map say {:title "frobtz" :description "foo bar baz" :timestamp "2010.06.10"}
03:32tomojyeah.. :)
03:33vIkSiTtomoj, yeap..
03:33vIkSiT.. or trying to anyway.
03:33brehautvIkSiT: a basic toy rdbms would have tables that are sets of vectors
03:34LauJensen(defrecord tuple [x y z]) (defprotocol Ptuple (add []) (remove [])) instantiate it with the maps data, and thats it ?
03:34vIkSiTbrehaut, well almost. a tuple looks like : [(field1, type) , (field2, type).. ]
03:34brehautvIkSiT: then a set of maps ;)
03:34vIkSiTLauJensen, aah yes.
03:35vIkSiThmm I think a vector of maps, yeap :)
03:35brehautvIkSiT: typically a relational DB doesnt allow duplicate records in the table ;) but sure
03:36bartjbrehaut: thanks,
03:36vIkSiTbrehaut, ah this is the schema representation of the table..
03:36brehautvIkSiT: ah right
03:36bartjbrehaut: though, I am not able to find the difference between re-find and re-seq
03:36vIkSiTthe records, yes I agree
03:36bartjbrehaut: since both return sequence of the matches!
03:37LauJensenbartj: one is lazy the other isnt
03:37tomojre-find shouldn't return a sequence..
03:38LauJensen$(re-find #"[1-9]" "abc 1 2 3 def 2")
03:38tomoj,((juxt re-find re-seq) #"foo" "foobarfoo")
03:38sexpbot=> "1"
03:38clojurebot["foo" ("foo" "foo")]
03:38LauJensen$(re-seq #"[1-9]" "abc 1 2 3 def 2")
03:38sexpbot=> ("1" "2" "3" "2")
03:38LauJensentomoj: clever demo
03:44bartjLauJensen: thanks
03:44bartjwhile trying to find the "domain-name" of a URL, I came up with this:
03:45bartj, (nth (re-find #"(https?://)?(www\.)?([^/]+)(.*?)" "http://www.spr-ufo.ru/hanti-mansiysk-g/irtish-servis-zao.html&quot;) 3)
03:45clojurebot"spr-ufo.ru"
03:45tomojseems seq is 2x faster in prim
03:46bartjnot sure, if re-seq (or anything better) would be preferable
03:46LauJensenclojurebot: regex?
03:46clojurebotSometimes people have a problem, and decide to solve it with regular expressions. Now they have two problems.
03:46vu3rdd:-)
03:47tomoj,(.getHost (java.net.URL. "http://www.spr-ufo.ru/hanti-mansiysk-g/irtish-servis-zao.html&quot;))
03:47clojurebot"www.spr-ufo.ru"
03:47tomojpart of the way there
03:48tomojgetting only the domain name would require a tld list, wouldn't it?
03:49tomojerr
03:49tomojI mean the second-level domains like co.uk cause trouble
03:53LauJensenOdd that java.net.URL doesnt support that
03:54brehautis there a function like concat that joins to vectors?
03:55LauJensenconj you mean ?
03:55brehauti dont think so?
03:55tomojthat would be O(n), you OK with that?
03:55LauJensenyou dont?
03:56LauJensen$(-> (.split "http://www.spr-ufo.ru/hanti-mansiysk-g/irtish-servis-zao.html&quot; "\\.") (nth 1))
03:56sexpbot=> "spr-ufo"
03:56brehautLauJensen: if i conj a vector onto a vector, the result will be the first vec with the second as the last elem
03:56LauJensenoh, you want a flat sequence ?
03:56brehautyeah
03:57LauJensen$(into [1 2 3] [4 5 6])
03:57sexpbot=> [1 2 3 4 5 6]
03:57brehautcheers
03:57tomojdoes that use InternalReduce now?
03:58tomojoh, it will use a transient I guess
04:01tomojAND InternalReduce
04:02HerrBlume$(concat [1 2 3] [4 5 6])
04:02sexpbot=> (1 2 3 4 5 6)
04:03Raynesconcat returns a lazyseq.
04:03HerrBlumeah ok
04:03RaynesThat particular application of into returns a vector.
04:03bartjLauJensen: that doesn't get the '.ru' extension, no?
04:03RaynesReturns whatever it's first argument is.
04:03HerrBlume$(into (list 1 2 3) (list 4 5 6))
04:03sexpbot=> (6 5 4 1 2 3)
04:06bartj, (.getHost (java.net.URL. "http://news.bbc.co.uk/2/hi/business/10290933.stm&quot;))
04:06clojurebot"news.bbc.co.uk"
04:07bartjtomoj: apparently the second-level domains, don't cause any trouble?
04:07tomojbut you've still got the subdomain there
04:07bartjtomj: I don't understand?
04:07LauJensenbartj: No its a bit of a hack, it just splits the string on periods and picks out the 2nd match. It only gets the second match, and will break if the www. isnt there
04:07tomojI thought you wanted only "bbc.co.uk"
04:09bartjtomoj: no, that's ok - the complete domain would do
04:09tomojyou still get the "www" though
04:10tomojif you don't mind that, then yeah, no problem
04:12tomojwonder why protocol fns don't get :file and :line metadata
04:14LauJensenhmm, sure they dont?
04:15tomojwell, my clojure.core.protocols/internal-reduce didn't, anyway
04:15tomojI'm not sure swank-clojure could deal with it even if they did, but it would be at least one step closer M-. on protocol fns
04:15tomojs.closer.closer to.
04:46BorkdudeWhy doesn't (find-first even? (repeat (rand-int 10))) terminate?
04:47tomoj,(take 5 (repeat (rand-int 10)))
04:47clojurebot(3 3 3 3 3)
04:47tomoj,(take 5 (repeatedly #(rand-int 10)))
04:47clojurebot(3 5 2 2 6)
04:49Raynes,(rseq [1 2 3])
04:49clojurebot(3 2 1)
04:49tomojwhy not just (* (rand-int 5) 2), though?
04:50Borkdudetomoj, that's also possible, but I was just wondering
04:51Borkdudewhy it doesn't terminate
04:51tomojstill wondering?
04:51Raynes$(take 10 (repeat (rand-int 10)))
04:51sexpbot=> (0 0 0 0 0 0 0 0 0 0)
04:51RaynesIt doesn't terminate because you aren't calling the function over and over again, you're repeating it's first result over and over again.
04:51tomojit will sometimes terminate :)
04:52RaynesUse his repeatedly example, Borkdude.
04:52LauJensenor the force... both can sway the results
04:53tomojrepeat is a function, so (rand-int 10) is first evaluated, then the result is passed to repeat
04:53Borkdudehmm, ok, yes
04:53Borkdudeof course
06:20vu3rddIs it okay to assume that #^ is deprecated for >= 1.2 and ^ is the new meta (and hence type-hint) reader syntax?
06:27Chousukeyes
06:52octei'm trying to have a reference to a function in a map and call it dynamically, but i can't seem to get it work. this is what i have: http://paste.lisp.org/display/111346
06:59raekocte: remove the quote before file-data-collector
07:00octeraek, that seems to evaluate the value of the key in the map when defining the *data-collectors* map
07:00raek*data-collectors* contains a map with entry, which key is "file" and value _the symbol_ file-data-collector
07:00octeuh.. or maybe not
07:01raekyes, you would want to evaluate file-data-collector to get the function that it represents
07:01raekso that the value of the map entry is the function itself
07:01MrHusocte: (def *data-collectors* {"file" file-data-collector}) without the quote works for me
07:02raek,(let [foo {:my-fn (fn [x] (* x x))}] ((:my-fn foo) 5))
07:02clojurebot25
07:03raekalso, it's common to use keywords as keys for maps
07:04raektwo keywords with the same name are guaranteed to be the same instance
07:05raekso even though the keyword :my-fn may occur 1000 times in the code, all uses referes to the same object
07:06octeraek, can i make a string into a keyword?
07:06raekyes
07:06octebecause i will be looking it up by string..
07:07raekjust use (keyword "the-string")
07:07raekbeware of strings with spaces in, though
07:07octeah
07:07octeraek, i found why i didn't think it was evaulating at lookup-time
07:07raekthey will not print correctly: (keyword "foo bar") => :foo bar
07:08octeif i recreate (re-bind? re-evauluate?) the file-data-collector fn i need to also re-avulate the (def *data-collectors*
07:08octeto update the reference i guess
07:08raekah, yes
07:08raekyou can then write #'file-data-collector instead of file-data-collector
07:09raekthis stores the var that the was bound to the function rather than the function itself
07:09octeah, thanks. what does that actually do? (fn [] 'file-data-collector)
07:09raekfn is lambda
07:09octei thought # was a reader-macro of some sort for fn
07:09raekyes, when followed by a paren :)
07:10raek#'foo => (var foo)
07:10raekpronounced "var quote"
07:10raekwhen a var is used as the function in a function application, it firsts looks up the value of the var and uses that instead
07:11raekso vars containing functions can be used as functions
07:11octeah, ok
07:11raek,#'inc
07:11clojurebot#'clojure.core/inc
07:11raek,(inc 1)
07:11clojurebot2
07:11octethese special things are nice, but hard to google for :)
07:11raek,(#'inc 1)
07:11clojurebot2
07:12raekvar-quote is often used when you want to store redefinable functions in data structures, like in your case
07:12raekyou only need to do this in data, though
07:13raekin code, the vars are always used
07:16octethanks, raek
07:22tomojI guess that's why invoking a var invokes the function it's bound to?
07:23raekprobably a convenience feature
07:23ior3khey everyone
07:23raekso one doesn't have to use deref
07:23ChousukeI don't think there's much else that a var could reasonably do when invoked
07:24ior3kI'm a freelancer, and I'd like to start using clojure on my work
07:24tomojgood point
07:24ior3kbut I'm not exactly sure how to convince my clients about that
07:24ior3kanyone has thoughts on this?
07:24rsynnottior3k: what do you currently use in your work?
07:24ior3kruby, mostly
07:25ior3kbut I have experience with several languages
07:25tomojtoo bad you didn't say 'java'
07:25Chousukeior3k: you could try telling them you're just using java library ;P
07:25rsynnotttomoj: yeah, that's what I was thinking
07:25ior3kthat's not the same though
07:25ior3kone thing is a java lib
07:25ior3kthe other is a completely different language
07:25ior3kif for some reason, someone else needs to look at the code
07:26rsynnottthough if you used jruby, and then say, "ooh, look, I can do X thing a hundred times faster, but only if I write it in this scary devil-language"
07:26rsynnott(write that section in)
07:26tomojif random other people are going to have to look at the code, clojure sounds like a bad idea to me
07:26ior3kwell, I guess jruby is one step in the right direction, that's for sure
07:26rsynnottior3k: in general, using exotic languages for things where the client gets the source is often difficult
07:26ior3kyeah, you never really know when that's going to happen,
07:27rsynnott(if you just give them the binary, you can use whatever you feel like, of course)
07:27ior3kI guess I could always ask them if they have a language preference
07:27ior3kbut most do
07:28RaynesIt's too bad that most of them don't know the difference between Clojure and COBOL.
07:28ior3khehe, they shouldn't have to
07:28Raynes"I herd Java is pop u lur."
07:28ior3kbut using an unknown language is quite a risk for them
07:28ior3kif I get hit by a bus
07:28ior3kthey will have trouble finding someone else to maintain the app
07:29Raynesior3k: Get an Iron Man suit, and give them your personal I'll-never-die guarantee.
07:29Raynes;)
07:29ior3khahaha
07:29ior3kI wish
07:29rsynnotttwo of us left more or less at once :S
07:29ior3kyeah, that's really not a position I want to put my clients in
07:30ior3keven though I'd love to be able to use clojure
07:30ior3kI just love lisp :)
07:30RaynesOne day.
07:31rsynnottthere does seem to be a general trend towards non-Java languages on JVM
07:31ior3kyeah
07:31rsynnott(and non C# languages on .NET, for that matter, though that platform's slightly more of a niche)
07:31Raynesior3k: Just think: somewhere, in an alternate universe, you're rocking Clojure all over your clients because Java died in the late 90s.
07:31ior3khehe
07:31ior3kwell, it's true that clojure still allows you to use several java libs
07:31rsynnottRaynes: it would hardly be clojure, if not for the JVM, surely?
07:32ior3kand therefore be more productive
07:32Raynesrsynnott: I said "java died".
07:32RaynesImplying other languages took it's place.
07:32rsynnottI doubt that exactly the same design decisions would have been taken if the JVM wasn't the target
07:32rsynnottah
07:32rsynnottI thought you meant just java died in general
07:32RaynesMaybe Rich is older in this universe, or decided to create Clojure earlier in his life.
07:32rsynnott(which would presumably mean Sun would never have bothered with proper JIT)
07:33ior3kto be honest, I'm not really fond of using java libs in clojure
07:33RaynesI don't really have to do that much anymore.
07:33ior3kusing a non functional black box in a functional language
07:33ior3kfeels weird
07:34ior3kso you think it's getting to a point where there is enough native/wrapped stuff?
07:34ior3kRaynes: ^^^
07:35Raynesior3k: Either that, or I just don't do enough specific stuff to have to use Java libs.
07:35RaynesBesides the standard libs, of course.
07:36ior3koh well
07:36ior3kthank you everyone for your thoughts
07:50rsynnottit is nice having access to them, though :)
07:50rsynnottwith the possible exception of Objective C/C, Clojure/Java interaction is about the nicest interaction between two languages I'v used
07:53Licenserwhy is it that I have the feeling that the lisp comunities hobby is to rant on over every lisp but what they find the best?
07:54tomojseems like there's plenty of ranting about the lisp they like as well :)
07:54Chousukersynnott: I wouldn't count ObjectiveC as "integrated" with C. it IS C, with a bit of syntax for classes and message passing
07:54Licenserit is sad, I mean why can't they all work together?
07:55tomojbecause CL is divinely inspired and we are heretics
07:55rsynnottLicenser: in fairness, CL and Clojure are _extremely_ different languages
07:56rsynnott(CL isn't functional, for instance)
07:56Chousukesome CL people are probably a bit peeved that Clojure has generated so much hype
07:57Chousuke(most probably aren't though)
07:58ChousukeIt would be awesome if CL were used as widely as Java is, but I think that's not possible any more :/
07:59ChousukeCL has found its niche and seems to have got stuck in it :P
08:00lpetitHi, any maven guru here ?
08:01Licenserrsynnott: I'd just hope that people would sit together and make the best out of things
08:01ChousukeLicenser: the problem is that people have differing views on what is best
08:02rsynnottLicenser: the two languages are useful for different things
08:02tomojproblem?
08:02clojurebotPeople have a problem and think "Hey! I'll use a regular expression!". Now they have two problems....
08:02rsynnottthere's some crossover, of course
08:02ChousukeWhat works best in practice is competition. But it needs to be the friendly kind.
08:02lpetittomoj: There's this cool war:inplace goal. Works great, but ....
08:04lpetittomoj: I'm working on a webapp. I'm with Eclipse. So I used eclipse:eclipse goal, which sets my project as dependent of other dependency projects in the workspace. That's cool, but ...
08:04LicenserChousuke: but there is little friendly about the competition I think
08:04ChousukeI suppose :/
08:05tomojlpetit: wait, I didn't mean to suggest I'm a maven guru, sorry
08:05rsynnottLicenser: I've never seen any particular hostility on either side, and there's some overlap in terms of people
08:05Chousukethough I think most of the actual active people are ignoring Clojure and just doing stuff :P
08:05lpetittomoj: war:inplace does not know about the eclipse:eclipse configuration, and keeps copying the snapshots of my workspace dependencies in the WEB-INF/lib/ directory. If I forget to remove them manually, when launching my webapp, it's not the code from the other projects that gets used, but the one in WEB-INF/lib
08:05rsynnottCL people are often rather cruel about Arc, but that's because it's crap, not because of some vicious competition
08:05lpetittomoj: too late. Know you must answer ! :-)
08:05tomojI do use maven, but none of that stuff :(
08:06Chousukersynnott: Does anyone still take Arc seriously?
08:06lpetittomoj: maybe you know how to add behaviour after the invocation of some other goal ?
08:06tomojnope
08:06lpetit:-(
08:07rsynnottChousuke: did anyone ever?
08:07Chousukersynnott: maybe
08:07rsynnottbut it's the only widespead instance I can think of of CL people attacking another language
08:07_fogus_rsynnott: I suppose some Lispers view Arc as less than good, but I never saw the hostility as stemming from that point
08:11_fogus_I'm no expert, but I always saw the gripe against Arc coming from the fact that pg hyped Lisp, got it to the brink of relevance again, and then abandoned it for Arc.
08:11RaynesLicenser: I've had good experiences with the one CLer that I know. I've discussed Clojure with him, he learned stuff from it, and has a pleasant view of it. Although he's persistent in not actually using Clojure, he likes it and is just happy that Lisp of any sort is gaining popularity.
08:12RaynesThere was that loper-os guy, but other than that, I haven't seen much.
08:13tomojwhere does all this unfriendly stuff happen? in the blogosphere?
08:13_fogus_I don't know enough about Arc itself, but many of the complaints against it seem to suggest that its a thin layer over Lisp/Scheme
08:13RaynesThe comments on that loper dude's post were pretty shockingly hostile as well. Most of them didn't appear to have ever seen much of Clojure, and just wanted to join in with the Clojure hate-fest.
08:13_fogus_As for Clojure, there will always be LoperOS guys no matter what, so why worry about it?
08:13rsynnottRaynes: which post is this?
08:14Licenserwell this axis of eval guy was beyond hostile and yes the loperOS guy wasn't nice either
08:14rsynnottah, found it
08:14_fogus_I doubt Rich loses much sleep over it
08:14Raynesrsynnott: That one. :p
08:14rsynnottI don't think either person is actually particularly big in the CL community, though
08:14tomojoh, "Clojure is the False Lisp, which Reeketh of the Cube Farm." hehe
08:15cemerick_fogus_: I think people would have been very happy with arc if it had delivered something notable technically. Renaming standard fns was a helluva letdown after all of that (very good) yammering.
08:16cemerickJust* renaming, that is
08:16lpetitcemerick: you for sure are a maven expert, aren't you ?
08:16cemerickheh
08:16cemericklpetit: perhaps in here.... :-)
08:17cemerickone-eyed man and all that
08:17_fogus_cemerick: I wish I knew enough about Arc's capabilities. But what you say seems to be a common theme.
08:17cemerick;-)
08:17lpetitcemerick: I have this goal which does almost what I want, but not totally. I want an ant-task (via antRunner, I've just discovered how to use it) to be run just after the goal is run.
08:19lpetitlpetit: to be precise: mvn war:inplace copies 3 files in WEB-INF/lib/ that I don't want. So I want to delete them. Easy enough. But I want to have them deleted by configuring my pom.xml so that when writing mvn war:inplace, my deletion task will also be called
08:21lpetit:)
08:25cemericklpetit: surely you'd want to use excludes instead of cleaning up the results afterwards?
08:25rhickeyany feedback on prim branch?
08:26lpetitcemerick: I've tried to configure the war:inplace plugin, but without much result. which exclude configuration are you thinking about ?
08:28chouserrhickey: I'm porting our codebase now. Should have results to report yet this morning.
08:28rhickeychouser: was the codebase on master?
08:29rhickeyIt shouldn't require any changes if so
08:29chouseran older master. we were using deftype pre-defrecord
08:29rhickeychouser: ah, and are many of our types going to become records?
08:30rhickeyyour types
08:30chouseryes. all, I think.
08:35chouseroh, whoops. Not all. custom equiv
08:41rhickeychouser: for numeric equiv or something else?
08:43chouserit's an object that represents a byte string as a offset/length into a byte array.
08:43rhickeychouser: why would that become a record anyway?
08:44chouserI've been assuming things should use defrecord unless there's a reason to prefer deftype
08:45rhickeydefrecord is for information and deftype is for program constructs
08:49dnolenhmm, so is definterface still an AOT kind of thing? and is it the only way to specify primitive args/return ?
08:49dnolenspecify primitive args/return for derecord methods I mean.
08:50dnolens/derecord/defrecord
08:50rhickeydnolen: 1)definterface is dynamic, and 2) well, maybe not after static
08:51chouserheh
08:51chouseroh
08:51chousermaybe not the only way to do primitives. I misunderstood for a moment.
08:51rhickeyOne of the things driving static is the number of times I've had to create a dummy interface just to get helper methods that take/return primitives. Now these can just be fns
08:52rhickeyI'm still contemplating the relationship between static and protocols
08:53dnolenrhickey: so one issue I've seen with with using statics for helpers method is I need to add a lot of args for the fields of the defrecord so I don't pay for the cost of field lookup time when there's lots of iterations
08:54dnolenin that case I would prefer that the deftype method allow primitive arg/return
08:54dnolensadly I've been unable to decipher the proper syntax to do this after looking at gvec :P
08:54rhickeydnolen: field lookup via '.' ?
08:55dnolenrhickey: ah, so that's just as fast just referring to that field when "inside" a defrecord method? I've been sticking with :field access.
08:55rhickeyone issue with statics for that is the circular def problem.
08:56rhickeydnolen: even :field access is fast for deftypes
08:56chouserdefrecords?
08:56rhickeysorry, defrecords
08:57dnolentrue, but I get like a 3X speed boost if I avoid it, and have those be parameters to my static methods
08:57dnolenwell, perhaps overstating more like 2-2.5X or something.
08:58rhickeythe problem is: a static can't use the type of the deftype before its used, and if defined after, can't be used by the deftype impl itself. But this could become a decl thing
08:58rhickeydeftype before it is defined
08:58rhickeysuch decls being not much slimmer than definterfaces :(
08:59AWizzArdrhickey: is there possibly a way to have something like Protocolls for concrete objects?
09:02dnolenrhickey: interesting. I anycase it's still a massive improvement. The code got 1.5X faster from a version that used type-hinting macros. And I love not having to write type hints inside methods.
09:03rhickeyAWizzArd: I don't know what that means
09:06AWizzArdrhickey: Example: in my db system I build indexes for data. There is a (defrecord Index ...). Every Index should be able to report how many elements it holds, a fn to serialize its data, to deserialize it, etc. But: the underlying datastructure that holds the objects inside the many Indexes can differ. In principle each instance of Index should follow a Protocoll, not all Indexes the same.
09:07rhickeyAWizzArd: still don't get it
09:10dnolenrhickey: oh yeah, I thought it was weird that the order of primitive args/return hints differed between definterface and statics (but I guess your saying this is part of the part you're mulling over)
09:10AWizzArdImagine you have the maps M1 = {:a 1, :b 2, :c 3} and M2 = {:x #{1 2 3}, :y #{4}, :z #{5 6}}. And you have a protocoll Cache, which defines get-element-count. For M1 this would be 3, and for M2 this would be 6. We can not simply extend Maps with this protocoll. Both concrete instances need their own implementation of count.
09:12rhickeyAWizzArd: that's why you have records
09:12AWizzArdYes, I was already thinking about writing a macro which will dynamically emit defrecords
09:12rhickeyno plans for per-instance protocol impls
09:13AWizzArdok
09:13rhickeyit adds a step to dispatch that will slow down everyone else
09:13AWizzArdyes, that would not make sense
09:14AWizzArdI just came across this and some days ago chouser had a similar challenge, so I just wanted to ask if this could make sense.
09:20rhickeyinstance methods bring equality/identity, dispatch and GC issues
09:21AWizzArdYes, and there are ways to work around those issues, and I guess they arise not often.
09:21chouserI don't see what I'm doing wrong here: (reify clojure.lang.ILookup (valAt [k])) ;=> java.lang.IllegalArgumentException: Can't define method not in interfaces: valAt
09:22hoeckthis?
09:22clojurebotthis is not allegro
09:23chouserhoeck: gah. thanks.
09:23hoeck:)
09:30canderaLicenser: ping
09:35raeknow I wanna make another IRC bot.
09:36raekirclj looks really neat
09:36Licensercandera: pong
09:36raekRaynes: you're awesome!
09:37canderaLicenser: been trying to come up to speed on clj-swing. Having some problem with adding an ActionListener.
09:37Licenseryou have an example?
09:37canderaYep. Pasting into a gist now. One sec.
09:39canderahttp://gist.github.com/434478
09:40canderaMy action listener never seems to fire.
09:40canderaKeeping in mind that I'm new to swing, and not exactly super-experienced with Clojure.
09:40Licensercandera: you need to put the add-action listener behind the [] the stuff in [] are bindings
09:40canderaYeah, I tried that, too.
09:41Licenserhttp://gist.github.com/434482
09:41Licenseralso you are using EMACS right?
09:41canderaYep.
09:42Licenserlook in the inferior lisp buffer
09:42Licensersince swing is a own thread and the bindings of out and so are sadly different there :(
09:42canderaNothing there. I thought of that, too.
09:43canderaYour code (which I had tried previously) gives me an error. Same error I was seeing: wrong number of args passed to add-action-listener
09:43Licenserhmm
09:43canderaI'm on a recent 1.2 snapshot.
09:44Licenser*nods*
09:44Licenser*fires up the reps*
09:45canderaBTW, I dig clj-swing so far. Very similar to what I had in mind to write.
09:46Licenser:)
09:46Licenserglad to hear that
09:46canderaI have some broader design questions for you at some point, though. :)
09:47arkhis clj-swing a separate effort from what Luke VanderHart was working on?
09:47canderaAlso: specifying the :action on the button works. But I want the action to affect one of the other controls.
09:48Tweyclojure-mode in emacs starts up SBCL in its inferior Lisp buffer ☹
09:53Licensercandera: that's cool :) I am always open to discuss clj-swing or take ideas to make it better
09:53Licenseroh sneaky
09:54candera?
09:54LicenserI opened the wrong repo :P
09:57Licensercandera: found the problem :)
09:57canderaExcellent!
09:58canderaWas it me or you? I'm guessing me. :)
09:58Licensercandera: well tecnically both :P
09:58Licenserbad design decision and non existing documentation on my side, not noticing that form was calling the content in a doto on your side
09:59Licensermind if I keep your code in the examples file?
09:59canderaAh. I think I understand. It's that I was adding an action listner to the frame, yes?
10:00Licenserno it was adding the frame to the action lsitener call which is kind of wrong it was (add-action-listener frame b1 (...))
10:00canderaRight. That's what I was trying to say.
10:00canderaMakes sense.
10:00canderaHow are you going to solve the problem? Anaphora?
10:01LicenserI took the stuff out of doto in the form macro, it is ugly and was a design mistake / oversight that it was in there
10:01Licenserand I don't even know what anaphora means :P
10:02canderaIt just means capturing a variable during the macro expansion. E.g. after the bindings in the frame, you could bind the frame itself to the symbol $.
10:02canderaIncanter does something similar in places.
10:02Licenserah I use :name for that I think
10:02Licenseryap
10:02canderaHow do I refer to the frame in the body of the expansion?
10:02Licenseryou can use :name in most components to that
10:03Licenserwell if you need to (frame ... :name my-frame ... [... binding stuff ...] (.coolFunction my-frame))
10:03canderaBTW: fine to use my example. It's a translation from "Swing: A beginner's guide"
10:03canderaOK - the :name thing works for me.
10:03Licenserkk then you got push to the new version on clojars and github
10:04canderaRead error: sentence does not parse. :)
10:04Licenser(dosync (push-to-github *clj-swing-source*) (push-to-clojars "clj-swing.jar"))
10:05tridd3llDoes anyone use clojure.contrib.sql against an existing database like Oracle or DB2? All of the examples I see use sql/create-table with just a keyword (like :fruit) for the table name. What I need to do is define tables that already exist (like PRODLIB.KEYS) to query/insert against.
10:05canderaMeaning I should do that, or you are?
10:05Licensercandera: meaning I just did
10:06canderaExcellent, thanks. FYI I would have seen that as a reasonable reward for you help. ;)
10:06Licenserheh
10:06Licensercandera: see helping people to work with clj-swing helps me to make it better, find problems I missed since I know how it works and don't expect stuff
10:06MrHusLicencer: The readme on clj-swing does not have the .md extention so formatting is wrong on the page. :P
10:07canderaLicenser: Thanks again - more feedback as I keep working my way through the book (and ultimately the project I want to build)
10:07LicenserI want to make clj-swing as simple and intuitive as possible. I can work on the simple part but the intutive is hard since my intuition is clouded since I know the code :P
10:07LicenserMrHus: thank you I'll fix that
10:09Licensercandera: I already can promise that you'll reach a point where clj-swing won't be enough since, I haven't implemented (wrapped) all kinds of widgets by far
10:11canderaLicenser: then I'll start breathing down your neck. :) Anyway, I've got to run off to go buy a house! Thanks again!
10:13raekwhere exactly does lein-swank live? leiningen? an own project?
10:16Licensertake care candera
10:19raekaha, lein-swank is now a part of swank-clojure...
10:27raekwhohoo! got swank-clojure, slime and clj-1.2.0 working over UTF-8!
10:28raekmy mind will finally be at peace
10:30Raynesraek: I'm awesome? :D
10:30Raynes<3
10:36raeknow, lets see... how does irclj handle encoding?
10:37raekhrm, clojure.contrib.io/reader uses clojure.contrib.io/*default-encoding*, which is UTF-8
10:38raeknote: in swedish channels, about 50% use latin-1 and 50% UTF-8
10:38raekthis only works because irc clients are smart and try both decoding from UTF-8 and Latin-1
10:42raekhrm, maybe one could make a java CharsetProvider that provides a try-utf8-fallback-to-latin1 Charset
10:48RaynesOi.
10:49RaynesI just noticed a bug in Irclj. Good thing I never used the :on-action handler in sexpbot, because it was broken. :\
10:58raekRaynes: how often do you push to clojars?
10:59Raynesraek: If I make a fix, or add something (like I'm doing as we speak), I push a new snapshot as soon as I know that sexpbot will run with the new snapshot.
10:59raekah, cool
10:59RaynesI'm very liberal with my snapshots.
10:59Raynes;P
11:01Raynesraek: I'll ping you when I push.
11:05Raynesraek: Just pushed the new snapshot.
11:06RaynesThat :on-action bug would have been nasty, had anyone actually used it.
11:06Raynessexpbot doesn't do anything special for actions, so I never noticed it.
11:07RaynesMy test/example bot needs to be more through so that I can catch stuff like that.
11:10Raynesraek: Sorry for Irclj's shoddy documentation. Most of that thing was thrown together in a day and a half, and I've been busy with other stuff lately, so the documentation hasn't really improved.
11:12raekwell, the example has shown me what I have needed so far... :)
11:14raekDownloading: irclj/irclj/0.3.0-SNAPSHOT/irclj-0.3.0-20100502.112537-6.jar from clojars
11:14Raynesraek: Yeah, the example bot isn't too bad. There isn't much to Irclj, so the general idea is easy to get across. It's what Irclj is 'specifically' capable of that isn't entirely clear.
11:14raekdoes it take some time before the new one gets through?
11:15RaynesHm?
11:15raekI just cleared all my irclj jar files from the project and .m2
11:15raekand ran lein deps
11:15jcromartieis 1.2 considered "beta" at this point or what?
11:15raeklooks like it downloaded a version from 2010-05-02
11:16RaynesOh.
11:16RaynesHrm.
11:16RaynesI'll try that again. Give me a sec.
11:17Raynes[INFO] Uploading project information for irclj 0.3.0-20100502.112537-7
11:18Raynesraek: Apparently, it's right. I guess maven's calendar is broke?
11:18Raynes:\
11:18raekhah, ok
11:18raekanother question: how are private messages to the bot handled?
11:19raekis the :channel value instead the nick or something?
11:19RaynesThey're considered normal messages, and trigger the :on-message handler.
11:19RaynesThe :channel value is the nick instead.
11:19raeknice, so I can always reply to "channel"
11:19RaynesYep.
11:19Raynes:)
11:20Raynesraek: I'm taking off for a while. If you have any more questions, ping me or shoot me a message on github.
11:22raekall right.
11:23raeknow, where's my cond-re macro?
11:23raekthis could make my bot's command parsing much simpler: http://gist.github.com/387097
11:26dnolen_raek: couldn't you do that with condp and re-matches?
11:27jcromartieyeah, looks like condp already fits the bill
11:27jcromartiealthough I have to say condp is one of the trickiest things to grasp in Clojure
11:29dnolen_jcromartie: really? so many others things on my list that are harder to grasp :D tho it is diminishing over time ...
11:29jcromartieheh
11:29jcromartieI just had to use it to really get it
11:29raekI wanted a more compact way of including the destruturing
11:30raekit takes triples of [re bindings body]
11:30raekbindings are bound to the groups of the match
11:30dnolen_raek: i see. cool. so you have your solution :)
11:34cgrandraek: (defn parse-flag [s] (rest (re-matches #"--([^=]+)(?:=(.*))?" "--abc")))
11:36cgranderr I mean (defn parse-flag [s] (rest (re-matches #"--([^=]+)(?:=(.*))?" s))) ;-)
11:37dnolen_can somebody tell me what I'm doing wrong here? I'm trying to create a type-hinted method on defrecord, http://gist.github.com/434649
11:38Chousukednolen_: bar is a method, not a function
11:38Chousukednolen_: maybe you meant to define a protocol instead?
11:39dnolen_Chousuke: wow, so only protocols generate fns?
11:39Chousukednolen_: yes.
11:39Chousukedefinterface generates an interface
11:39dnolen_Chousuke: that was the gap in my understanding abou the relation between interfaces and protocols.
11:39Chousukebest not think of them as at all related
11:40Chousukea protocol is backed by an interface, but that's just the implementation
11:50Licensercoookies!
11:51Raynescakes!
11:52cemericklpetit: should ccw work OK in helios RCs?
11:55lpetitcemerick: not tested for a while, but I guess so
11:56lpetitcemerick: did I just loose ? :)
11:56cemericklpetit: not at all, we'll see how it goes.
11:57lpetitcemerick: ok then. Honestly I'm pretty confident
11:58cemerickyeah, it's supposed to be entirely compatible with whatever the current rev is, just thought I'd check
11:58Licenserno Raynes cooooookies!
11:59LicenserI want to build something geniouse and crazy
11:59lpetitcemerick: that's a good test I haven't done in a while. Looking forward to your feedback
12:01cemericklpetit: am I right in thinking that ccw doesn't have remote repl capability?
12:01lpetitcemerick: you're right, it's on my todo list
12:02cemericklpetit: if possible, I'd recommend just reusing the existing impls
12:02lpetitcemerick: as you guessed (was it you ? I think so) in one of your blog posts, we are using the java console input/output facilities provided by Eclipse
12:02cemerickenclojure's repl library has been very solid for us. I don't have any experience with swank, though.
12:02cemerickyeah, I figured
12:03cemerickIMO, all repls should be run over a socket
12:03cemerickI've always had issues with inferior repls
12:04cemerickor, I should say, did the last time I used them :-)
12:06lpetitcemerick: sure, I totally agree. One path for everything. Even if the REPL is from the same JVM, pass through a socket for communicating between the server part and the GUI partr
12:06cemerickyup
12:09lpetitcemerick: but from what I've seen, I will not take a lot of things from enclojure repl, when I plan to do so. Because the GUI part is in swing, and will resemble nothing under Eclipse
12:10cemericklpetit: the GUI is irrelevant -- the tricky part is the repl client/server library, which is a separate small component :-)
12:10cemerickor, not irrelevant, but easy to recreate ;-)
12:11lpetitcemerick: indeed, but for ccw, I just use the "trick" (currently) of starting the application to test with clojure.contrib.repl_ln :-)
12:12lpetitcemerick: I also have a "server" backdoor, of course, to be able to send commands to the launched JVM
12:12lpetitcemerick: carefully written in clojure 1.0 style, so that it works for any clojure a user may want to use
12:18Licensercookies
12:21rrc7cz-hmis there some trick for working on a gen-class and not having to restart swank? working within already defined methods is fine of course, but when you're adding methods I don't see another way
12:21arohnerit would be really nice if you could apply a map to (fn foo [ & { a :a b :b}])
12:21arohner(apply foo {:a 1 :b 2})
12:30StartsWithKin clojure dist, test/clojure/test_clojure/genclass/examples.clj there is ExampleAnnotationClass using new reader syntax to attach metadata to class
12:31StartsWithKhow can that be used lets say to add: @Perm("can-read") @Perm("can-write")
12:35StartsWithKalso, are there any examples on how to use enums and other annotations inside the annotation value part
12:43chouserweird. I've got what appears to be a deadlock involving agent await that only shows up after upgrading clojure.
12:43chouserI don't really believe that's it, but that's how it looks at the moment.
13:20dnolen_hmm does ^:static work for def as well?
13:25duncanmdum de dum
13:31Bootviswhat's the difference between defn- and defn?
13:31RaynesBootvis: defn- makes the definition private.
13:31Bootvisthanks
13:45chouserrhickey: we using binding to replace various core functions with our own for unit tests
13:45chouseras long as core functions have been vars this has worked just fine. direct linking started to change this, but we had a workaround. statics are killing.
13:46rhickeychouser: with your hack for direct linked things?
13:46chouserwe'll have to find another way to solve our problem before we can use the prim branch
13:46rhickeywhat's an example of something you replace and why?
13:47chouserwhat is easy. I'll work on why for you.
13:48chouserwhat: pmap, send-off, await
13:48technomancywe rebind test-var so we can mark some tests as integration tests in their metadata
13:48technomancythat way we can skip the tests that require network access when doing our regular test runs and run them with less frequency.
13:49technomancyvery nice capability to have.
13:49technomancymight be worth formalizing in clojure.test in the future though.
13:50chouseroh, I bet all these are to support mocking of our own network functions.
13:50rhickeyif your hack was based on modifying the metadata before compiling a use, you can just lop of :static true
13:51rhickeylop off
13:51chouserthe test calls real code that may call network functions inside pmap or send-off
13:52technomancychouser: we have a with-alter-var-root macro for that. it's super-ick, but it works across threads.
13:52chouserwe want to mock out those network functions with binding, but that fails if the real code does a real send-off, so we have to mock that out as well.
13:52technomancyobviously verboten for anything but tests
13:52chousertechnomancy: hm, that might be better
13:53chouserok, lopping off :static works fine for now.
13:53chouserall tests pass. prim is good enough for us. :-)
13:53rhickeyyay
13:53chouserbut altering the var root would be much better.
13:54rhickeyso, this still begs the question of opt-in/out and knobs
13:54chouserthat were never really answered with direct linking
13:55rhickeya big problem is people thinking they should be able to change the decision of other people re: direct links
13:59cemerickeasily being able to route around "private" vars when necessary seems like a corollary, but carrying over that principle doesn't sound possible
14:00rhickeycemerick: @#'
14:01cemerickyes, I know about that
14:01rhickeycemerick: so, I don't understand re: private vars
14:01cemerickI'm just saying that both statics and visibility are examples of authors making decisions that users might want to override
14:02rhickey#'
14:03timcharperwill a future die if it's running, but there are no references to retrieve it's result ?
14:03timcharperIE: does the running thread keep it from being garbage collected ?
14:03timcharper
14:04chousertimcharper: yes, the running thread will keep going
14:05chouser,(let [x (future (Thread/sleep 2000) (println "stayin' alive"))] 0)
14:05clojurebot0
14:05chouserheh. well, it works at a real repl.
14:06chouserI imagine "sayin' alive" is printed on some clojurebot console somewhere.
14:09leif-pHi. All the examples in clojure.walk have to do with transformation. Does anyone have any example code where they walk through a form collecting values? I can do it by mutating an atom, but I hope there is a more functional, clojure-y way.
14:19aria42Is there a *special* variable that's set when a form is being evaluated as part of compilation?
14:40yacincan you do the multiple possible argument destructuring that you can do in defns in defmethods?
14:40yacinlike
14:40yacin(defn mymax ([x] x) ([x y] ...))?
14:41yacini guess having different arglists in defmethod is what i want
14:41yacinor should i just make my dispatch function take this into account?
14:44chouseryour dispatch function will have to handle different arity counts either way
14:45yacinyeah, i just realized that
14:46jasonamsterny good tutorials or walkthroughs for a rubyist to learn clojure? Not just syntax but doing projects and creating apps
14:46technomancyclojurebot: peepcode?
14:46clojurebotpeepcode is a commercial screencast series; see the Clojure one at http://peepcode.com/products/functional-programming-with-clojure by technomancy
14:47jasonamstertechnomancy: isn't peepcode out of date?
14:47technomancyjasonamster: it doesn't cover the latest features of clojure, but the stuff it covers is still relevant.
14:47technomancyI wrote a blog post that covers the few things that are a bit out of date: http://technomancy.us/136
14:48jasonamstertechnomancy: okay great... I actually think I purchased that peepcode a while back anyway... Now if I can only find it.
14:48technomancyheh; cool
14:49technomancyclojure is really good about not breaking backwards compatibility within the language itself (modulo external libraries)
14:51jasonamsterjust found it... yep i remember watching this... I must have been drunk, b/c it's a blurry memory
14:54technomancyheh
15:25timcharperchouser, heheh. Thanks.
15:25chouser:-)
15:26timcharperthe bot is still probably singing "oh, oh, oh, oh, sayin' alive"
15:26chouserI know I am.
15:26timcharperinfecting song, isn't it?
15:26timcharperlol
15:27timcharperin seriousness though... is there anyway to hook into the garbage collector with clojure? Or is this naughty? I'd like to have a thread that stops when an object is freed.
15:27chousertimcharper: fill-queue does that, I think, but it's messy, fragile, etc.
15:27technomancyclojurebot: 𝅘𝅥𝅮 "This was a triumph. I'm making a note here: huge success." 𝅘𝅥𝅯
15:27clojurebotmake a note of http://scienceblogs.com/goodmath/2006/11/the_c_is_efficient_language_fa.php it is yet another article about picking c or c++ for performance being naive
15:27chousertechnomancy: :-)
15:28chouserfor the good of all of us, except the ones that are dead.
15:30chousertimcharper: see 'alive?' and (throw ... "abandoned")
15:30timcharperlooking...
15:30timcharperyeah
15:32timcharperso, you create an object that is not referenced by the fill fn (but is by the drain fn)
15:32timcharperso if the drain fn gets gc'd, then so does the fill fn ?
15:33timcharperhmmm... let me see if I get this actually...
15:34chouserclose. if the drain instance is gc'ed, next time fill loops it'll notice and kill the thread so the thread no longer keeps refs to the blocking queue, etc.
15:34timcharperah... the drain fn is the lazy sequence :)
15:34timcharperthat is pretty neat
15:34timcharperwhy is that fragile ?
15:34timcharper(I want to create a process that subscribes to a queue and pulls off mongodb records from it, running mass-insert on it everytime)
15:35chouserit's a lot of consequence hanging on GC's specific behavior
15:35chouseryou might consider more specifically-scoped behavior, something closer to with-open
15:35timcharperI considered that first
15:35chouseroh, good.
15:35chouserthat's the correct order. :-)
15:35timcharperbut I've already got two with-open-ish statements on this piece of code
15:36timcharperand adding another... it just nests deeper and deeper
15:36timcharperI would like to flatten them
15:36timcharper(maybe I should write a macro for it...)
15:36timcharperto flatten the nesting
15:36chouserwell, if the nesting points are correct, I'd -- yeah, combine them somehow rather than going to some other mechanism
15:37timcharperit's a with-open to read a csv, with-open to write a csv, and then a with-mongo-db-mass-inserter-thingy
15:37chouserthe GC-based behavior probably should only be considered if you can't know by any other mechanism when it should be cleaned up
15:37timcharperwhich in the case of fill-queue... would suck to have to remember to close it
15:37timcharper(which is why GC exists)
15:37chousertimcharper: maybe a protocol so you can (with-my-open [reader ... writer ... mongo ...] ...)
15:38chouserand extend the protocol to all of them. only one level of nesting then, but without losing any specificity.
15:38timcharperwhat about a thread-through approach for nested macros ?
15:39chousersure, if that works
15:39timcharperkinda like thread through... but obviously without the threading
15:39timcharper(as in threading a value through it)
15:39timcharperheh, ok. Thank you counselor chouser :)
15:39chouser:-)
15:52arkhdoes a repl (await) an agent (send-off) ? When I send-off an agent at the repl with an infinite loop, the repl doesn't return with another prompt
15:53arkhe.g. (send-off (agent nil) #(do (prn "hi") (Thread/sleep 1000) (recur))
15:54chouseryou're just missing a close paren
15:54chouserbut even with that fixed, the agent will immediately fail because the action fn must take at least one argument
15:55arkhgee I do good work ... thank you though
15:57arkh(send-off (agent nil) (fn [_] (do (prn "hi") (Thread/sleep 1000) (recur nil))))
15:57chousernp
15:57chouserthere you go. :-)
15:57arkhchouser: thanks! ; )
16:49aria42Is anyone using the maven plugin (1.3.2) and having trouble getting it to respect the compile and copy configuration elements?
17:14duncanmkinda quiet today....
17:16dnolen_duncanm: the pre 1.2 hush ...
17:19serp_sup
17:21dnolen_rhickey: so what was the rationale behind putting the return arg type hint where it is now? is that because ^:static true would look weird? wouldn't it be better to just have fns that are tagged in the normal way with ^long or ^double to have implicit static?
17:22dnolen_erg I mean ^:static hint foo
17:22dnolen_^:static ^hint foo
17:34serp_is it ever a problem in practice that transactions become too big and performance dies because the transaction becomes interupted by external modifications and keeps restarting?
17:39dnolen_serp_: that's a possibility, but as long as you give your design some thought you can make that very unlikely. the trick in clojure it seems is to pick the right level of granularity.
17:40dnolen_serp_: if you need to serialize access use an atom, if you to coordinate two or more things use refs. That's what I've culled anyway. People who know better than I can probably say more.
17:43hiredmanjust like locks you can also change granularity, a map in a ref vs. each value in a map being a ref
17:44hiredmanthe difference is operations on refs compose
17:50serp_I have to read more stuff to understand your answers, but thanks :)
17:55rhickeydnolen_: if you have multiple arities they might have different returns
17:57arohnerif you have a fn with signature [ & {a :a b :b}], and you want to apply a map, is there a faster/cleaner way than (apply foo (interleave (keys map) (vals map)))?
17:57dnolen_rhickey: oh yeah. thx.
17:59dnolen_serp_: transactions seem scary/involved but it's actually pretty easy to set some up, use a couple Thread/sleep and you can get a intuitive sense of what kinds of things can happen.
18:07rmarianskiarohner: maybe you can (flatten (seq map))
18:07rmarianskidunno if that's cleaner though
18:07arohnerrmarianski: using flatten makes a little more sense to me. thanks
18:08rmarianskisure, np
18:20mebaran151is it possible to completely AOT compile a Clojure app that uses defprotocol and friends?
18:21mebaran151I was wondering if I AOT'ed a Clojure 1.2 app if I couldn't avoid nasty probles on android (running just the final jar once through dx)
18:44arohnermebaran151: I'm pretty sure the answer is yes, you can AOT defprotocol
18:45arohnermebaran151: I don't know if that's solves all the issues of running on andriod.
18:46lancepantzi think it would completely break servlets if you couldn't
18:54hamzaguys, I have symbol for a function and I need to call that particular function something like the following (let [s 'println] (s "Hello...")) but it does not work..
18:55Tweyhamza: Don't call a symbol, just call the function
18:56Twey(let [s println] (s "Hello"))
18:56dakrone,(let [s (var println)] (s "hello"))
18:56clojurebothello
18:56Twey,(let [f (+ % 1)] (f 3))
18:56clojurebotjava.lang.Exception: Unable to resolve symbol: % in this context
18:56Twey,(let [f #(+ % 1)] (f 3))
18:56clojurebot4
18:56Tweydakrone: What's the ‘var’ for?
18:57Twey,(let [s println] (s "Hello"))
18:57clojurebotHello
18:57dakronethat works too, don't even need the var
18:57Chousukehamza: you can resolve a symbol to a var by using resolve
18:58hamzabut in my case symbols are user defined, i pass them around as symbols then i need to call them.
18:58hamza,(doc var)
18:58clojurebotGabh mo leithscéal?
18:58TweyHaha
18:58Chousukevar is not for runtime stuf
18:58Chousukef
18:58Tweyhttp://clojure.org/special_forms#var
18:58Chousuke,((resolve 'println) "foo")
18:58clojurebotfoo
18:58hamza,(let [s 'println] ((resolve s) "Hello..."))
18:58clojurebotHello...
18:58TweyAh, ‘resolve’, that's the one
18:59Twey,(let [f 3] (eval 'f))
18:59clojurebotDENIED
18:59hamzacool thanks..
18:59Chousukeresolve can return nil though, so beware
18:59Lajla,(let [gay 3] (let [twey gay] (+ twey gay)))
18:59clojurebot6
18:59TweyDenied?! :-D
18:59Chousukeit'll also return a Class instance for class names.
18:59TweyHm, not allowed eh.
18:59ChousukeTwey: eval is not allowed
19:00TweyIt's an error anyway. Guess eval doesn't work like that.
19:00LajlaChousuke, kerro twey:lle että mun suomenkieli on parempi kuin sen.
19:00timcharperchouser: for fun and giggles, here's a macro that encapsulates the WeakReference pattern used by fill-queue
19:00Twey>.>
19:00Lajlakerro että olen paras.
19:00hamzaChousuke: function will be defined before calling it, is it safe to assume it wont return nil in this case?
19:00ChousukeLajla: You're being weird :P
19:00LajlaChousuke, I guess, it's a curse.
19:00TweyHow long have you known Lajla? :þ
19:00timcharperhttp://gist.github.com/435165
19:01LajlaTwey, do not remind it.
19:01LajlaYou're a cruel man.
19:01LajlaReminding people that I exist.
19:01Twey'tis true
19:01LajlaYou should hate yourself, I happen to have some of that spare for you.
19:01TweySometimes I sit here and just look at you, so you can't escape.
19:01LajlaSometimes I wank and think about my sister.
19:01TweyI knew that already.
19:01LajlaI say it a lot.
19:02LajlaMore reason to hate myself.
19:02LajlaAnd more reason for you to do so too, your thoughts have been beviled with incest.
19:02Chousukeseriously now, keep that outside this channel, please.
19:03timcharperchouser: maybe you don't want to wrap it because it can be abused
19:03timcharper:)
19:05timcharperLajla: not funny
19:05timcharper "Yields an object and a fn to tell if if the object has been GC'd yet
19:05timcharper
19:05timcharper The following will quit when the return value is no longer referenced and GC is run
19:05timcharper
19:05timcharper (with-monitor [monitor alive?]
19:06timcharper (let [alive-fn (fn [] (loop []
19:06timcharper (println \"alive...\")
19:06timcharper (java.lang.Thread/sleep 1000)
19:06timcharper (when (alive?) (recur))))]
19:06timcharper (future (alive-fn))
19:06timcharper monitor))"
19:06timcharper [[tracer-binding alive?-fn-binding] & body]
19:06timcharper `(let [~tracer-binding (Object.)
19:06timcharper weak-ref# (java.lang.ref.WeakReference. ~tracer-binding)
19:06timcharper ~alive?-fn-binding (fn [] (not (nil? (.get weak-ref#))))]
19:06timcharper ~@body))
19:06timcharperummm... wow. Go ERC random yank.
19:10RosaSchafhi, I was searching for something and came across neman.cells in the list of libraries on clojure.org. I have actually no idea but it seems to be interesting. However, the latest change was made over an year ago and I wonder if the idea is still up to date and if it is, if there is another, more active implementation or if neman.cells will work fine? (I actually just want to know if it is worth to have a closer look at it)
20:05quotemstrWhy does Clojure put the docstring *before* the arguments?
20:06TweyBecause the bodies of a function are arglist/expression pairs?
20:06quotemstrBod... ies?
20:07TweyYou can overload a function on number of arguments
20:07quotemstrIn the same defn?
20:07Twey(defn foo [x y] (foo) [x y z] (bar))
20:07TweyYes
20:07quotemstrAh.
20:09technomancyquotemstr: the only thing that helps there is font-lock; Emacs will highlight it with comment-face if it's in the right place.
20:12quotemstrSo where in the Emacs implementation in Clojure? Every Lisp dialect seems to get its own Emacs. :-)
20:13ChousukeTwey: not quite like that though.
20:14technomancyquotemstr: actually once Emacs gets threads and Clojure gets a little closer to self-hosting, Emacs may become a feasible compilation target.
20:14Chousukeif you want to overload by arity, you need more parens :)
20:14TweyReally? Damn.
20:14Chousukeeg. (defn foo ([a] a) ([a b] b))
20:14TweyThanks. I'm new. ☺
20:24LajlaTwey, if I prove that my language is better than clojure and make a better compiler, will you then join the dark side?
20:25zakwilsonHow does one prove that a language is "better"?
20:37hamzaare there any examples that show how can i use protocols to override functions such as conj to work on custom data structures?
20:38hamzaI am looking over protocols and types but no examples
20:38technomancyhamza: conj hasn't been ported to use protocols yet
20:39hamzatechnomancy: thanks, is there alist somewhere that shows which functions are ported?
20:45technomancyI don't know of such a list.
21:28Lajlazakwilson, well, by me saying it is, and then using the argument to authority.
21:29tomojwell, you can have a deftype implement IPersistentCollection for custom conj behavior, right?
21:31Lajlatomoj, are you addressing me?
21:32tomojnope
21:32Lajlatomoj, why not?
21:32LajlaDon't youy like to put me in the centre of attention?
21:36quotemstrDo {}-structures default to ordered or unordered maps?
21:36quotemstrEww -- comma are just ignored?
21:36quotemstrcommas, even.
21:36quotemstrWhat about in backquote?
21:36Lajlaquotemstr, commata, and yes.
21:36LajlaYou use ~
21:37quotemstrAh.
21:37Lajla`(a ~b c)
21:37LajlaSame key too
21:37LajlaOn most keyboards
21:37quotemstrI can live with that.
21:37Lajlaquotemstr, if you can, then so can I.
21:38LajlaIf you believe, then so do I.
21:38Lajlaquotemstr, also, they call the syntax-quote.
21:38LajlaWe call it the unquote.
21:38LajlaPluriformity eh?
21:38LajlaAnd we all respect each other
21:38LajlaAnd don't go argue about it.
21:38LajlaWe realize we all mean the same thing, but say it differently.
21:38LajlaWe don't blow ourselves up because of it.
21:38LajlaWe're all friends.
21:39quotemstrI get the feeling there have been massive flamewars on this very topic.
21:39Lajla,(let [a 3 b 4] `(~(+ a b) c))
21:39clojurebot(7 sandbox/c)
21:39Lajlaquotemstr, I haven't seen them.
21:40LajlaLisp is unlike the gaza strip.
21:40Lajlahere we realize, Scheme, CL or Clojure, we all came from the same roots.
21:40LajlaWe believe the same things in essense, minor differences.
21:40LajlaWe should be brethren, not war.
21:40LajlaWe're all entitled to the promised land.
21:41quotemstrMy ancestors called it quasiquote and I'll DIE and MARTYR MYSELF before you call it syntax-quote you filthy heathen!
21:41quotemstrErr, I mean, right.
21:41Lajlaquotemstr, that's another thing.
21:41Lajlaquasiquote is `
21:41Lajlaquote is '
21:42Lajlaand unquote is , in Scheme, in CL it's called backquote, Cloj has ~, and calls it syntax-quote.
21:42Lajlaquotemstr, be open to the warmth we offer you.
21:42raekno, it is ` which is called syntax-quote
21:42raek~ is simply called unquote
21:42clojurebotTitim gan éirí ort.
21:42raekand ~@ unquote-splicing
21:43LajlaWhether you cover up your women and beat them to death for being raped, whether you sell indulgences in the name of God to enrich yourself, whether you nuke homeless people who got in a land before you you think is your promised land, we all have our failures, doesn't mean we can't get be friends.
21:43Lajlaraek, I respect your vision
21:43Lajlaafter all, doesn't matter how we call it, it's the same.
21:45raekI just wanted to avoid confusion about clojure's names, not pick on other lisps' conventions...
21:45Lajlaraek, I respect that.
21:45raekanyway, http://clojure.org/reader says "Syntax-quote (`, note, the "backquote" character), Unquote (~) and Unquote-splicing (~@)"
21:46raekthat was what I wanted to relay
21:46LajlaTo inform is the key to peaceful co-existence between different creeds.
21:46LajlaWelcome that which is different, do not be afraid of it.
21:50lancepantzLajla: to a point
21:50lancepantz"all that is necessary for the triumph of evils is that the good men do nothing"
21:51lancepantznot that i'm saying we should take out the scheme fans
21:54quotemstrSo def *always* affects the root binding, where set! affects either the root or the current dynamic binding?
21:54raekset! can only affect a thread-local (i.e. dynamic) binding
21:55quotemstrSo set! on an unbound variable is an error?
21:55raekyes
21:55quotemstrHrm.
21:55LajlaNot sure if this is the idea of clojure, but in Scheme, the idea is that set! changes a memory address.
21:55LajlaAnd define actually binds a variable.
21:56LajlaEhh, hanges the contents of a memory address.
21:56raekclojure is a bit different from scheme
21:56Lajlalancepantz, it has a reason though, good leaders are reluctant to lead.
21:57raekonly root bindings can change
21:57quotemstrraek: Then what does set! do?
21:57raeklocals introduced by let and function parameters are actually not variables at all, but local names for immutable values
21:58Lajlaraek, that's the same thing in Scheme though.
21:58raekyou can mutate vars if you have a thread-local binding for it
21:58Lajlaset! does not mutate.
21:58LajlaIt binds a symbol to another value.
21:58raekit mutates the var object
21:59raekclojure variables are objects
21:59raekliving in a namespace
21:59LajlaIf that was so, then let would mutate it too.
21:59LajlaIt changes the environment in a way.
21:59raeklet makes a new environment
22:00raek(if one uses scheme terminology)
22:00LajlaThat is true
22:00Lajlaset! changes it, but it doesn't mutate any data per se.
22:00raekyes
22:01raekanyway, in order to be able to change a variable with set!, it must first have a thread-local value
22:01LajlaAs in (define x #(1 2 3)) (define y x) (set! x #(2 3 4)) y will then still have #(1 2 3)
22:01raekthis is done by (binding)
22:01raeka warning: in clojure, def should normally only be used at the top level
22:02raekit does not add a new binding in the "closest" frame, but in the global environment
22:02raek(the current namespace)
22:02JonSmithright
22:02JonSmithdef is global
22:03raekthese things doesn't work much like in scheme
22:03quotemstrCan Clojure's reader eval by itself like CL's can?
22:03JonSmithraek: is more like common lisp in that way
22:05raekIIRC, there is a #= reader macro that evaluates
22:06raek(def x 1) (set! x 2) => "Can't change/establish root binding of: x with set"
22:06JonSmithyou have to do binding first
22:06raek(def x 1) (binding [x 2] (set! x 3) x) => 3
22:06JonSmithset is thread local
22:07raekyes, I just thought I'd show quotemstr an example
22:07quotemstrThanks.
22:07JonSmithoh ok
22:07JonSmithi think i came in partway through, my bad
22:07quotemstrCan refs point to refs?
22:08raekset! can be used when interfacing with some java libraries
22:08raekyes, refs can point to anything and nesting is allowed
22:08raekyou can make cycles this way too
22:08raekjust make sure not to try to print the ref
22:09raek(if you have cycles)
22:09raekalso, in the example with binding, after binding has been evaluated, x has the value 1
22:10raekand all other threads saw the value 1 during all the time
22:11quotemstrAh, I like the shortcut literal syntax.
22:11quotemstrshortcut lambda syntax, that is.
22:19quotemstrHrm, I'd prefer map to do the Python-esque thing and return an iterator object instead of being automagically lazy.
22:27tomojhuh?
22:28tomojiterators aren't lazy?
22:28quotemstrSure they are.
22:29quotemstrBut in Python, printing an iterator doesn't automatically try to iterate through all items in the sequence.
22:29quotemstriter((1,2,3)) => <tupleiterator object at 0x10048c7d0>
22:32KirinDavequotemstr: “automagically lazy?”
22:32quotemstrKirinDave: What I mean is that map seems to return a magic object instead of the mapped sequence.
22:33quotemstrBinding this magic object to a var doesn't evaluate the sequence, but then trying to get at the value of the var evaluates the sequence.
22:33quotemstrTrying to print this magic object similarly evaluates the sequence.
22:33KirinDavequotemstr: "Getting" doesn't actually.
22:33KirinDavequotemstr: You're playing on the repl?
22:33quotemstrKirinDave: No, just looking at some documentation for now. :-)
22:34KirinDavequotemstr: It doesn't return any sort of magical object, it returns a lazy seq. Which is like a cons cell but the cdr is delayed computation that it knows to force.
22:34quotemstrIs it possible to print the delayed sequence object itself without resolving the sequence?
22:35KirinDaveThere are ways to make a unique identifier, but otherwise the print function forces it.
22:36quotemstrWhat does a unique identifier have to do with it? Let's consider lists.
22:36quotemstrYou have regular lists and lazy lists, right?
22:36KirinDavequotemstr: yes.
22:36quotemstrA var can be set to either kind of list.
22:36KirinDaveYes.
22:36quotemstr(Among other data types.)
22:37tomojso is the quibble just about the printed representation of a lazy seq?
22:37quotemstrKirinDave: But list and printing functions on that var will do the same thing regardless of whether it's a lazy or real list, right?
22:37KirinDavequotemstr: What it does depends entirely upon the object.
22:38quotemstrBasically, I'm just used to the model of a lazy-list and a list being two very different data types, with an explicit call being required to transform the lazy list to a real list.
22:38KirinDavequotemstr: Well then, welcome to the future.
22:38KirinDaveSeq is a super-abstraction over all these types.
22:38quotemstrI'm not sure it's the future. :-)
22:38quotemstrIs it possible to distinguish between a variable bound to a list and a variable bound to a lazy-list?
22:38KirinDaveYes.
22:39quotemstrAh, okay. Thanks.
22:39KirinDavequotemstr: I suggest you fire up the repl and answer these questions yourself.
22:39quotemstrWhen it finishes building, I will. :-P
22:39KirinDaveBuilding?
22:41quotemstrThe macport had a bunch of dependencies. It's done now.
22:42tomojthere's a macport for clojure?
22:42tomoj:(
22:42quotemstrtomoj: Why not?
22:42KirinDaveWow, macports.
22:42KirinDaveHaven't heard that name in awhile.
22:42tomojwhy?
22:42clojurebotwhy not?
22:42KirinDavewhy ask why?
22:42tomojit looks like it's 1.0.0 anyway?
22:42KirinDaveDang come on clojurebot work with me here.
22:42quotemstrtomoj: It provides a unified way of managing software installation. The less I stick in /usr/local/stow, the easier it is to manage.
22:42quotemstrtomoj: 1.1
22:42tomojah, not so bad
22:43KirinDavequotemstr: So why does this bother you?
22:43tomojoh, the wrappers it installs look kinda useful
22:43tomojquotemstr: but, you don't need to stick anything in /usr/local for a standard clojure install
22:43tomojit's all project-local
22:44quotemstrKirinDave: I'd worry about evaluating happening when it wasn't expected.
22:44tomojevaluation will happen exactly when it needs to
22:44KirinDaveIn general that's not an issue.
22:45tomojbets on how long it will take quotemstr to realize that lazy seqs are beautiful? :)
22:45quotemstrtomoj: Sure, but then I need to add crap to $PATH and stick the clojure directory somewhere. I just wanted a repl, dammit. :)
22:45tomojno, you don't need to add anything to $PATH or stick any clojure directory anywhere
22:45tomojbut yeah, you'd have to set up a project
22:45tomojand those wrappers do look useful
22:46tomojtoo bad they're tied down to a system-wide version of clojure
22:46tomojwould be cool for a repl/clj command to look in ~/.m2 and allow you to pick the clojure version
22:47tomojyep, they should
22:48quotemstrHrm. Nifty.
22:48tomojquotemstr: can you map over both an iterator and a list (or whatever the equivalent is in python)?
22:49tomojI mean, mapping over an iterator would force evaluation, right?
22:49tomojer, no, I guess not
22:49tomojjust get another iterator back, I bet?
22:50quotemstrno, map always evaluates immediately. There's a separate function to construct an iterator from an iterator and a mapping function.
22:50quotemstrThen again, lazy sequences were bolted onto Python, so I'm not sure that approach is better.
22:50tomojthat doesn't seem.. inconvenient to you?
22:50tomojheh, yeah
22:50quotemstrIt seems less surprising, but that's because I'm used to Python and not Clojure. :)
22:51tomojthe seq abstraction is pretty fundamental here
22:51KirinDavequotemstr: Hopefully we can break you of that love.
22:51quotemstrWell, it's nice to be able to talk about a Lisp without being asked whether I can find the way back to my nursing home on my own.
22:51quotemstr:-)
22:52tomojI mean, we can do things like this:
22:52tomoj,(->> (map #(* % %) (range 10)) (filter even?))
22:52clojurebot(0 4 16 36 64)
22:52quotemstrOn the other hand, I have a horrible temptation to restructure my project's lisp to resemble Clojure instead of CL. :-)
22:53KirinDavetomoj: Funny thing happened in here the other day. Someone asked "What is the equivalent of ruby's detect?"
22:53tomojif the interfaces for lazy seqs and concrete sequential data structures were different, it seems like beautiful stuff like that would be uglier
22:53KirinDavetomoj: Which is a funny question. Suggests to me people have a hard time with laziness.
22:53tomoj(by "interface" I don't mean java interface, but the functions you can apply to these things..)
22:53clojurebot
22:54KirinDaveclojurebot: it is a lie
22:54clojurebotYou don't have to tell me twice.
22:54tomojKirinDave: I don't understand?
22:54KirinDavetomoj: Well how do you find the first item in a list that (conforms? x) returns true to?
22:55tomojclojure.contrib.seq-utils/find-first ?
22:55tomoj(first (filter ....)) I guess is what you're getting at?
22:56KirinDavetomoj: Yeah.
22:56tomojso the rubyist thinks the whole seq would have to be processed by filter, I guess
22:57KirinDaveWell I don't think he thought that directly.
22:57KirinDaveIt's more like, there is an inherent bias against that kind of thinking because people have a gut measure of cost for things like (filter ...)
22:57tomojyeah
22:58tomojI think I still sometimes felt a gut reaction against things similar to (first (filter ..))
22:58tomojs.felt.feel.
23:10quotemstrWhy is (let [foo 5] #'foo) an error?
23:10quotemstrVars only exist for dynamically-bound symbols?
23:11tomojvars only exist when you create them
23:11tomoje.g. with def
23:13quotemstrWhich corresponds to the invisible "value cell" in Common Lisp.
23:13tomojlocal variables don't vary
23:13quotemstrI forgot that detail. :)
23:45quotemstrWhy are send and send-off separate functions?
23:49technomancyquotemstr: sometimes you want a bounded thread pool, and sometimes you want unbounded
23:50technomancydepending on whether the work you're sending is IO-bound or CPU-bound.
23:50technomancysend-off is for IO-bound
23:50quotemstrtechnomancy: That's what the documentation says, but it'd be nice if the documented explained the difference in thread-pool model instead of just saying "A is for X and B is for Y".
23:51quotemstrOr better yet, Clojure could directly expose the thread pool to user code. :) (Maybe it does?)
23:51technomancyit does, but I don't know if it's documented
23:52technomancy,clojure.lang.Agent/pooledExecutor
23:52clojurebot#<ThreadPoolExecutor java.util.concurrent.ThreadPoolExecutor@613e0>