#clojure logs

2010-10-13

00:00amalloyhm. but just turning it into args# doesn't work because the scoping is different
00:01kmcand i solved it by doing an explicit gensym and splicing that
00:01amalloyyeah, you did. what was my clever solution? i said something neat, didn't i?
00:01kmcyeah, you moved the quotes and splices around
00:01kmcyou had something like ~x#
00:02kmcbut it didn't work in my situation
00:02amalloydamn. ~x# isn't working for me now, either
00:02amalloytime to go digging through the logs on my office computer, i guess
00:02kmc,`(x# ~@(`(x# ~x#)))
00:02clojurebotjava.lang.Exception: Unable to resolve symbol: x# in this context
00:03kmc,`(x# ~@(`(x# y#)))
00:03clojurebotjava.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.IFn
00:04amalloyah. the trick is you have to be still inside the outer scope; you can be in the middle of unquoting it
00:04clojurebotscope is at http://paste.lisp.org/display/73838
00:05amalloyargh. i want to tell him to shut up when he does that, but (i think?) that makes him stop responding to genuine ,(requests)
00:09kmcwhat sets him off?
00:09kmcalso clojurebot is male?
00:09amalloywell, hiredman made him. if you want her to be female, hiredman, just say the word
00:10kmci'm just curious because lambdabot is canonically female
00:10amalloyas for setting him off: god only knows. he has a set of words he knows, and sometimes he notices something you say and thinks it's relevant. sometimes he's right, sometimes he's not
00:10amalloywell, i haven't hung around in #lisp very much. maybe the lisp->clojure folks in here are secretly laughing at me all the time, i dunno
00:15notsonerdysunnygood morning Fellow clojurers! :)
00:16ohpauleezhey
00:16ohpauleez!
00:17ohpauleezAre we clojurers? clojurists maybe? Clojurinos?
00:17notsonerdysunny:)
00:17amalloyclojurians, i thought?
00:17ohpauleezah, yes, that's it
00:17notsonerdysunnyclojuredocs.org seems to be down
00:17ohpauleeznotsonerdysunny: not for me
00:20notsonerdysunnyhmmm
00:29amalloy,(let [[a & more] [1] [b & rest] []] [more rest a b])
00:29clojurebot[nil nil 1 nil]
00:29amalloyexcellent. thanks clojurebot
00:36kmc,(let [[a b c] []] a)
00:36clojurebotnil
00:37kmc,(let [[a b c] []] c)
00:37clojurebotnil
00:37TigerUppercutI don't know why, the same code in clojure and java was 35x more slow than java. That my calc to check 1mill numbers if is a perfect square
00:38TigerUppercutdoes it really happen?
00:38amalloyTigerUppercut: i think there are a lot of things you're doing less efficiently than you could be
00:40amalloyif efficiency matters, you might look into those
00:41calviniz
00:43erohtaramalloy: did you figure out your multi-pred issue?
00:44amalloyerohtar: mmm, i'm half-heartedly hacking on it at the moment. i think it ought to be a function rather than a macro, but it's proving a little awkward to write
00:45amalloyi can't find a way to do it without an explicit (loop), which feels way wrong to me
00:49tomoj,(letfn [(conjunction [& preds] (fn [x] (every? #(% x) preds)))] ((conjunction pos? integer?) 3))
00:49clojurebottrue
00:49tomojdoes that work?
00:50amalloy,(letfn [(conjunction [& preds] (fn [x] (every? #(% x) preds)))] ((conjunction pos? integer?) 'a))
00:50clojurebotjava.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.lang.Number
00:50amalloy,(letfn [(conjunction [& preds] (fn [x] (every? #(% x) preds)))] ((conjunction integer? pos?) 'a))
00:50clojurebotfalse
00:51tomojwas the original problem that order matters?
00:51tomojI came in late
00:51amalloyno, the original problem was that i was doing something eagerly
00:51amalloywhere every? is lazier
00:52amalloyi wrote this gross monstrosity, but yours is much better
00:54_rata__good night guys
00:54_rata__see you
00:55_rata__and thanks for all the help =)
00:55amalloytomoj: yeah, yours is perfect, aside from the implementation detail that i want &x, not x
00:55amalloyeven the name is better :)
00:56tomojI've wanted that function sometimes
00:57tomojwe have complement, but that's it
00:57amalloyyeah
00:57tomojdisjunction and conjunction aren't as useful I guess
00:57tomojactually..
00:57amalloyno, not quite as useful, but seems like they come up sometimes and might well belong in contrib?
01:00tomojs/actually..//
01:00sexpbot<tomoj>
01:00tomojI was thinking juxt could help but it's not lazy and makes it uglier anyway
01:00amalloyright. juxt was my first solution
01:01amalloyi've seen juxt applied cleverly so many times on #clojure that when i have an interesting problem the first thing i ask myself is "does this problem have anything to do with juxt?"
01:02tomojhaha
01:07amalloyanyway, conjunct (-ion seems too verbose for me) is quite handy. i'll have to put it into some kind of library for my other projects
01:09amalloyespecially now that i'm adding pre- and post-conditions on my functions to remind me where to look when i start using them wrong
01:11amalloytomoj, or anyone: how do you feel about writing (defn baz [[& foo] bar]) vs (defn baz [foo bar]) to clarify that foo should be a collection?
01:12hiredman,(doc refer)
01:12clojurebot"([ns-sym & filters]); refers to all public vars of ns, subject to filters. filters can include at most one each of: :exclude list-of-symbols :only list-of-symbols :rename map-of-fromsymbol-tosymbol For each public interned var in the namespace named by the symbol, adds a mapping from the name of the var to the var to the current namespace. Throws an exception if name is already mapped to something else in the current name
01:17amalloywhat's the keybinding in paredit to kill the sexp at point? C-k kills everything on the line, even after that sexp. i could go into the sexp, hit C-k, and then delete it, but that seems silly
01:18amalloyi guess going into the sexp and then hitting M-<down> isn't too bad
01:23amalloyalso, is there a function that combines quot and rem? i know i can use (juxt quot rem), but it seems like that's duplicating work for the computer
01:24replaca_amalloy: C-M-k?
01:24amalloyreplaca_: thanks, that's exactly what i was looking for
01:24replaca_cool
01:25replaca_that's not really paredit, just emacs
01:25amalloyoh, so it is
01:25amalloyi assumed that since C-k was rebound by paredit, so was C-M-k
01:25replaca_it will work in your python buffer, too, I think :)
01:26amalloyheh. php, more likely :(
01:26replaca_C-M-k already does the "right" thing
01:26replaca_oooh :(
01:26ohpauleezamalloy: juxt is the best solution I think
01:28amalloyreplaca_: i think paredit's C-k is useful sometimes, but C-M-k must be useful more often. maybe i should rebind
01:31replaca_well, C-k is standard emacs (and just slightly modified by paredit), so if you use emacs for other things, you might want to keep it
01:31replaca_but the beauty of emacs is that you can do what you want :)
01:41shachafamalloy: Why not #(any? (complement zero?) %) (or however you'd write that)?
01:42amalloyshachaf: that's basically the same as my original form - equally verbose, and equally correct
01:43amalloythe second form is much shorter and faster, and just as correct given that the seq is always two long
01:43amalloyand arguably easier to understand?
01:43shachafamalloy: Well, it's more general, so if it's as clear it's nicer.
01:43amalloyit's not more general than my original, is it?
01:43shachafamalloy: Nope. I prefer your original in principle. It's just an attempt to make that one clearer.
01:44shachafI don't know much about Clojure syntax (apologies for being an intruder here), but in Haskell "any (/= 0)" and "(/= [0,0])" are the same length.
01:44shachafI suppose which one is clearer depends on the context.
01:46amalloywell, i don't know much about haskell syntax, but it seems like there are some implied arguments in there?
01:46amalloyin clojure you could theoretically write #(take-whlile #(not= 0 %) %), except that you need % to mean two different things
01:47amalloyer, every? not take-while. getting projects mixed up. but you see what i mean
01:48shachafamalloy: Well, Haskell functions are curried (I hope the strict pedants don't beat me up for saying this :-) ).
01:48shachafamalloy: So perhaps it's not really a fair comparison.
01:49amalloyah
01:49shachafamalloy: I tend to feel silly when I do the opposite, though -- use a more specific form of a function than necessary.
01:50amalloyshachaf: well, i feel silly when i reinvent the wheel in a way that is clumsier than using the general case would be. i don't mind reinventing the wheel if i get a wheel that's actually better-suited to my current purposes
01:57notsonerdysunnyHello everybody, I thought describing the problem here may not give me enough space to do justice.. so I just sent it to the MailingList .. If anybody could help me .. with this http://groups.google.com/group/clojure/browse_thread/thread/ee283fa6af4f2bc8 it would be very nice of you
02:00amalloynotsonerdysunny: why is Variables a macro to begin with? just write it as a function and your problems seem solved?
02:00notsonerdysunnyamolloy is also a predifined macro available in a library
02:01erohtaramolloy: sorry, i had stepped away
02:01erohtaramalloy: what about this
02:01notsonerdysunnyI want to write it in such a way that Variable only get accessed at compile time since it is accessing mathematica ... and we cannot distribute mathematica along with our tool
02:01notsonerdysunnyamalloy: *
02:01erohtaramalloy: (defn multi-pred [& preds]
02:01erohtar (fn [x]
02:01erohtar (not (some #(not (true? (% x))) preds))))
02:02amalloyerohtar: it's cool, tomoj came up with a solution i liked earlier
02:02amalloysearch for conjunct in the logs if you wanna look at it
02:03erohtaramalloy: if you use every, will that short-circuit?
02:03amalloyyes
02:03kmcamalloy, i'm a pedant and i'm here to beat you up :D
02:03amalloyit's only juxt that won't
02:04shachafkmc: You mean me?
02:04kmcsure you too
02:04kmc:D
02:04amalloyhaha
02:04shachafkmc: Well... Haskell functions *are* curried in a sense. Even if not explicitly.
02:04amalloykmc: feel free to beat me up if i ever make an assertion about haskell, since it will be false
02:05kmcshachaf, sure, i mean if you really want the pedantic answer
02:05shachafkmc: The function that in Clojure would be :: (a,a) -> Bool is in Haskell :: a -> a -> Bool.
02:05kmccurrying is just a convention
02:05kmcthere's nothing in the Haskell language forcing you to curry, but the std lib and the syntax encourage it
02:05shachafkmc: Oh, that's not the type of beating-up I had in mind.
02:06kmcamalloy, Haskell is the set of all languages that do not contain themselves?
02:06amalloyi don't think my statement was *quite* a russell problem, but maybe it was
02:06kmcit depends on whether you consider the statement you made to be itself a fact about Haskell
02:07amalloyah, i see
02:07shachafamalloy: Do you think Haskell is worth learning?
02:08amalloyoh crap. i'd have fallen right in if you hadn't warned me
02:08amalloyor if your name were easier to type. i can never remember where the Cs and Hs are, and i end up hitting TAB five times while i try to figure it out
02:08kmctrap sprung
02:09kmcwhich pedantic objection did you forsee shachaf?
02:09amalloythis slows me down enough that you have time to warn me
02:09shachafkmc: Usually "currying" refers to the transformation of a function from (a,b) -> c to a -> b -> c.
02:10shachafkmc: So some people could say that as long as that transformation isn't explicitly applied, functions aren't curried.
02:10kmcah
02:10shachafamalloy: That's just because English is an awkward language.
02:10kmc*shrug*
02:10shachafkmc: This objection usually pops up when people refer to partial application as currying.
02:10kmcyeah
02:10kmcthat's wrong
02:10amalloynotsonerdysunny: you might look into apply-macro - i don't know if it does quite what you want, but it's basically a wrapper around using (eval)
02:10kmcbut i think it's okay to use the word "curried" to refer to any function which follows the curried convention
02:11kmcanyway, i've had this argument in #haskell :)
02:11hiredmanhaskell is useful because the type signature for bind isn't completely etched into my mind yet so I need lambdabot to remind me
02:11shachafhiredman: Unfortunately λbot is dead. :-(
02:11kmcnot, like, permanently
02:11kmcshe's just sleeping
02:12kmchiredman, you're using (>>=) in clojure or another language?
02:12shachafhiredman: Anyway, who needs bind? join/fmap/return is the True Way.
02:12amalloynotsonerdysunny: or, just don't put this code that returns a compile-time literal into functions - put them into compile-time literals!
02:12kmchehe
02:12hiredmanclojure
02:12kmccool
02:12hiredmanI am playing with writing a clojure compiler, which is just a big state monad
02:13kmchiredman, cool
02:15kmcit seems that Haskell and Clojure are technologically very different languages, but share a lot philosophically
02:15notsonerdysunnyamalloy: that was just a example ...
02:16amalloynotsonerdysunny: but if the data is known at compile time, you can factor it out to a compile-time literal; if it's not known at compile time, you can't apply a macro to it
02:16notsonerdysunnyamalloy: what I really want is the return value of (mathematica-eval "D[x*x,x]") which would calculate the derivative
02:16replaca_kmc: I think that they represent a lot of design choice made differently, but carefully, so all the parts fit really nicely
02:17kmcyeah
02:17notsonerdysunnyamalloy: the funcition could be more complex
02:17hiredmanhttp://github.com/hiredman/Archimedes/blob/master/src/Archimedes/compiler.clj is the front end and http://github.com/hiredman/Archimedes/blob/9da0f7cd3072f140573f678044176b884e968299/src/Archimedes/compiler/jvm2.clj is the backend
02:17replaca_kmc: a lot of us here in #clojure are big haskell fans
02:17kmcHaskell might be the only good committee-designed language
02:18replaca_maybe cause it's a (good committee)-designed language :)
02:18kmchehe
02:18kmci think it helps that they had no ambitions for more than like 100 people to use it
02:18kmcand that this was the case for the better part of a decade
02:19replaca_yeah. some academics trying only to unify their work
02:19notsonerdysunnyamalloy: the purpose is to use mathematica to generate the code for solution of PDEs which ofcourse is know at compile time.. If I want the solution for a different PDE then I would substitute the original one with a new one and recompile to get the code that solves the new PDE .. its just a experiment I am running .. I want to see how far I can take it
02:19kmcto try to be a bit more on-topic: i'm interested in Clojure's STM, and in comparing with (GHC) Haskell
02:19kmcam i correct that Clojure's STM is not lockless?
02:20replaca_it's lockless from the user's point of view
02:20replaca_but it's implementation involves locks
02:20amalloynotsonerdysunny: so it sounds like your data isn't known at *clojure* compile time, but only at *your-tool-here* compile time. what if you ran clojure in multiple passes? invoke mathematica, write the results to your clojure file, and repeat until you're satisfied with what's there
02:20amalloyor use eval to accomplish the same thing; but the code you deploy can't refer to Variables, so you need to rewrite it somehow before you can have "finished" clj files
02:21replaca_ooh, an apostrophe crime, sorry
02:21kmcright, i meant on the implementation side
02:21amalloyreplaca_: perhaps we should send you for a timeout in #english?
02:21replaca_no, not that! I recant!
02:21kmcGHC's STM is lockless and suffers from terrible performance at high contention
02:22kmcas threads step on each other and cause repeated retrys
02:22replaca_yeah, I'd be interested to see how clojure's does at high contention
02:22amalloykmc: clojure does the same thing, though i understand there are a couple optimizations to try to reduce the problem
02:22kmci'm interested in the idea of an STM implementation which introduces locking selectively at high contention
02:22kmcah
02:24replaca_it's interesting, since it's still a research area. I think we'll learn a lot from the Clojure version since I expect it to be used very heavily
02:24replaca_ok, time to zip off to bed. night all
02:26amalloykmc: found the part of JoC that discusses this STM issue
02:27amalloy(a) if a transaction has to retry N times (for some uninteresting N), it gives up and throws an exception
02:27amalloyi presume this gives you a chance to re-evaluate how you're using STM
02:28kmcyeah
02:28kmcseems like a useful performance-investigation tool
02:28amalloy(b) older transactions are allowed to "shut out" younger transactions temporarily, to give them a chance to complete
02:29tomoj<amalloy> erohtar: it's cool, tomoj came up with a solution i liked earlier
02:29tomoj*** freakazoid (~sean@2002:43b4:56b3:0:fa1e:dfff:fed9:2b0b) has quit: Quit:
02:29tomoj Leaving.
02:29tomoj<amalloy> search for conjunct in the logs if you wanna look at it
02:29tomoj<erohtar> amalloy: if you use every, will that short-circuit? [01:03]
02:29tomoj<amalloy> yes
02:29tomoj<kmc> amalloy, i'm a pedant and i'm here to beat you up :D
02:29tomoj<amalloy> it's only juxt that won't
02:29tomoj<shachaf> kmc: You mean me?
02:29amalloylol
02:30amalloykmc: those are the two points discussed in JoC, though i imagine if you looked through the java source you could find more points of interest
02:30kmcurk
02:30kmcwhere do i find this JoC of which you speak?
02:30tomojdid I stop the pasteflood?
02:30tomoj(did I start one?)
02:31amalloyyes, and yes
02:31amalloyi'm pleased to see you got over your tourettes to quickly, tomoj
02:31tomojhttps://gist.github.com/2e218a0600cf73d19472
02:31tomojthat's what I was trying to paste :(
02:31amalloykmc: http://joyofclojure.com/
02:32shachaftomoj: Get a smarter IRC client. :-)
02:32amalloywritten by our very own chouser (and fogus who occasionally graces us with his presence)
02:34amalloydon't go buying it because you want to learn more about the STM primitives, though; i parroted for you literally all of the information it contains
02:36amalloy(implementation-wise, that is. it has a good chapter about how to use them)
02:37kmcwould it be useful for learning the language? more so than online docs?
02:39amalloywell, JoC was the first clojure resource i really worked with
02:39amalloyi haven't read any of the others, so i can't do a good comparison for you
02:40amalloybut as i understand it JoC is less introductory, so as someone with functional-programming experience it's likely to be the one for you
02:41amalloyyou might also want to try labrepl, which is free and online. it's small, but it's hands-on and is useful for a few things
02:42kmccool
02:42kmci'm doing all right with the reference docs so far
02:42amalloyand now, i'm going to assume that the increasingly-louder yawns i'm emitting mean that it's bedtime
02:42kmc(and with asking annoying questions here)
02:42kmcsleep well :)
02:42amalloynight
02:43amalloyoh, and pester LauJensen when he gets here (he's in germany, so he can take over if you stay up late)
02:43amalloyor maybe he's in switzerland or something like that. whatever. european time
02:51lypanovlol
03:02LauJensenGood morning all
03:15kmchi LauJensen
03:24notsonerdysunnygood morning LauJensen
04:23ossarehwhat is a typical use case for constantly?
04:24hiredman(def always (constantly true))
04:24hiredmanif something is always, it's constantly true
04:25raekI don't use it very often. some functions like (swap! a (constantly x)) have alternatives for this case: (reset! a x)
04:25ossarehso in that case you are creating a var that can *never* be redefed?
04:26hiredmanno
04:26raekno, #'always contains a function, that when given any argument returns true
04:26hiredmanconstantly creates a function
04:26hiredman((constantly true) :bleh)
04:26hiredman,((constantly true) :bleh)
04:26clojurebottrue
04:27hiredman,(update-in {:foo 1} [:foo] (constantly 5))
04:27clojurebot{:foo 5}
04:28hiredmanmy favorite is (repeatedly promise)
04:29raekI think it's perhaps only useful when an API requires you to pass an update function and you want it to do the same thing no matter what it gets
04:29raekin other situations, there are most often another way of writing the code
04:29raeke.g. assoc-in instead of update-in, reset! instead of swap!
04:40tobiasraedermorning
04:45esjmornin' all
04:48tobiasraederhey esj :)
05:12LauJensenmorning all ya'll
05:20bartjLauJensen, morning!
05:29yayitsweiwhat's an idiomatic way to retry on error? currently using a (loop ... (if error recur))
05:35AWizzArdJava 6 Update 22 is out and contains some fixes for very serious bugs.
05:35AWizzArdhttp://www.oracle.com/technetwork/java/javase/downloads/index.html
05:38tobiasraederout of curiosity what fonts do all of you use for coding?
05:40LauJensenyayitswei: loop might be okay, depending on your scenario. A more stack-fragile approach would be (defn tst-retr [i] (try (/ 5 i) (catch Exception e (tst-retr (inc i))))) (tst-retry 0)
05:40LauJensentobiasraeder: (set-default-font "-bitstream-Bitstream Vera Sans Mono-normal-normal-normal-*-12-*-*-*-m-0-iso10646-1")
05:41_atotobiasraeder: (set-default-font "Inconsolata-12")
05:42AWizzArdLau, not Times New Roman??
05:42AWizzArd;)
05:44raektobiasraeder: Inconsolata <3
05:45raekDejaVu Sans Mono is also good
05:45bobo_real men use Windwings
05:45bobo_*wingdings
05:45raek(a superset of Bistream Vera Sans Mono)
05:45yayitsweiLauJensen: what's the stack-fragile part? the try/catch?
05:46yayitsweior the manual recursion
05:46LauJensenyayitswei: No, the calling of itself. It grows the stack
05:46yayitsweigotcha. thanks
05:46LauJensennp
05:46yayitsweiwhereas recur uses a form of TCO right
05:47LauJensenExactly
05:47yayitsweialso meant to ask you Lau, in your Compojure/Emacs intro on Vimeo, you have Compojure logging displayed in the inferior lisp buffer. I don't see that in my Emacs, do you have some special configuration?
05:48yayitsweigreat screencast btw I learned a lot
05:48LauJensenyayitswei: thanks. Yea you're probably using cake swank ?
05:48yayitsweiyep
05:48LauJensenyayitswei: alright, then my inferior-lisp, corresponds to your console output. I run everything within emacs using M-x swank-clojure-project
05:50yayitsweiok. but my console returns after the cake swank command, I think it runs in the background
05:50tobiasraeder@_ato how do you live with size 12 fonts? that seems so damn huge to me
05:51yayitsweiis there a log file that it appends to?
05:51LauJensenyayitswei: Actually I dont know, you should check in #cake.clj
05:51raekI use inconsolata size 12 too. emacs seems to have its own unit system for fonts...
05:51yayitsweiLauJensen: ah thanks
05:51tobiasraederim trying 10 right now and that seems the biggest size i can really stand
05:52raekI would say that size 12 in emacs corresponds to ~10-11 in the rest of the OS
05:53raekhrm, either that or Inconsolata size 12 is a bit smaller than <any other font> size 12
05:54raekupon more consideration, the latter seems to be the case
05:55LauJensenemacs handling of font sizes seem undeterministic. Some fonts are great at 13, but take up half the screen at 14. Some only change 1 pixel
05:58_atotobiasraeder: http://meshy.org/~ato/tmp/emacs.png
05:58LauJensen_ato: Can you send me your color theme?
05:58tobiasraeder_ato: i'd love that too
05:58tobiasraederand seems to be about the same size as my size 10 font, weird
05:59_atoyeah, maybe the DPI is wrong on my PC or something, I dunno. I just fiddle it until it seems right to me :p
05:59tobiasraeder^^
06:00_atocolor theme is just zenburn: http://github.com/ato/emacs-starter-kit/raw/ato/elpa-to-submit/zenburn.el
06:01_atoI darken the background slightly from the default zenburn though
06:01_ato(setq zenburn-bg "#1f1f1f")
06:01_ato(zenburn)
06:02LauJensenzenburn is nice, but you have do run (zenburn) (zenburn) for all of it to work... Little to bright on the bg though
06:02LauJensenah ok, you just said that .. :)
06:02LauJensenperfect, thanks to
06:02LauJensenato
06:03LauJensenIs there a Ring middleware for parsing the parameters of an Ajax POST request?
06:05tobiasraedersince im such a clueless person, how do i integrate the color theme into emacs?
06:06tobiasraederwithout using the complete starter kit ;)
06:06LauJensentobiasraeder: put that file somewhere on your load-path, like ~/.emacs.d, then (require 'zenburn) (setq zenburn-bg "#1f1f1f") (zenburn) (zenburn)
06:06tobiasraeder@LauJensen thanks
06:06LauJensenor make a new folder if you like and do (add-to-list 'load-path "~/.that-folder") first
06:07raekLauJensen: are there any differences between an "Ajax POST request" and an ordinary POST request?
06:07LauJensenraek: Yes, the body comes as a stream
06:07LauJensenso both multipart-params and -params dont try to process it, even if it just contains "x=2"
06:08raekI see... then I don't know :)
06:20yayitsweijust tried zenburn and I like the color scheme better. however I can't see my params helper anymore. any suggestions?
06:22lypanovanyone know a good testing framework for js that can be run from command line via eg rhino?
06:22yayitsweiclarification- I can't see little marker that appears briefly over a corresponding paranthesis using zenburn
06:22lypanovah, jspec. *tries it*
06:23_atoyayitswei: hmm, it's works for me
06:23yayitswei_ato: could it be because I'm using aquamacs?
06:24_atoI also use the paren-dimming stuff from the starter-kit, I doubt that'd cause the paren matching helper thing to break though http://github.com/ato/emacs-starter-kit/blob/ato/starter-kit-lisp.el
06:25_atoyayitswei: try M-x show-paren-mode
06:25_atowhich should toggle it on or off
06:25yayitsweithat's good to know. but it _was_ enabled
06:27mrBlissHere's what my Emacs looks like http://mrbliss.blinkenshell.org/emacs.png
06:27_atoyayitswei: I assume you've tried restarting emacs? I sometimes find after changing themes a few times the colours get messed up, presumably because not all themes set all the faces
06:29_atoyayitswei: these some docs here on how to set the color show-paren-mode uses, you could try setting it explicitly: http://www.emacswiki.org/emacs/ShowParenMode
06:31yayitswei_ato: thanks, just tried restarting emacs and I'm getting "Cannot open load file zenburn" so I'm investigating that
06:50yayitswei_ato: no errors now (thanks for the restart advice), but the background color doesn't change until I eval (zenburn) manually. any thoughts?
06:54_atohmm.. only thing I can think of is that something later in your config might be overriding it
06:55_atoI just literally have (setq zenburn-bg "#1f1f1f") (zenburn) at the top of my config: http://github.com/ato/emacs-starter-kit/blob/ato/ato.el
06:56_ato(the file gets "required" automatically by starter kit, but I used to use a non-starter-kit emacs config and that was basically the same plus the require)
06:56notsonerdysunnyscheme macros are supposedly more hygeinic .. is there a that would describe the difference from the lisper/clojurians perspective
06:58yayitswei_ato: well I'll keep poking around. thanks for your help
06:59shanmuHi there, is there a clojure build tool which can do db-migrate stuff like rake (essentially, I am exploring for possibilties where I can maintain db objects/version them etc using clojure code)
07:02notsonerdysunnycake is clojure's rake .. I don't know anything beyond this or if it will address your problem ..
07:02notsonerdysunnyshanmu *
07:05shanmunotsonerdysunny: thanks! I saw cake, am using lein at the moment will think of migrating if it supports what I am looking for at the moment#
07:06shanmuIs there any best practice/idomatic ways for maintaing db schemas using clojure?
07:06_atonotsonerdysunny: you know how in Clojure macros you use a trailing # on symbols? Like this: `(let [foo# ...] ...)
07:07raeknotsonerdysunny: Scheme has a special expression rewriting language that Scheme macros are written in. In Lisps (including Clojure), macros are written in Lisp code.
07:07_atothe "foo#" symbol will be replaced with a automatically generated name so it doesn't collide with anything called "foo" in the surrounding code it's expanding into
07:09_atoAs I understand it hygenic macro systems try to make it impossible to collide symbols like that. Clojure is sort of semi-hygenic, the idiomatic way of writing macros means it's easy to avoid symbol capture, but you can capture if you want to (useful in some obscure cases)
07:09raeknotsonerdysunny: in Lisp macros it is also possible that "symbol capture" can happen
07:10raeknotsonerdysunny: for example, a macro generates a let form that binds variable y and wraps some code. if that wrapped code contains y, things break...
07:12raeknotsonerdysunny: Clojure elegantly solves this in most cases by letting syntax-quote resolve all symbols into fully qualified var names and providing the foo# gensym mechanism
07:12LauJensenyayitswei: did u fix your zenburn issue?
07:15yayitsweiLauJensen: but I still can't figure out why my paren helper is broken. I'm shelving it for now (unless you have any ideas (: )
07:15raek(in most cases, since Clojure allows you to do unhygeinic macros if you want to: (defmacro evil [body] `(let [~'x 1] ~body)) )
07:15LauJensenIf you got show-parens on, and its not working, try evaling the theme twice, or try a known good theme bfore zunburn
07:17serp__,(+ 1 2)
07:17clojurebot3
07:18yayitsweiLauJensen: zenburn's my first theme
07:18LauJensenyayitswei: You might want to install color-themes from ELPA then
07:19yayitsweiLauJensen: Ok- will try that tomorrow, thanks. It's late here in Cali!
07:20LauJensenalright :)
07:27notsonerdysunnythanks _ato and raek what you described clarifies things quiet a bit.
08:20tobiasraederwhen you have a backtick quoted form is there a way to just create a symbol? (like 'mysymbol) would normally?
08:20tobiasraeder*(like 'mysymbol would normally)
08:21pdk,`(1 ~'mysymbol)
08:21clojurebot(1 mysymbol)
08:21pdkhmm
08:21pdk,`(1 mysymbol)
08:21clojurebot(1 sandbox/mysymbol)
08:22tobiasraederyeah i dont want it to be resolved
08:22tobiasraederbut the first thing looks good
08:22tobiasraederyeah works as i need it
08:22tobiasraederthanks a ton :D
08:24tobiasraedermhm maybe not
08:24tobiasraederokay, its a bit more complicated but thats the problem caused by my code i think
08:28raektobiasraeder: what does your code do?
08:29raek(unresolved symbols in macros are used pretty rarely)
08:33pdkisn't there an equivalent to gensym for this
08:34chouser,(gensym)
08:34clojurebotG__10167
08:35raeka symbol suffix that causes it not to be resolved? I'm not aware of such a thing.
08:35chouser`foo#
08:35chouser, `foo#
08:35clojurebotfoo__10168__auto__
08:36chousertobiasraeder: most of the time when you need an unresolved symbol you should use getsym or foo# Using ~'foo is usually an indication you're doing something tricky (or wrong)
08:37fhdHi. How can I get a specific key from a map if I have the string? e.g. (let [m {:foo "Foo" :bar "Bar"} k "foo") ...?)
08:37bobo_,(keyword "foo" {:foo "nils"})
08:37clojurebotjava.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to java.lang.String
08:37fhdI forgot an ] after "foo"
08:37bobo_ah
08:37bobo_bah
08:37pdk,(symbol "foo")
08:37clojurebotfoo
08:37Chousuke,(keyword "foo")
08:37clojurebot:foo
08:37pdk,(keyword "foo")
08:38clojurebot:foo
08:38raek(a suffix -- let's call it ¤ -- such that `(... foo¤ ...) is equivalent to `(... ~'foo ...), is what my answer was about)
08:38fhdThanks, I see what you're getting at :)
08:38fhdFirst time I saw a ClassCastException from a bot :P
08:38chouserraek: oh right. nothing like that. :-)
08:38fhdOr any exception for that matter
08:39fhd,("foobar")
08:39clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn
08:39fhdAwesome
08:40tobiasraeder@raek, chouser im still doing some pretty nasty java interop
08:40tobiasraederill look into getsym or use foo#
08:40chouserhm... java doesn't usually have any need for symbols of any kind, qualified or not
08:41tobiasraederits combined with generation functions for deftype, alot of functions
08:41tobiasraederand the function names for example are symbols, atleast thats what it looks to me
08:41tobiasraeder*generating
08:42tobiasraederor am i getting that wrong?
08:43_atoyour macro expands into (deftype foo ... SomeInterface (method [...] ...)) and you need to make sure the "method" symbol is unqualified?
08:43_atothat seems like an OK use of ~' to me
08:44_atomight be easier to implement using extend though
08:44chousertobiasraeder: yeah, if you're generating named functions from some source other than the macro's caller passing them in directly, it's likely you'll need something like this
08:44tobiasraeder@chouser yeah thats what i have to do :/
08:44tobiasraeder@_ato how do i implement them using extend?
08:46_atotake a look at the doc-string for the "extend" function
08:46_atoit may or may not make it easier
08:46_atomight be able to avoid macro for some stuff and just write regular functions, depends on what exactly you're doing
08:47tobiasraederill look into it, thanks
08:48_atoah wait.. looks like it only works with protocols, not interfaces
08:48_atosorry my bad ;-)
08:48tobiasraederokay :D
08:48jarpiaintobiasraeder: http://onclojure.com/2010/02/23/generating-deftype-forms-in-macros/
08:49tobiasraeder@jarpiain ill look into it
08:49_atobeware that post describes a prerelease version of deftype with slightly different syntax though
08:49tobiasraederk
08:51esjtobiasraeder: at one point I used a macro to do a deftype: http://gist.github.com/448759
08:52esjbut it might be a simpler scenario than yours
08:52tobiasraeder@esj not really simpler, just a gazillion less methods ;)
08:53tobiasraederhow do i type hint the functions im implementing? the interface offers 3 functions with different types of parameters but the same name/amount of parameters
08:53tobiasraederseems like im not getting it right
08:54chouserif you hint anything, you have to hint everything for that method, including the return value
08:55tobiasraederthat might be the problem
08:57tobiasraedersay i want to implement a method with the following signature public void doStuff (String arg0, Object arg1, Object arg2)
08:58tobiasraedermy try was (deftype mytype [] MyStupidInterface (^Void/TYPE doStuff [this ^String arg0# ^Object arg1# ^Object arg2#] (println "random stuff"))
08:59tobiasraederbut it tells me it cant resolve classname Void/TYPE which makes sense since its a type and not a class, anyone got a suggestion?
09:01tobiasraederokay its just void not Void/TYPE and it works.
09:12fhdHow can I convert a list to a vector?
09:12chouservec
09:13chouser,(vec (list 8 6 7 5 3 0 9))
09:13clojurebot[8 6 7 5 3 0 9]
09:13fhdchouser: Hm, I thought that was a shorthand to "vector". It isn't.
09:13jfieldsis there a fn that (x odd? [1 2 3 4]) ;=> [[1 3] [2 4]]
09:13jfieldswhat is x?
09:14chouserfhd: right. vec is a bit like set and seq, in that it takes a collection not a series of args
09:15chouserwhile vector is like hash-set, list, hash-map, etc.
09:16chouserjfields: x is (juxt filter remove)
09:16jfieldsthanks chouser
09:16chousernp
09:27lpetitjfields: or it could be #(reduce (fn [[t f] e] (if (%1 e) [(conj t e) f] [t (conj f e)])) [[] []] %2) :)
09:27lpetit,(#(reduce (fn [[t f] e] (if (%1 e) [(conj t e) f] [t (conj f e)])) [[] []] %2) odd? [1 2 3 4])
09:27clojurebot[[1 3] [2 4]]
09:28chouserlpetit: is that just to get vectors?
09:29lpetitchouser: no, it's a horribly not time-tested premature optimization attempt to not traverse the list twice.
09:30chouserheh. ah.
09:35fhdIs there a function in Clojure that I can use to create a map from a list? Something like "map"? Here's an example: http://paste.lisp.org/display/115491
09:36esj,(into #{} (1 2 3 4 5 6))
09:36clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
09:37esjboooo
09:37esj,(into #{} '(1 2 3 4 5 6))
09:37clojurebot#{1 2 3 4 5 6}
09:37esjha !
09:37kryftesj: Serves you right for trying to call 1!
09:37chouser,(let [s '(1 2 3)] (zipmap s (map #(str "Number: " %) s)))
09:37clojurebot{3 "Number: 3", 2 "Number: 2", 1 "Number: 1"}
09:38fhdchouser: wow that looks tough, give me a second...
09:38chouser,(into {} (for [n [1 2 3]] [n (str "Number: " n)]))
09:38clojurebot{1 "Number: 1", 2 "Number: 2", 3 "Number: 3"}
09:39raekfhd: map + anonymous function is often more simply written with 'for'
09:39chouser,(reduce #(assoc %1 %2 (str "Number: " %2)) {} [1 2 3])
09:39clojurebot{3 "Number: 3", 2 "Number: 2", 1 "Number: 1"}
09:39fhdraek: I'll try that, didn't know for
09:39fhdraek: I was kind of looking for a map version of "map" :)
09:39lpetitchouser: one more, one more ! :-) (you didn't show the version with transients :-p )
09:40chouserlpetit: into uses transients. :-P
09:40lpetitchouser: cheat
09:40chouserheh
09:41chouser(let [s [1 2 3]] (apply array-map (interleave s (for [n s] (str "Number: " n)))))
09:41chouser,(let [s [1 2 3]] (apply array-map (interleave s (for [n s] (str "Number: " n)))))
09:41clojurebot{1 "Number: 1", 2 "Number: 2", 3 "Number: 3"}
09:42raekfhd: a version using into and for: http://paste.lisp.org/display/115491#1
09:42lpetitit's kind of a complement to the golf game. Start with the tiniest version, expand to the largest one :-)
09:42chouserhehe
09:42esj:)
09:42fhdraek, chouser: Nice, thank you. I like (for a lot :)
09:42raekfhd: but since you don't do anything with the keys, zipmap might be more elegant
09:43chouser,(apply merge (for [n [1 2 3]] {n (str "Number: " n)}))
09:43clojurebot{3 "Number: 3", 2 "Number: 2", 1 "Number: 1"}
09:43lpetitNow please rhickey come in and show us how to abuse pods for creating a map from a list please :-)
09:43raekas chouser previously demonstrated
09:43fhdraek: I actually do, in my real code :P
09:43chouserhm. zipmap could be most efficient, but it doesn't use transients.
09:44jfields,(apply assoc {} [1 2 3 4])
09:44clojurebot{3 4, 1 2}
09:44chouserinto+for seems like a nice option
09:44fhdchouser: I'm going to have nightmares tonight for sure :) But nice to see 100 ways to solve this.
09:44chouserfhd: ok, I'll try, but 100 is a lot...
09:44fhdchouser: :P
09:45raekzipmap has a simplistic appeal if the keys and vals are processed isolated from each other
09:46raekinto+for is perhaps more elegant if the computation of the new key and val pairs share some part of the process
09:47fhdraek: That's the case for me. I'm actually iterating through a list of files and then saving them in a map, filenames as key, content as value
09:48fhdraek: Tried to use zipmap for that, but it was a nightmare
09:48fhdraek: The filenames are progressed too, in fact.
09:49fhdWhat does #{} do btw? I've done it like this: (into {} ...) and it works fine.
09:50raek#{} is the literal syntax for sets
09:50raek(contains? #{:a :b :c} :a)
09:51fhdraek: Okay, thanks.
09:52raeknp :)
09:56lpetit,(contains? [4 5 6] 1)
09:56clojurebottrue
10:04fhdWhat do you use for constants BTW? (def ) or something more fancy?
10:06lpetitdef or defonce
10:10AWizzArdA def- and defonce- would be useful.
10:11AWizzArdAnd a defconstant and defconstant- too.
10:11chouserI like ^:private
10:16lpetitchouser: so who's doing the foreword of JOC, finally ?
10:16chouserlpetit: oh, it's going to be great!
10:16chousergotta run. bbl.
10:16lpetitchouser: I've had another idea ...
10:16lpetitchouser: run coward, run :-)
10:52bartjcan anyone please tell the difference between the "package" keyword in Java and the "ns" function in Clojure
10:53bartjpackage generally doesn't include the class name
10:53Chousukethe package keyword doesn't do much
10:53bartjbut while specifying the Clojure class name using the ns function, the class name seems to be included
10:53Chousukens actually creates a namespace object
10:54ChousukeIt's not really a clojure "class". It's a namespace.
10:54bartjChousuke, I am mostly concerned with the class-name definition
10:54ChousukeI suppose I should just say they're completely unrelated :P
10:56ChousukeClojure namespaces just become named classes if you use gen-class
10:57Chousukewith the last segment of the namespace determining the class name, and the previous ones the packae
10:57Chousukepackage*
10:58bartjChousuke, thanks!
12:09Licenserthis sounds bad: clojure.core/unquote-splicing
12:17lpetitLicenser: huh ?
12:17Licenserlpetit: never mind the bug was 50 cm infront of the screen ;)
12:18lpetitok, cu
12:18Licenser:)
12:54jfieldsopinions? which is better? http://paste.lisp.org/display/115505
12:55ohpauleezas long as app-name is always constant, #2
12:56kotarakDunno which is "better", but I'd prefer #2
13:18LauJensen#2
13:22amalloyreally? i like #1
13:22raekthe voting is till open? :) the I'd pick #2. maybe with defvar- instead of def
13:22LauJensenamalloy: I dont like using let to bind something to the global scope
13:22raek* still, then
13:23amalloyLauJensen: i guess that's true. i think i read the intro to LoL too recently
13:23jfieldsso no real benefit, it's just a personal pref?
13:23raekI most often put helper functions and magic numbers in private vars
13:24jfieldsis there a clojure "standard"?
13:24ordnungswidriganybody here with experience in implementing TSP and m-TSP, and derived problems?
13:24LauJensenamalloy: lol? Lord of Lisp
13:24raekthat way I can access them in my tests
13:24LauJensen?
13:24raekLauJensen: was that questionmark pointed at me?
13:24LauJensenyea
13:24LauJensenno
13:25KirinDaveHa.
13:25LauJensenpointed at amalloy
13:25LauJensensorry
13:25LauJensenlittle tired today :)
13:25ordnungswidrigheisenmark
13:25raekyou're not the only one... :)
13:26ordnungswidrigoh, bbl. sorry guys
13:26LauJensenhe just remembered he needed to go get more sleep
13:27KirinDave /me grumbles.
13:27raekcold + Programming Theory homework...
13:27KirinDaveNews.ycomb is such a trashy hacker news outlet now.
13:27LauJensenKirinDave: yea I never read it, except when they commit half a day to flaming me, then I try to keep up with the fun :)
13:28KirinDaveLauJensen: For a short while it was nice.
13:30LauJensenKirinDave: I think its hard to keep a community which is above 500 people. Would be nice to see some smaller groups ala #clojure
13:31KirinDaveThere is a special threshold for sites like that
13:31KirinDaveToo small and the low volume keeps it from being worthwhile. Too high and you start to get node.js assholes demanding that you learn javascript because it's the best™.
13:32KirinDaveE.g., http://news.ycombinator.com/item?id=1786161
13:32KirinDaveThat guy.
13:33KirinDave"I know javascript. What more do you want? I have *code to write!*"
13:33LauJensenwoot? Ive never heard of anything such thing from the node.js community
13:33KirinDaveLauJensen: Then you are not listening to the wretched masses.
13:33KirinDave"Write once, never rewrite for scale"
13:33LauJensenKirinDave: Yes I am, when they flame me :)
13:33LauJensenThough I haven't taken any shots for not using node.js yet
13:34KirinDaveI ahve.
13:34KirinDaveAnd I don't really have a public presence the way you do.
13:34LauJensenWell. Node.js still looks cool, its on my list of things to play with
13:34KirinDaveBut really, it's depressing to watch as people seem to forget _why_ they're doing what they're doing.
13:34KirinDaveIn that Lua thread, someone immediately asked, "Is there a framework for writing asynchronous servers with Lua?"
13:35KirinDaveWhich is just painful.
13:35LauJensenhehe
13:35KirinDaveSynchronous, asynchronous, who cares? The right question is, "Is there a good framework for writing servers?"
13:36LauJensenKirinDave: So you're saying you dont care about the differences?
13:36KirinDaveI suppose that the node.js masses have enough cargo-culting rubyists that this kind of nonsense was inevitable.
13:36KirinDaveLauJensen: I do care about the differences.
13:36KirinDaveIf I can write threaded servers, I'd prefer to. The code is much more natural.
13:36KirinDaveBut I can and did write huge async stuff.
13:36KirinDaveLauJensen: Did you ever see that epic ruby conversation I posted once?
13:37KirinDaveIt made the rounds.
13:37LauJensenNo, please share
13:37KirinDaveLauJensen: http://kirindave.tumblr.com/post/24570389/incredibly-stupid-people-on-freenode-ruby
13:37LauJensenwow, you really are harsh
13:37LauJensenDid you at least blur their names or something?
13:37KirinDaveLauJensen: Read the log.
13:37KirinDaveNo
13:38KirinDaveread the log tho.
13:38KirinDaveI usually ablate my ire somewhat.
13:38KirinDaveNot in this case, I still feel good about calling these people out.
13:38LauJensenOkay I'll read. Just the other day I said "Hey, I think this can be done better" and I got flamed for the better part of 4 hours, so Im assuming you'll take some heat for that URL as well :)
13:38KirinDave"because of closures, and scope"
13:38KirinDaveThats what my friends use to put each other down when we're talking out of our asses. :)
13:39KirinDaveSeriously, read the transcript. It's pretty amazing.
13:40_fogus_"I was under the impression that ruby was a garbage collected language." <-- best line ever!
13:40LauJensen"kirindave: the most common reason for "leaking" is, it's not really leaking, there is a loop, and, I know this doesn't sound right, but please trust enough to try it... you have to paste the inside of the loop into a method, and just call the method from inside the loop, without doing any work inside the loop that isn't in a method " epic memory leak fix
13:40KirinDave_fogus_: It was like talking to Moai heads.
13:41KirinDaveLauJensen: Irony tho, he was right.
13:41LauJensenYea I fugred
13:41LauJensenFigured!
13:41KirinDaveThe bug was that ruby 1.8.4 had an optimization for purely functional calls.
13:41_fogus_KirinDave: You mean those things on Easter Island?
13:41KirinDave_fogus_: yes
13:42KirinDaveIt'd share a pre-allocated stack frame. The regex compiler pushed data into the local context with the assumption the stack frame would get collected.
13:42KirinDaveAnd if you did this twice in these methods, the pointer would just get overwritten and lost to the collector.
13:42LauJensenKirinDave: You seriously think those guys were stupid in that conversation? I thought they were very helpful and accurate in pinpointing the problem, despite that the fact that you walk in there with an attitude
13:42KirinDaveLauJensen: Oh they were incredibly stupid.
13:43zaphar_psKirinDave: at least you've brightened my day a little with that link :-)
13:43KirinDaveRubyPanther was correct the way any clock-shaped-object is right twice a day.
13:43KirinDaveHe's not even a whole clock, just a child's scribble of two intersecting lines.
13:43KirinDaveLauJensen: And his fix wouldn't work.
13:43KirinDaveThe fix was to put x = 1 at the top of the method.
13:43LauJensenCalm down buddy, you're backbiting against someone who actually tried to help you
13:43KirinDaveThis told the ruby interpreter to make a new stack frame. :)
13:44KirinDaveLauJensen: Isn't this the party where you go, “Problem?” :)
13:44LauJensenI dont think so :)
13:45KirinDavePart of interacting with people in a technical sense is realizing when you're out of your depth.
13:46KirinDaveFor example, if I began to lecture Chouser on how to do a bunch of clojure implementation shit out of my ass and then said, "But I am trying to help!" My intentions might be great, but in reality I'm just wasting his time and wasting Chouser's.
13:46KirinDavezaphar_ps: Glad you liked it.
13:46zaphar_psKirinDave: the fix was to put x = 1 at the top of the method?
13:46KirinDaveLauJensen: They didn't argue how to fix it, they argued it *wasn't a memory leak.*
13:46zaphar_psthat seems kludgy
13:46KirinDavezaphar_ps: it was. a later release of 1.8.4 corrected the problem.
13:46LauJensenKirinDave: They were right though ? It was an implementation of Ruby itself that leaked
13:47KirinDavezaphar_ps: But we had cod eot ship.
13:47KirinDaveLauJensen: They were arguing it wasn't a leak.
13:47KirinDaveBut rather expected behavior. Since we fixed the leak, I suspect I was right and it was not desired behavior.
13:48LauJensenKirinDave: Well, its difficult to reason about 'desired behavior' in Ruby
13:48KirinDaveThat may be true.
13:48LauJensenI guess if you want desired behavior, you should consider not using Ruby
13:48lypanov;)
13:48zaphar_psKirinDave: since it was fixed in a later release that would support your supposition as well
13:48KirinDaveBut it was pretty obvious it was a leak. If you ran the gc after every call, it wouldn't keep that memory around
13:48lypanovruby people don't like logic.
13:48KirinDavelypanov: Hey, i was a ruby person for years.
13:49LauJenseneww
13:49LauJensen:)
13:49_fogus_KirinDave: "The other reality you're facing here is your career. While it is gradually slowing, our field moves quickly. You need to be constantly studying and reading and learning to be any good at it at all. The reality is: grow and keep up or stop and be left behind." -- Couldn't have said it better myself.
13:49KirinDaveThere are smart dudes in the ruby community. They're just crowded by hangers-on and get-rich-quick folks.
13:49KirinDave_fogus_: Thanks.
13:49lypanovKirinDave: i joined #ruby in '00
13:49KirinDavelypanov: Oh dear, quite early.
13:49KirinDaveI was in 02.
13:49lypanovKirinDave: but rails killed everything that was ever good about it.
13:49KirinDavelypanov: Ha.
13:49technomancyKirinDave: you mean #ruby-lang?
13:49KirinDaveNo comment. I try to keep out of scuffles with DHH and the rails core team these days. I like Rick too much.
13:50KirinDavetechnomancy: In which context?
13:50KirinDavetechnomancy: In my post title, it was #ruby
13:50KirinDavetechnomancy: And I assumed he meant ruby-lang.
13:50technomancyKirinDave: the freenode channel is called #ruby-lang, maybe you got a crap answer because you were in the wrong channel? =)
13:50LauJensenhehe
13:50KirinDavetechnomancy: Oh no, #ruby exists. I was asking in #ruby-lang, too.
13:50LauJensenyea KirinDave, why does it say #php at the top? :)
13:50KirinDaveBut everyone who could help was out.
13:51KirinDaveDunno what it is now. This was in 2008.
13:51lypanov#ruby-lang has also been useless for a fair few years unless you have a rails q
13:52technomancyI quit that channel in 06 or so, it was high-quality-but-headed-downward around then.
13:52lypanovaye.
13:52KirinDavetechnomancy: I had largely withdrawn from everything but #caboose at that point, which is probably why i bothered to go into #ruby. Hadn't been burned yet.
13:52lypanovhttp://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/113779
13:52lypanovahhh memories
13:53KirinDaveha
13:53KirinDave"A new faster ruby... by christmas!"
13:53KirinDave-- Someone, 2004, 2005, 2006, 2007, 2008, 2009, 2010
13:54lypanovKirinDave: its... hard. :P
13:54KirinDaveHa.
13:54KirinDave;)
13:54KirinDaveI know.
13:57jjidoI am looking for an example of blowing the stack by using large data and recursion instead of just recursion.
13:58jjidodoes Clojure allocate on the stack?
13:58lypanovlarge data?
13:58lypanovany recursion unless its using proper tail call semantics will cause stack bloweruperage eventually
14:00jjidolypanov: yes a simple factorial function does it
14:01tomoj,(reduce #(map + %1 %2) (repeatedly 10 (fn [] (repeatedly 10 #(rand-int 100)))))
14:01clojurebot(602 429 369 459 410 504 604 499 498 383)
14:01rickmodejjido: Unlike for example C and C++, JVM languages do not allow stack allocation of variables within procedures - only with formal parameters.
14:01tomoj,(reduce #(map + %1 %2) (repeatedly 10000 (fn [] (repeatedly 10 #(rand-int 100)))))
14:01clojurebotEval-in-box threw an exception:java.lang.StackOverflowError
14:02rickmodejjido: and those formal parameters are either primitives (like int, long, double) or a pointer (reference)
14:02jjidotomoj: thank you
14:02tomojdunno if that counts
14:02amalloyLauJensen: sorry, was in a meeting. Let over Lambda
14:02KirinDaveLoL is a rad book.
14:02tomojit causes the lazy seqs to be realized in a way that blows the stack
14:02KirinDaveI can still only understand about 2/3 of it, after 3 reads.
14:02tomoj,(reduce #(vec (map + %1 %2)) (repeatedly 10000 (fn [] (repeatedly 10 #(rand-int 100)))))
14:02clojurebot[493931 495802 492457 493838 493937 499825 497226 499613 496431 498065]
14:03tomojwhereas that works
14:03KirinDavetomoj: Weird.
14:03tomojI thought so too at first
14:03tomojand again now, since I can't really remember this :/
14:04dnolentomoj: vec is strict
14:04tomojyeah
14:05KirinDaveI'd better read these wsdl files.
14:05tomojoh, I guess you end up with (map + (map + (map + (map + (map + (map + .....))))))
14:05tomojwithout the vec
14:25kryftO Matlab, how I hate thee. Let me count the ways..
14:39LauJensenbtw, Conj Labs Frankfurt is sold out, so keep your eyes on the website for the next event
14:40ohpauleezLauJensen: Do you do those solo or with cgrande?
14:40LauJensenohpauleez: Always with cgrand
14:41ohpauleezAh, awesome. (cgrand* I don't know why I always add the /e)
14:42shooverman, these clojure events are going to start needing bigger venues
14:42LauJensenYea he's a superb partner for this kind of thing.. or any kind of thing I guess :)
14:47jjidotomoj: I simplified your code
14:48jjido,(reduce (fn [a, b] (map + a b)) (repeat 10000 [1]))
14:48clojurebotEval-in-box threw an exception:java.lang.StackOverflowError
14:48jjido;)
14:49kotarakIs it possible to extend a protocol to arrays?
14:54_fogus_kotarak: LIke this? http://gist.github.com/624638
14:55kotarak_fogus_: Ah. Yes. I fiddled with (extend-protocol Foo ....) But there neither "[L..." etc. works
14:55kotarakMaybe strings for classnames should also be allowed?
14:55kotarakThey also work for types.
14:55kotaraktype hints, I mean
14:56_fogus_I could live with some sugar around the Class/forName thing
14:57kotarak_fogus_: Well, I consider ^"[Ljava.lang.String;" as sugar. (extend-protocol Foo "[Ljava.lang.String;" ...) could work similar.
15:01_fogus_I was thinking of sweeter sugar... but alas I have no better alternative.
15:12KirinDave_fogus_: Is that [[ a typo or necessary?
15:13_fogus_KirinDave: "[[" means 2D
15:13KirinDaveAh
15:14_fogus_"[[[" 3D etc...
15:14_fogus_It's a little DSL for Java arrays :p
15:14KirinDaveHaha. Domain specific lunacy.
15:16_fogus_KirinDave: Section 10.3 of JoC has more information. :-)
15:17KirinDaveI was reading that chapter on the train this morning.
15:19jjidoWhy does this work: (letfn [(later [& form] #(eval form))] ((later vector 1 2 3)))
15:19jjidoand this fails: (letfn [(later [& form] #(eval form))] ((later list 1 2 3)))
15:21Chousukejjido: try 'vector and 'list? :/
15:22raekjjido: hrm, not sure... but do you know about 'delay'?
15:22jjidoChousuke: yes that works
15:22jjidoraek: I need a function not a ref
15:24_fogus_,(letfn [(later [& form] #(do (println form) (eval form)))] ((later #(list % %2 %3) 1 2 3)))
15:24clojurebotDENIED
15:24_fogus_Grrr. Anyway, that worksa
15:24raek(defmacro make-thunk [& form] `(fn [] ~@form))
15:25jjidoraek: you guys are great at macros ;)
15:27raekhrm, why does the first example work?
15:27raek,(eval (list vector 1 2 3))
15:27clojurebotDENIED
15:28_fogus_This works also: (letfn [(later [& form] #(eval form))] ((later (var list) 1 2 3)))
15:28jjidois there a special meaning to "!" in the Lisp culture?
15:29jjidolist a special beast.
15:29ohpauleezjjido: In Clojure it means that it's destructive or will modify something
15:29jjidoalso cons
15:29ohpauleezlike set!
15:29jjidoohpauleez: and on its own? I want a short name for the later or make-thunk macro
15:30_fogus_jjido: Using the (var _) technique should work for anything
15:31ohpauleezjjido: Nothing comes to mind, but
15:31ohpauleezdon't quote me :)
15:31jjido_fogus_: (letfn [(later [& form] #(eval form))] ((later (var cons) 1 '(2 3))))
15:35_fogus_jjido: In that case the problem is elsewhere. '(2 3)
15:36_fogus_(letfn [(later [& form] #(eval form))] ((later (var cons) 1 '(list 2 3))))
15:36_fogus_This is why people think eval is evil
15:36jjidoisn't it? ;)
15:36_fogus_It is us who are evil. ;-)
15:49jaleyhey guys, does anyone know if there's a util function in leiningen (or anywhere) for launching processes with provided args, or will it probably be just as easy to use java APIs for this type of thing?
15:50dnolenjaley: do you want to shell out or something?
15:50jaleydnolen: actually I want to run a java tool
15:51dnolenjaley: yeah I believe Java has some process APIs
15:51jaleydnolen: with the same classpath as the leiningen process in fact: calling package.class.main() would be nice if it didn't call exit() :)
15:52dnolenjaley: I definitely don't much about doing that kind of thing, perhaps someone else can chime in.
15:52dnolens/don't much/don't know much
15:52jaleydnolen: thanks anyway, i'll probably just call exec() from java
15:53drewrc.c.shell-utils/sh is decent
15:53ordnungswidriganybody here, who know about TSP variations? Or optimization algorithms in general. I'm asking here because our beloved channel might attract those kind of people.
15:54jaleydrewr: ah cool - thanks for the suggestion, will look into it
15:59raekI think that has been moved to clojure.java.sh in 1.2 (the old one is still functional, of course)
15:59jaleyraek: found it in c.c.shell with no deprecation notes..?
16:00jaleyraek: unless i'm blind, which i am, but still can't see it
16:01raekI don't know why. maybe c.j.shell does not replace c.c.shell-utils completely
16:02jaleyraek: hmm.. looks extremely similar, i guess I should use the c.j version anyway
16:02jaleyraek: saves me a contrib dependency
16:03plathropIs lazytest broken or am I stupid? http://gist.github.com/624781
16:03jaleyanyone know if there are plans for a clojure.math (or equivalent) to tidy up the math and math-functions etc in contrib?
16:05jjidoplathrop: why the underscores?
16:06plathropjjido: The funtion I'm attempting to test, one of the tranformations it needs to do is convert CamelCase to camel_case
16:08plathropWhich it currently does by replacing #"[A-Z]" with (str "_" (lower-case c)) (where c is the matching character)
16:10plathropI plan on adding tests for that part too :-)
16:10plathropbut I thought I'd start learning lazytest with something simple like "all the characters in the results are lowercase"
16:14amalloy,(map #(Character/isLowerCase %) [\a \A \-])
16:14clojurebot(true false false)
16:14amalloyplathrop: ^^ seems to be why?
16:15amalloy,(map #(not (Character/isUpperCase %)) [\a \A \-])
16:15clojurebot(true false true)
16:17plathropamalloy: ah, thanks
16:17plathropwell... but why does it work at the repl?
16:18amalloyummmm, does it? i don't see that in your gist
16:18raekit's too bad that 'complement' has such a long name...
16:20dnolenraek: and too nice that renaming it is so easy :)
16:21amalloyyeah. i don't thhink composition is so much more command than complement that it's worth messing up abbrevs. compose+comp seems to make more sense than comp/complement
16:22_fogus_,(every? #(Character/isLowerCase %) (filter #(Character/isLetter %) "b-aa123&&b_b"))
16:22clojurebottrue
16:22plathropamalloy: It's the third section of the gist, scroll down.
16:22amalloyshachaf: if i were cleverer, i'd have found a way to use juxt to do both of my maps :)
16:23plathrop_fogus_: probably a better way of doing it, for sure. I'm just curious why it is different between REPL and command-line at this point
16:23_rata__hi
16:25_rata__how do I start a repl in vimclojure?
16:26_fogus_plathrop: difference in char encoding between one and the other? :-( I got nothing
16:26amalloyplathrop: i'm not sure either
16:29amalloyplathrop: you could try running just map canonicalize at the repl, see what the output is
16:29amalloyor (some (complement lower-case?) (map canon blah)) to see which some fails
16:31_rata__does anyone use vimclojure?
16:35raekplathrop: beware that jline (which leiningen uses/used for lein repl) breaks UTF-8... :(
16:35lypanov_rata__: thinking about it.
16:35raekplathrop: try to do (seq "string containing the interesting chars")
16:36raek,(seq "åäö")
16:36clojurebot(\å \ä \ö)
16:36_rata__lypanov, ah ok... haven't you used it yet then?
16:38lypanov_rata__: not yet no. but its sitting here in my directory waiting for me to use it.
16:40lypanovokay. gonna try it now.
16:40_rata__lypanov, hahahaha ok... tell me please if you get to run a repl inside a vim buffer :)
16:41lypanovshall.
16:41plathropOkay, thanks everyone
16:42plathropBig-time learning is fun
16:42raekplathrop: (explanation: the seq-of-string thingy is a test to check whether the terminal encoding and the repl encoding are the same. if they are not, the sequence will appear to have other characters than the string)
16:43lypanov_rata__: :ClojureRepl
16:46ohpauleezcool email on the list about the maybe-monad. Clean design, a little more verbose
16:46LauJensenohpauleez: link?
16:46_rata__lypanov, thanks
16:47ohpauleezLauJensen: http://groups.google.com/group/clojure/browse_thread/thread/8b77bece19b0bba0/c9960c69ca059ff6?show_docid=c9960c69ca059ff6
16:47LauJensenThanks
16:47_rata__but it doesn't work well for me... it tries to open the repl, but I get an error
16:49amalloyheh. almost like the link was to some malware that crashed LauJensen's computer
16:51_rata__what's nailgun?
16:51lypanov_rata__: you read the install instructions?
16:51amalloyclojurebot: nailgun?
16:51clojurebotI don't understand.
16:51_rata__this instructions? http://www.assembla.com/wiki/show/clojure/Getting_Started_with_Vim
16:52amalloyclojurebot: nailgun is http://martiansoftware.com/nailgun/
16:52clojurebotRoger.
16:52amalloygood boy. _rata__, see above?
16:53_rata__yes
16:53_rata__thanks
16:54amalloyactually this one's even better
16:54amalloyclojurebot: nailgun is http://www.ruby-forum.com/topic/186850#815956
16:54clojurebotYou don't have to tell me twice.
16:54amalloylol. very apt randomly-chosen ack there, clojurebot
17:17amalloylypanov: cake uses something nailgun-like; you could try using that
17:18lypanovamalloy: vimclojure needs nailgun itself so forcing it to work by repeatedly hammering it with a metal coated stick
17:19amalloylypanov: might be cheaper to get a regular wooden stick, but put a heavy, flat, metallic object on one side
17:20lypanovawesome. actually works.
17:20lypanovamalloy: my expensive metal plated stick really did the trick.
17:21amalloywell done. you should patent that
17:21arkhthis may not be the right place to ask, but I have a memory leak in some clojure/java/networking code and I haven't been able to figure out why: http://gist.github.com/624930
17:23KirinDavetechnomancy: Resist. :)
17:23KirinDavetechnomancy: But the joke is canonically, "Because of closures, and scope."
17:23lypanovyou have to put it in a method in a method in a method and then say "bazam" and it'll work.
17:23lypanovthats by design. you idiot.
17:23amalloyarkh: aren't you sending things to the agent faster than it can process them?
17:24plathrop"memory leaks don't happen in Ruby by definition" *facepalm*
17:24arkhamalloy: the listen() method blocks until it receives data
17:24amalloybut send-off doesn't
17:24lypanovobviously the guy was too young to have been around in '00
17:25arkhamalloy: it queues and sends fifo as its able
17:25lypanovin '00 ruby didn't have memleaks. it just crashed.
17:25amalloyarkh: but it has to hold that queue internally
17:25amalloyand you're filling it up super-fast
17:26arkhamalloy: it queues it internally, true, but the actually runtime environment has packets arriving pretty slowly
17:26amalloyagent: please do a billion things for me. take your time with each thing, it's no problem, but i need you to write down this list of a billion things right now so you can do them later
17:26arkh*actual
17:26amalloyright? that's essentially what you're doing
17:26arkhamalloy: yes
17:27arkhamalloy: it's kind of a quickie setup. I would ordinarily set aside a buffer with an upper-bound so it doesn't consume all memory
17:27amalloyright. well, that's why it's consuming all memory :P
17:27arkhis it??
17:28amalloyyou said the memory is leaking, right?
17:28arkhwhy wouldn't those objects get gc'ed?
17:28lypanovomgodz. i'm all repl-y and vim-y at the same time.
17:28arkhmemory is leaking, yes
17:28amalloybecause the agent isn't done with them yet
17:28arkhoh.
17:28amalloyit's falling out right there: creating an enormous to-do list for the agent, which it processes slowly
17:29arkhI guess I assumed agents would clean up their todo list as it was consumed. Not the case?
17:29hiredmanyou can use a future + a linkedblockingqueue
17:29amalloy(in fact an infinite to-do list, which you require the agent to realize all at once)
17:29raeka LinkedBlockingQueue can have an upper limit
17:29raekhttp://download.oracle.com/javase/6/docs/api/java/util/concurrent/LinkedBlockingQueue.html
17:29amalloyarkh: they do clean up as they're consumed. but you write them faster than it consumes them
17:29amalloysince as you say, the packets arrive slowly
17:30amalloyand since agents are coordinated, it can only do one task at a time; the rest are buffered in the to-do list
17:30arkhamalloy, hiredman, raek : thank you
17:30arkhamalloy: I guess I should have read the agent code : (
17:30hiredmanjava.util.concurrent is good, use what is in it
17:31amalloyyou probably don't want an agent at all. just (loop [] (do-my-packet-thing) (recur))
17:31amalloythen do-my-thing will block, and you're all set
17:31KirinDaveAgents seem widely misused.
17:31raekarkh: hrm, do you send-off upd-sends constantly? have you tried to let the upd-send function send itself to the agent?
17:31arkhI should do that for now - I just didn't want the read side blocked by the send side
17:31KirinDaveThey are more valuable for asychronicity than for bulk processing
17:31hiredmanI have to say, I almost never use agents
17:31hiredmanI use futures and queues and promises
17:32raeksomeday I will finish http://github.com/raek/stream-seq, a more clojur-y abstraction that includes blocking queues
17:32hiredmanI have an implementation of a blocking queue using promises
17:33hiredmanbut it was just for fun
17:33hiredmanlbq
17:33arkhSo agents can't be my asynchronous magic to sprinkle on my IO, huh? /s ; )
17:34lypanovyou need a +2 blade of Awesome Agency
17:34raekhiredman: similar to this? http://clj-me.cgrand.net/2009/11/18/are-pipe-dreams-made-of-promises/
17:34arkh... I still have much to learn
17:35raekarkh: I think they can be used (but perhaps not ideomatically) in your case too
17:35arkhlypanov: I need my Agent of the Mongoose with +8 queue length
17:35amalloyarkh: udp is pretty fast though, right? i mean, it's not like tcp where it might block for seconds
17:36arkhamalloy: it's something to process and relay syslog messages so the packets aren't coming in that fast
17:37amalloyarkh: so have one, blocking, listening process, and an agent for sends
17:37amalloythen you won't overflow the agent, and you can send without blocking on receive
17:37arkhraek: I do want to stick with what's idiomatic - still sometimes difficult to discern what is and isn't in clojure (when bending the guidelines becomes too much)
17:39raekwell, rhickey uses an agent whose transition function sends itself to the agent as a way of looping in another thread in his ants.clj demo
17:39arkhamalloy: I'll look into some non-agent options, too. I
17:39raek...probably why that solution pops up every now and then
17:40arkhraek: see? that's where I kind of got the idea it might be idiomatic
17:40hiredmanraek: mine was much simpler
17:41raekbut the ant agents actually keep state in them, so agents for ants seems motivated
17:41arkhhiredman: did you do an ants implementation?
17:41hiredmanno
17:41raekI think he was referring to his LinkedBlockingQueue implementation
17:41amalloy(def outgoing (agent nil)) (loop [incoming nil] (when incoming (send-off outgoing (fn [] (udp-send sender incoming)))) (recur (udp-listen listener)))
17:41amalloyarkh: something like that
17:42arkhamalloy: I'll check that out
17:42raekanyone have any comments on the examples on http://github.com/raek/stream-seq/, btw?
17:45raekI hade this idea of making all handling logic of request-response servers pure functions that take seqs of requests and return seqs of responses
17:46raekand that these handling logic functions could be swapped while the server is running
17:46raek(not only by redefining the functions)
17:47raekand a graph of pipes and filters could be built up from a DSL or something
17:49_rata__how do I check if an object is a ref? it can't find "ref?" or something like that
17:50amalloy_rata__: a hacky way would be to see if it's an instance of clojure.lang.Ref
17:51amalloy(or clojure.lang.IDeref if you're checking against all ref types)
17:51_rata__,(instance? (ref nil) clojure.lang.Ref)
17:51clojurebotjava.lang.ClassCastException: clojure.lang.Ref cannot be cast to java.lang.Class
17:51amalloy,(instance? clojure.lang.Ref (ref 1))
17:51clojurebottrue
17:51_rata__ahh... it was the other way around
17:51amalloy,(instance? clojure.lang.IDeref (ref 1))
17:51clojurebottrue
17:52_rata__ok, thanks
17:52raek,(map #(instance? clojure.lang.IDeref %) [(future 1) (delay 1) (promise)])
17:52clojurebot(true true true)
17:53raek,(supers clojure.lang.Ref)
17:53clojurebot#{clojure.lang.IReference java.util.concurrent.Callable clojure.lang.IMeta java.lang.Runnable java.lang.Object clojure.lang.AReference clojure.lang.IRef clojure.lang.ARef java.lang.Comparable clojure.lang.IDeref clojure.lang.IFn}
17:53raek,(supers clojure.lang.Atom)
17:53clojurebot#{clojure.lang.IReference clojure.lang.IMeta java.lang.Object clojure.lang.AReference clojure.lang.IRef clojure.lang.ARef clojure.lang.IDeref}
17:54_rata__and the best way to have mutually referencing objects is to use refs, right?
17:55amalloy,(map (juxt #(instance? clojure.lang.Ref $) #(instance? clojure.lang.IDeref %)) [(ref 1) (promise 1) (atom 1)])
17:55clojurebotjava.lang.Exception: Unable to resolve symbol: $ in this context
17:55amalloy,(map (juxt #(instance? clojure.lang.Ref %) #(instance? clojure.lang.IDeref %)) [(ref 1) (promise 1) (atom 1)])
17:55clojurebotjava.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$promise
17:55amalloy,(map (juxt #(instance? clojure.lang.Ref %) #(instance? clojure.lang.IDeref %)) [(ref 1) (promise) (atom 1)])
17:55clojurebot([true true] [false true] [false true])
17:55amalloymutter
17:55raekif the objects are mutable, then yes. you'll need to use a reference primitive (ref/atom/agent/var)
17:56amalloy_rata__: often you can instead use one atom around the whole group of mutally-referring objects
17:56amalloybut as raek says, if the objects are mutable that won't work
17:56_rata__no, objects need not be mutable
17:57amalloythen i think an atom is the preferable solution. it's certainly what *I* would prefer
17:57raekrefs are fine. you can use atoms if updating multiple references atomically isn't important
17:58amalloy,(let [x (atom [1 2])] (swap! x (fn [[a b]] [b a])))
17:58clojurebot[2 1]
17:59_rata__I need to read about atoms... I don't remember well what they are for
17:59plathrophrm. how best to trim the first character of a string...
17:59amalloythey're the simplest mutable type: they perform a single read/write atomically
18:00amalloy,(.substring 1 "hello")
18:00clojurebotjava.lang.IllegalArgumentException: No matching method found: substring for class java.lang.Integer
18:00amalloy,(.substring "hello" 1)
18:00clojurebot"ello"
18:00plathropnice
18:00plathropthanks
18:01plathrop,(subs "Hello" 1)
18:01clojurebot"ello"
18:01amalloy~source subs
18:02amalloyit just calls .substring, so use whichever makes you happier
18:02_rata__ok, but if I want to change later to use atoms, it's easy to refactor
18:02_rata__isn't it?
18:02amalloy_rata__: depends on whether you've chosen to depend on updating multiple refs
18:02amalloyif you have only one ref, it is very easy to change it to an atom
18:03_rata__amalloy, no, I have multiple mutually-referencing refs
18:05amalloyright. so then the refactor will basically be: define a new atom which is a seq of all the objects that are currently individual refs
18:05amalloyif you wanted to change
18:05amalloyif that's hard, or you often mutate some smaller subset of your refs, then stick with refs
18:06raek_rata__: atoms are just like refs, but more lightweight and without the transaction stuff
18:07raek_rata__: also, be sure to have discovered get-in, assoc-in and update-in (might be handy to know about)
18:08arkhraek: I like your vision of stream-seq
18:08plathropThese seems ugly to me. Is this the best way to do this? http://gist.github.com/625027
18:08_rata__amalloy, ok, thanks... I think I'll stick with refs for a while
18:09_rata__raek, yes, I commonly use assoc and assoc-in
18:09amalloyplathrop: yeah, i think you can do better
18:10amalloytry a single replace on #"(?<!^)[A-Z]"
18:10amalloythat should be the regex magic to say "don't match at the start of the string"
18:11erikcw1what is the preferred way to store project settings such as database logins and hosts so that they can easily be changed for production/testing? Property files, JSON, clojure?
18:11plathropamalloy: ooh. I didn't know that one
18:12zakwilsonplathrop: see ->
18:12amalloyplathrop: ?<! amd ?<= are very useful
18:12plathropzakwilson: that's hard to google for, got a link?
18:12zakwilsonplathrop: http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/-&gt;
18:12plathropamalloy: I presume ?<= is the opposite of ?<! ?
18:13amalloyyes
18:13amalloyA13aA4
18:13amalloys/(?<!^)[A-Z]/q/
18:13sexpbot<amalloy> A13qq4
18:13amalloyhm, sexpbot isn't case-sensitive, but you see how the lookbehind worked
18:14plathropyeah
18:14plathropthanks, amalloy
18:14Raynesamalloy: It's just a Java .replace. :p
18:14amalloys/(?i)(?<!^)[A-Z]/q/
18:14sexpbot<amalloy> hq, qqqqqqq qqq'q qqqq-qqqqqqqqq, qqq qqq qqq qqq qqq qqqqqqqqqq qqqqqq
18:14amalloyheh. worked
18:14amalloyor the opposite of worked
18:15amalloys/(?I)(?<!^)[A-Z]/q/
18:15ossarehI've stumbled on some code I think is interesting: http://github.com/somnium/congomongo/blob/master/test/congomongo_test.clj - on line 16 what is the :let and the :when on line 22 - does for really have some form of "when" clause?
18:15amalloyossareh: yes
18:15ossarehI need to read other people's code so much more than I do.
18:16ossareh,(doc for)
18:16clojurebot"([seq-exprs body-expr]); List comprehension. Takes a vector of one or more binding-form/collection-expr pairs, each followed by zero or more modifiers, and yields a lazy sequence of evaluations of expr. Collections are iterated in a nested fashion, rightmost fastest, and nested coll-exprs can refer to bindings created in prior binding-forms. Supported modifiers are: :let [binding-form expr ...], :while test, :when test. (
18:16amalloy,(for [x (range 10)] :when (even? x) x)
18:16clojurebotjava.lang.IllegalArgumentException: Wrong number of args (6) passed to: core$for
18:16amalloy,(for [x (range 10) :when (even? x)] x)
18:16clojurebot(0 2 4 6 8)
18:16ossarehwow
18:16ossarehthat kinda changes my life a little
18:16ossarehthanks amalloy
18:17amalloy,(macroexpand '(for [x (range 10) :when (even? x)] x)) ; now i'm curious
18:17clojurebot(let* [iter__4059__auto__ (clojure.core/fn iter__10443 [s__10444] (clojure.core/lazy-seq (clojure.core/loop [s__10444 s__10444] (clojure.core/when-let [s__10444 (clojure.core/seq s__10444)] (if (clojure.core/chunked-seq? s__10444) (clojure.core/let [c__4057__auto__ (clojure.core/chunk-first s__10444) size__4058__auto__ (clojure.core/int (clojure.core/count c__4057__auto__)) b__10446 (clojure.core/chunk-buffer size__4058__a
18:17amalloyhaha, changed my mind :P
18:18amalloyclojurebot: regular expressions?
18:18clojurebotHuh?
18:18zakwilsonList comprehensions aren't really part of my usual thinking yet. I'd have used filter there.
18:18amalloyclojurebot: regular expressions is http://www.regular-expressions.info/tutorial.html
18:18clojurebotIk begrijp
18:18amalloyclojurebot: regular expressions?
18:18clojurebotregular expressions is http://www.regular-expressions.info/tutorial.html
18:18zakwilson,(filter even? (range 10)
18:18clojurebotEOF while reading
18:18zakwilson,(filter even? (range 10))
18:18clojurebot(0 2 4 6 8)
18:19amalloyzakwilson: that's because filter is better there :)
18:19amalloybut i wanted to demonstrate :when
18:22plathropokay, so clojure.string or clojure.contrib.string or clojure.contrib.str-utils or clojure.contrib.str-utils2 ?
18:24raekplathrop: if you are on 1.2 and what you need is in clojure.string, then clojure.string
18:24plathropCool, thanks
18:24plathropWhen what I need isn't there?
18:24lypanovclojure with vimclojure is exactly what i thought ruby might well become 5 years ago and counting.
18:25amalloylypanov: well, you can't win them all. maybe one day it'll be like emacs instead :)
18:27lypanovamalloy: as i'm not a big fan of emacs, if it had become emacs like i'd not like it :)
18:27lypanovamalloy: so while i enjoyed the joke, logically speaking... ;)
18:28amalloyyes, i would be astonished if there were any vim users who wished things were more like emacs
18:28lypanovamalloy: you mean in clojure or vim?
18:28plathropSometimes I wish vim were more like emacs, sometimes I wish emacs were more like vim. Depends which I'm using at the time.
18:28amalloyoh, either
18:29lypanovamalloy: wrt vim, the vast majority of people i think wish for something even vaguely as good as elisp.
18:29zakwilsonFor non-critical (but not entirely experimental) stuff, do I want to be using 1.3 yet?
18:29lypanov(i just keep praying for a minimal editor with damn good lang integration, but been doing that for > 5 years and still no answer...)
18:30zakwilsonEmacs is minimal compared to the average IDE these days.
18:33lypanovzakwilson: from my perspective anything that i don't use is bloat so its got more to do with "can i easily turn it off. and is turning it off part of using it"
18:33lypanovthats what i'm waiting for.
18:33lypanovanyway. bed :) night *
18:33zakwilsonlypanov: doesn't every programmer eventually write an editor? Now may be your time.
18:47ohpauleezvimclojure + paredit.vim has been a blast for me as well
18:48ohpauleezThat said I use emacs for CL, but Clojure felt pretty natural in vim
18:48ohpauleezI think this is in part to lein
18:49ohpauleeztmux/awesomewm + leiningen + vimclojure/paredit.vim
18:57KirinDaveI wonder if yayitswei is going to show up...
18:58amalloyhe threatened to show up at your coffee thing, right?
18:59amalloyhey shachaf, i just reinvented the wheel in a silly way again, but this time in java
19:02Deranderossareh: me too
19:02Deranderohpauleez: does vimclojure have an repl mechanism?
19:02DeranderI learned emacs to do clojure dev, never did the vim side of things
19:02ohpauleezDerander: it does
19:02ohpauleezI rarely use it
19:02Derandermm
19:03ohpauleezI typical eval file or paragraph, doc lookup, and auto-complete
19:03ohpauleeztypically*
19:03Deranderyeah
19:03ohpauleezsometimes I macro expand
19:03DeranderI use the repl for testing out ideas.
19:03ohpauleezI have a running repl in another tile
19:03ohpauleezbut I don't use the repl via vim
19:04ohpauleezDerander: http://github.com/ohpauleez/net-ns/blob/master/README.md
19:04ohpauleezthere's a poorly formatted section about the vimclojure stuff I use
19:08Deranderohpauleez: thanks
19:09ohpauleeznp
19:10jjlIs there any better way to set global function across all namespaces? E.g in user.clj, (use 'clojure.contrib.repl-utils :only [show]). It works great in user=> when I call (show xx), but when I switch to another namespace foo=>, I have to do it again. It is annoying …
19:10_rata__thank you guys... see you later
19:12technomancyjjl: not really. it's sort of possible with ns-tools, but it's a bit awkward to set up. if you just want show, you're better off using slime-inspect (C-c S-i) in Emacs, presumably other tools have similar functions
19:14jjltechnomancy: thanks for your hint. But I am using vim and I want to use other functions more than show such as pst+ clj-stacktrace.repl
19:15jjlIs any better way to enable stacktrace all the time instead of only showing one line. After that, I have to (pst+) ...
19:42jjidocan you do a var from a 'name?
19:48jjido,(var 'first)
19:48clojurebotjava.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.Symbol
19:57jjidoAre there no more macro experts around?
20:00kmc,(eval 'first)
20:00clojurebotDENIED
20:00kmc;P
20:01jjidokmc: I tried (let [v (eval 'first)] (var v)), but it says v is not known
20:01kmcwouldn't (eval 'first) evaluate to a function?
20:02kmc,(var first)
20:02clojurebot#'clojure.core/first
20:04jjido,(let [v 'clojure.core/first] (deref v))
20:04clojurebotjava.lang.ClassCastException: clojure.lang.Symbol cannot be cast to clojure.lang.IDeref
20:04jjido,(let [v 'clojure.core/first] (deref (var v)))
20:04clojurebotjava.lang.Exception: Unable to resolve var: v in this context
20:12amalloy,(supers (var first))
20:12clojurebotjava.lang.ClassCastException: clojure.lang.Var cannot be cast to java.lang.Class
20:12amalloy,(supers (class (var first)))
20:12clojurebot#{clojure.lang.Settable clojure.lang.IReference java.util.concurrent.Callable clojure.lang.IMeta java.lang.Runnable java.lang.Object clojure.lang.AReference clojure.lang.IRef clojure.lang.ARef clojure.lang.IDeref clojure.lang.IFn}
20:13amalloy,(let [v first] (deref (var v)))
20:13clojurebotjava.lang.Exception: Unable to resolve var: v in this context
20:13amalloyoh sure
20:14amalloy,(let [v (var first)] (deref v))
20:14clojurebot#<core$first clojure.core$first@1b5dade>
20:15amalloyi missed the beginning. is that anything like what jjido was trying to do?
20:15jjidoamalloy: I would like the ref, but I don't have the variable
20:16jjidoamalloy: I was trying with (var 'first)
20:16amalloyjjido: do you have its namespace?
20:16jjidoamalloy: yes I think so
20:17amalloy,(find-var 'clojure.core/first)
20:17clojurebot#'clojure.core/first
20:17jjidoamalloy: great!!!
20:18amalloysee also intern if you don't want to glue the symbol together yourself
20:18amalloy,(intern 'clojure.core 'first)
20:18clojurebotDENIED
20:18amalloyawww
20:18amalloywell, that would work in real life
20:22amalloy,(ns-resolve 'clojure.core 'first)
20:22clojurebot#'clojure.core/first
20:23amalloyjjido: ^^ is a better solution than intern, though feel free to use find-var if it's more convenient
20:24jjidowhat is the difference between them?
20:24amalloyif the var doesn't exist, intern will create it and ns-resolve will return nil
20:26jjidook
20:26jjidothe name makes sense :)
20:47bhenryhello
20:48bhenryis there something like this built into clojure or contrib for maps? https://gist.github.com/fef21fec41dd21dfa107
20:49amalloy,(doc get)
20:49clojurebot"([map key] [map key not-found]); Returns the value mapped to key, not-found or nil if key not present."
20:50amalloy,(let [v [:bar 1] e [:"bar is" :bar]] (map e #(get v % %)))
20:50clojurebotInvalid token: :
20:51amalloy,(let [v [:bar 1] e ["bar is" :bar]] (map e #(get v % %)))
20:51clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: sandbox$eval10486$fn__10487
20:51amalloybhenry: it's something like that anyway :P
20:51amalloy,(let [v {:bar 1} e ["bar is" :bar]] (map #(get v % %) e))
20:51clojurebot("bar is" 1)
20:52bhenryamalloy, i had just changed my implementation to use get, but i was wondering if there was some kind of turn map into string function like that
20:52amalloythere might be, but if there were you would still have to iterate over the vector, since the map isn't sorted
20:53bhenryokay. i was mainly trying to make sure i wasn't reinventing the wheel. i find myself doing that a lot. mostly from ignorance.
20:53bhenrythe bonus is that lately i find that my solutions are getting more and more similar to the idiomatic ones out there.
20:54amalloybhenry: ot
20:54amalloydamn it
20:54amalloybhenry: it's a nice little semi-printf you have there
21:22jjidodo you get a new namespace when you do (eval (read-string))?
21:38jjidoit is clear that you get a new namespace when you do (eval (read-string)) but what is its name?
21:39jjidooh, symbols that are function arg names do not pertain to a namespace
21:39jjido:(
21:41amalloyjjido: right. binding forms don't have namespaces
21:43amalloy,`(let [x 1] x)
21:43clojurebot(clojure.core/let [sandbox/x 1] sandbox/x)
21:43amalloy,`(let ['x 1] 'x)
21:43clojurebot(clojure.core/let [(quote sandbox/x) 1] (quote sandbox/x))
21:43amalloyhm
21:44amalloyoh right. it's a valid syntax-quote, but if you expand it as a macro it will fail
21:44amalloy,(clojure.core/let [sandbox/x 1] sandbox/x)
21:44clojurebotjava.lang.Exception: Can't let qualified name: sandbox/x
21:46amalloyjjido: i assume you have some interesting example where it would be convenient for lexically-bound symbols to have a var; what is it?
21:47jjidoamalloy: still the same story, I want a container object with a reference to the item, and a reference back from the item to the container
21:47amalloyah
21:48amalloyi'm still not sure it's possible without mutation
21:48jjidobefore I used var/deref but that route seems closed now
21:51amalloywhat do you mean? you can do it with an atom
21:53jjidoyes I need to use that. How about a mutable map otherwise? there are not that many containers to track
21:55amalloy,(let [x {:holder (atom nil)} x-holder [x]] (swap! (:holder x) (constantly x-holder)) (identical? x-holder (:holder x)))
21:55clojurebotfalse
21:55amalloyhm
21:56amalloyoh
21:56amalloy,(let [x {:holder (atom nil)} x-holder [x]] (swap! (:holder x) (constantly x-holder)) (identical? x-holder @(:holder x)))
21:56clojurebottrue
21:56amalloyjjido: is this useful?
22:14jjidoamalloy: I don't really see the point you make, too sleepy. I need a new atom for each container right?
22:15amalloyi think you can do it either with each container or with each held object
22:15amalloythe way i did it puts an atom in each object, pointing at its container
22:44shachafamalloy: Pong?
22:44amalloygnip
22:44shachafamalloy: Which wheel was it this time?
22:46amalloyoh, i had some Configuration class from a third party, and i needed it to store a List<String>, but it only accepted Strings
22:46amalloyso i hacked around for a while and converted my list to a single string, then looked at the api and saw they had a setStrings convenience method that turns a String[] into String
22:50rplevybasic question that is hard to google: what predict distinguishes between all collectionish things and symbolish things? it's not symbol because number are not symbols for example
22:51rplevy*predicate I mean
22:51amalloy,(map coll? [[1] () 1 'a])
22:51clojurebot(true true false false)
22:51amalloyrplevy: ^^
22:52alsocaseycould anyone point me towards my serialization options in clojure? Is there such functionality in the core or contrib?
22:53rplevyamalloy: I thought of that but what about (coll? (seq []))
22:53amalloy,(seq []) ;is nil. not a collection
22:53clojurebotnil
22:53rplevyamalloy: oh that explains it, thanks :)
22:58lancepantzdoes anyone know if maven implements a dependency task model ala ant, rake, cake, etc?
22:58lancepantztough to google for against results for library dependencies
23:02technomancyit uses a "lifecycle" model: http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
23:03amalloylancepantz: wikipedia has a decent summary of maven, too
23:05lancepantzgood link, looks as if it does not
23:14kmcso are [ ] part of the fundamental syntax of s-expressions in clojure?
23:14kmcor are they, at some level, sugar for an ordinary ()-based combination?
23:15kmci kind of expected that [ x y ] would get read as, like, (vector x y), but it seems not
23:15amalloykmc: i believe they're part of the syntax
23:16amalloyyou can check out the asm/ directory of the java source to be sure; the compiler's in there somewhere
23:16amalloythough maybe i'm not sure what you're asking
23:17technomancy,(macroexpand-1 [:a])
23:17clojurebot[:a]
23:21kmcmm
23:21kmcany idea why this design decision was made?
23:45amalloykmc: perhaps it's because the fundamental type in clojure is an Object? then there's no reason to favor lists over vectors, at the compiler level
23:46kmcbut it seems valuable to have only one kind of thing, syntactically
23:47amalloywell, i guess it's possible there is
23:47amalloyafter all, we do *have* vector and hash-map functions
23:47kmci mean this is one of the selling points of Lisp
23:47kmcbut the [] syntax seems to work out ok — you can still quote it, etc.
23:47amalloy,(map class [[1] (vector 1)])
23:47clojurebot(clojure.lang.PersistentVector clojure.lang.PersistentVector)
23:48kmcand what do i know, i've never implemented Clojure
23:48kmcbtw has anyone worked on a native-code-compiling implementation?
23:49amalloykmc: someone muttered about translating to scheme, and then passing that through the scheme-to-C compiler
23:49kmca specific one?
23:49kmcthere's more than one scheme native compiler, afaik
23:49amalloyhell if i know
23:49kmcanyway that's a cool idea
23:49chouserkmc: most such efforts will be dramatically easier after we've got clojure-in-clojure
23:49amalloythere's clojure-clr though
23:49kmcshould work all right, except for the Java interop parts
23:49kmcfor which you could a) use gcj java b) generate JNI c) do some RPC d) punt
23:50chouserkmc: I did peek at using gcj to AOT-compile to native code
23:50amalloy(a) is a fate worse than death. any of the others might be reasonable
23:50chouserbut clojure's core classes use some parts of the java std lib that gnu classpath hasn't implemented
23:51chouserI started trying to hack those parts out, but ... got distracted ...
23:51amalloythough (d) seems pretty impossible for any definition of "punt", since even the most basic parts of clojure use forms like (. someObj somefunc)
23:52kmcwell you could reimplement those?
23:55amalloysure
23:56kmcthough, i'm more and more of the opinion that for implementing a dynamic language efficiently, you need tracing JIT and not AOT compilation
23:56kmci'm not sure if HotSpot's JIT-fu is powerful enough