#clojure logs

2010-06-25

00:58vIkSiThi all
00:59vIkSiTdoes anyone recommend a way to do a merge on 2 lists?
01:18RaynesvIkSiT: What do you mean by "merge"?
01:20alexykhow do you error out with a message?
01:22vIkSiTRaynes, ah, something like doing a merge sort, except you're taking the union of 2 lists
01:22Raynes(throw (Exception. "message"))
01:22vIkSiTRaynes, basically, the imperative model has you parallely iterating through the 2 lists, doing a compare, and then adding elements in order..
01:23vIkSiTfunctionally, it looks like a combo of loop-recur and first/last would work.. but not sure if there's a known way to do it
01:32alexykRaynes: was there an (error ...) or something?
01:48Raynesalexyk: Not that I know of. There is one in Haskell... It probably wouldn't be very hard to simulate it.
01:49alexykRaynes: yeah. failwith in ocaml. I do all three at once... mixups
01:50Raynesalexyk: It might be as simple as throwing a (println "Omgerrors!") in there.
01:51alexykI just do an assert for now after such
01:51alexykit's zomgerrors btw
01:51RaynesIndeed.
02:47jeffhillHello! I'm hacking about with generating lazy sequences, and I wanted something like iterate but with something like recursive arguments... so I built a macro around lazy-seq. It seems to work fine, but I feel like I've done something non-idiomatic. Is there anything I'm missing here? Link to source: http://paste.lisp.org/display/111831
03:16mmarczyktechnomancy: ping! about Lein -- responded to your comment on GitHub
03:17mmarczykgotta be off now, though...
03:56AWizzArd,(vec (.getBytes (str (char 55366))))
03:56clojurebot[63]
03:56AWizzArdwtf
04:00neotyk,(java.lang.Character/MAX_VALUE)
04:00clojurebot\ï¿¿
04:02AWizzArdThat's 0xffff
04:03neotykjust noticed that is is a range
04:03AWizzArdThe thing is: when I .getBytes on my string (be it latin1, utf-8, utf-32, etc) I get something different from (map int my-string)
04:04AWizzArdI can't (String. (.getBytes my-string "UTF-8") "UTF-8") to get the same result
04:04AWizzArd(= my-string (String. (.getBytes my-string "UTF-8") "UTF-8")) ==> false
04:04neotyk,(str (char 55366))
04:04clojurebot"?"
04:04cschreineris there a way to put @ inside a symbol-name?
04:04neotyk,(str (char 63))
04:04clojurebot"?"
04:05AWizzArdIt's fine that it is a questionmark, but I would prefer that it used the same number
04:05cschreinerthis is relation to generation css; like the @font-face tag
04:05cschreinerI cannot do :@font-face
04:06AWizzArd,(let [s (apply str (repeatedly 5000 #(char (rand-int 65000))))] [(count s) (count (.getBytes s "LATIN1"))])
04:06clojurebot[5000 5000]
04:06AWizzArd,(let [s (apply str (repeatedly 5000 #(char (rand-int 65000))))] [(count s) (count (.getBytes s "LATIN1"))])
04:06clojurebot[5000 4999]
04:06cschreiner(symbol ":@font-face") works though
04:08cschreinernevermind, it's okay
04:09neotykAWizzArd: sorry I wan't be able to help
04:10AWizzArdI was just surprised to see such behaviour.
04:11neotyk~str
04:11clojurebotduck-streams is now clojure.contrib.io
04:11neotyk,(source str)
04:11clojurebotjava.lang.Exception: Unable to resolve symbol: source in this context
04:13neotykit calls .toString on result of (char ...) and that most likely does reencoding
04:15AWizzArdOver there in #Java they had a tip, I will study it now.
04:39dsophmm what is a good tool to generate documentation like the ones on clojure.org ?
04:52tomojautodoc
04:54dsoptomoj: thanks
04:57cschreinerLooking for a more reasonable way to do:
04:57cschreiner,(let [items (list 1 2 3 4)] (zipmap items items))
04:57clojurebot{4 4, 3 3, 2 2, 1 1}
04:58cschreineror is this sound clojure?
05:06sergey_miryanovhi all!
05:07sergey_miryanovi have a question about into for transient data - how to use it? if i use (into (transient []) (range 10)) i got an exception...
05:10AWizzArdsergey_miryanov: yeah, transients could need a bit more work. For example 'find' does also not work on transient maps.
05:12sergey_miryanovAWizzArd: clear
05:15Licenseraloa
05:22tomojcschreiner: that seems fine to me
05:22tomojnot sure why you'd want to do it..
05:30cschreinertomoj: I just want to create a map from a list where the keys are eq to the vals
05:31tomojright, but why?
05:32cschreinerthat's another story, not really important here
05:32tomojgoing to replace some of the values?
05:32cschreinerIit's just for personal testing
05:33cschreinerif I would go for (into {} ...) I could'nt quite figure out how
05:34tomoj,(let [s (range 10)] (into {} (map vector s s)))
05:34clojurebot{0 0, 1 1, 2 2, 3 3, 4 4, 5 5, 6 6, 7 7, 8 8, 9 9}
05:34tomojyour way is fine
05:34cschreinerguess so ;)
06:28AWizzArdAnyone here with a SSD?
06:31AWizzArdI would like to see what the performance difference is.
06:32AWizzArdPlease start a Server JVM and (import '(java.io FileOutputStream BufferedOutputStream DataOutputStream)) and define a string of one million random chars (def s (apply str (repeatedly 1000000 #(char (rand-int 55000)))))
06:33AWizzArdAnd then simply (with-open [dos (DataOutputStream. (BufferedOutputStream. (FileOutputStream. "/data" false)))] (time (dotimes [i 100] (.write #^DataOutputStream dos (.getBytes #^String s "UTF-8") 0 1000000)))) ; writing the string a hundred times to disk
06:54bartjAny Russian's here? I want to ask them a slightly off-topic question (:
06:55bartjregarding phone-numbers in Russia (:
06:57AWizzArdbartj: maybe #C++ ?
06:59bartjAWizzArd: why so ?
06:59AWizzArdja nje ponimaju po russki
07:01sergey_miryanovi'm a russian
07:06bartjAWizzArd: can you please tell me why phone numbers on this page are 12 digits? - http://www.77rosfirm.ru/catalog/card/77.1188629
07:09silveenHappy midsummer everyone
08:02AWizzArd,"\ud80e\udc80"
08:02clojurebot"𓢀"
08:17mmarczykAWizzArd: ouch... exposing my Emacs's failure to display unicode characters properly :-(
08:19AWizzArdmmarczyk: yes sure :)
08:20AWizzArd,(.codePointAt "\ud80e\udc80" 0)
08:20clojurebot80000
08:20AWizzArdThis is a string of just one character, with Unicode code point 80000
08:20AWizzArd,(count "\ud80e\udc80") ;-)
08:20clojurebot2
08:20mmarczykis there such a code point?
08:20AWizzArdyes
08:21mmarczykoh, look, a bug! :-)
08:21AWizzArdno, not a bug
08:21AWizzArdthis is correct behaviour
08:21mmarczykhuh?
08:21AWizzArdinternally 2 chars are used, to produce one real character
08:21AWizzArdthis char does not fit into 2 bytes
08:22AWizzArdcode points exist up to 0x10FFFF = 1114111
08:22mmarczykI'd still kinda sorta expect "logical" characters to be counted
08:23mmarczyk,(.length "\u80e\udc80")
08:23clojurebotInvalid character length: 3, should be: 4
08:23mmarczyk,(.length "\ud80e\udc80")
08:23clojurebot2
08:23mmarczyk...not going to argue with the host though
08:24AWizzArdyes, two 2-byte-chars are used, and they represent one unicode char
08:24AWizzArdWas a Java design descision and makes mostly sense.
08:24mmarczykwas it before the rise of utf-8?
08:24mmarczykjust out of historical curiosity
08:25AWizzArdOtherwise they would have to encode each char with 4 bytes under the hood, which is quite wasteful, as 99,99999% of all texts don't contain such very specific chars
08:25AWizzArdFirst Unicode was designed to eat 65k chars
08:25AWizzArdJava incorporated this
08:26chouserit may not be an implementation bug, but it might well be a design bug
08:26mmarczykI suppose a variable-length encoding would be terrible for indexing into strings etc.
08:26AWizzArdThen, later, the unicode consortium discovered this is not enough.
08:26AWizzArdThey now wanted to support over a million characters.
08:26mmarczyk"nobody should ever need more than 65k chars" -- sounds familiar somehow ;-)
08:27AWizzArdIt could be a design bug, but it probably isn't one
08:29mmarczykactually, how does one replace a "narrow" character with a "wide" character in an array of characters? copy the whole thing while adding an extra char in the middle...?
08:29AWizzArdThe real problem is that the api doesn't deal with malformed strings.
08:29AWizzArdWhen you want to traverse a(ny) string correctly, you can not traverse its (seq)
08:30AWizzArdYou need to look at the .codePointAt i
08:30AWizzArdand if that value is > than (int Character/MAX_VALUE), then you need to an extra increase of i in the loop
08:30AWizzArd+do
08:30mmarczykoh, you mean it's a clojure.lang.StringSeq problem...?
08:30AWizzArdno
08:30AWizzArdthere is no problem
08:31AWizzArdThe default behaviour is to traverse a string with charAt
08:31AWizzArdThis works in nearly 100% of all cases.
08:31mmarczyknot quite though?
08:31AWizzArdIt's good.
08:32AWizzArdThough, it is not really a correct approach.
08:32mmarczykok, so an alternative would be a "CodePointSeq" on a string
08:32AWizzArdyes, for example
08:32mmarczykwhich couldn't have characters as members, I guess
08:32mmarczykinteresting!
08:32AWizzArdIn principle such a CodePointSeq could be half the (count of-the-string).
08:33AWizzArd(<= (/ (count s) 2) (count CodePointSeq) (count s))
08:34mmarczykwondering I might be tripped up by this: do Chinese characters fit into the lower 65k part of Unicode then?
08:34AWizzArdI think all or most of all fit in there
08:34mmarczykok
08:34chouserI don't see how this could possibly be ideal
08:34chouserThere should be two things -- bytes and codepoints a.k.a. chars
08:35AWizzArdIt really is not ideal. We need a good bit of inside knowledge if we wanted to write correct code.
08:35chouserhaving a string be made up of something that is neither isn't useful, is it?
08:35AWizzArdNot the best thing, I agree. But this allowed all Java programs to continue to run. Also it means that Strings are not even more hungry than they already are.
08:35mmarczykis a big-C Character capable of holding a wide char?
08:35AWizzArdAn empty string eats 30+ bytes or so
08:36chouserutf8 is teh bomb
08:36AWizzArdno, native char and the wrapper Character both internally use 2 bytes to represent a character.
08:36mmarczykutf-8... would need to store an extra array of indices indicating where, say, every 32nd char starts
08:36mmarczykfor constant-time .charAt
08:38AWizzArdAll this would be okay.. people who studied this topic can write correct code.. but there still remains one problem, and that is: malformed strings.
08:38chousermaybe constant-time .charAt isn't worthwhile
08:38AWizzArdUnfortunately those don't throw an exception.
08:39mmarczykchouser: isn't that what enables StringSeq...? though maybe we could do without it
08:39AWizzArdWhile "\ud80e\udc80" is a perfect 2-char / 4-byte / 1-unicode-char string this one is nonsense: "\udc80\ud80e" (just reversed)
08:39AWizzArd,(vec (.getBytes "\ud80e\udc80" "UTF-8"))
08:39clojurebot[-16 -109 -94 -128]
08:39mmarczykthough constant time indexing also enables substring
08:39AWizzArd,(vec (.getBytes "\udc80\ud80e" "UTF-8"))
08:39clojurebot[63 63]
08:39mmarczykI'm not letting anyone take away my substring :-P
08:40AWizzArd,[(map int "\ud80e\udc80") (map int "\udc80\ud80e")]
08:40clojurebot[(55310 56448) (56448 55310)]
08:40chousermmarczyk: in it's current implementation, sure. If String's charAt weren't constant-time, you'd want other adjustments to its API
08:41AWizzArdThose designers of the spec decided that there have to be low surrogate chars and high surrogate chars, which expect something to their left or right
08:41mmarczykchouser: I suppose, not sure what those would be though; .substring is more important anyway
08:43AWizzArdwell, substring won't work on such strings
08:43mmarczykAWizzArd: with utf-8 strings supported by array of indexes into the underlying byte array it would
08:43AWizzArdIt works correctly when looking at the single chars, as in 2-byte-values.
08:43mmarczykI think?
08:44AWizzArdStrings are internally represented by a char array.
08:45AWizzArdIf you know for sure that your string contains no surrogate char at all, then subs and .substring work correctly and as expected.
08:45AWizzArdIf you want to do a substring as a human would expect it, by visible characters, then you will have to do it manually :)
08:46AWizzArdBefore each use of subs you can check if it is okay to use it: (re-find #"[\uD800-\uDFFF]" s)
08:46mmarczykyeah, I understand
08:46mmarczykbut you could theoretically implement strings differently
08:47AWizzArdif those 2048 chars are not included in the string (and this should be true for nearly 100% of all strings), then using subs is fine
08:47mmarczykthe above was referring to such hypothetical implementation
08:47AWizzArdmmarczyk: yes, and in such a case that would work
08:47AWizzArdOr they could make char being 3 or 4 bytes wide.
08:48mmarczykI think I'll make figuring out the performance/memory hit into a little project :-)
08:48AWizzArdwell sure, that could be interesting
08:50mmarczykthanks for the conversation, this is interesting stuff
08:50AWizzArdThe very easy solution is to use 3 bytes per char. That allows you to represent up to 16 mio different chars, while the current unicode standard supports just 1,114,112 characters
08:50AWizzArdBut interesting would be a compressed string, so that "aaaaaaaaaa" would just eat around 10 bytes, not 30
08:51chouserseriously. UTF8 is awesome
08:51mmarczykpresumably different things are possible on big proper boxen than in the embedded realm
08:52AWizzArdI am still pissed, because I am now writing a very fast serialization lib for Clojure and can't rely perfectly on .getBytes, which will produce wrong results for random strings.
08:52chouserI mean, it was nice when strings could have fixed-sized chars, but that era has passed.
08:52mmarczykextra byte per char in J2ME -> "surely you are in jest?"
08:53mmarczykchouser: yup, and currently we live in the era where strings cannot / must not have fixed-sized chars, yet they still do ;-)
08:53mmarczyksomebody make the next one hurry up
08:57mmarczykalright, I need to be off for now... see you later
09:16jcromartieI wish every programmer realized how evil mutable state is
09:16jcromartiethen I would have apps that set session variables and trigger a chain of event handlers that results in reading the session variable, in the same HTTP request
09:17jcromartiewouldn't
09:25lpetithello there.
09:28lpetitRegarding the recent "resurgence" of newbie questions such as "why does contains? has the semantics it has ..." et al., I've been thinking about some ways to make it both easy for the newbie to get the answer by himself, and easy to the newbie to contribute back where he found the info
09:30lpetitSomething directly usable from the REPL. e.g. some 'rationale' namespace. rationale functions would work on the same set of symbols (doc) and (find-doc) work on. rational content for vars/specialchars could be contained somewhere in the cloud (would need the network available).
09:30lpetit(rationale contains?) may return a string with an indexed list of texts.
09:31lpetite.g. "(0) http://some.googlegroup.thread\n(1) Rich Hickey once said on #clojure ..."
09:31lpetit(rate contains? 0) would mean : me as a user found rationale 0 to be useful
09:32lpetit(unrate contains? 0) would mean: me as a user found rationale 0 particularly useless
09:32lpetitthe 2 last functions would go to the cloud and and a "vote" for the given rationale
09:33lpetitfinally, (add-rationale contains? "some free text") would contribute a new rationale
09:34lpetitJust thinking about it. Thoughts ?
09:37jcromartiei don't see the benefit of it over just sending them here or to the mailing list
09:41lpetitjcromatie: I was thinking about this as an easy way to accumulate knowledge (especially concerning the rationale of things: why is contains? the way it is ?), and, via the rate/unrate functions, to automatically sort good knowledge. In the end: time saver for both the newbie and the non-newbie. So more time for the non newbie to help the newbie on more interesting questions. But maybe I'm...
09:41lpetit...just dreaming up ?
09:41lpetitjcromatie: I thought that the immediate access of those functions via the "always open" REPL could help leverage these functionalities
09:42lpetitjcromatie: of course, a little help from clojure-bot could also help add knowledge directly from irc, just after having answered for the nth time to the same question
09:43lpetitI know the answer generally is in the ml archive and / or in the #clojure logs and / or somewhere on the wikis / blog posts, but it's kind of steganographied knowledge ...
09:45eevar2lpetit: imo the best way to learn the essentials is "programming clojure" + "the joy of clojure"
09:46chouserit would be nice to have something better. right now we have official docs that are mostly up-to-date, but pretty dense and minimal. And we have "live help" on irc and ggroup which is up-to-date and as verbose as needed.
09:46stuarthallowayhas anyone ever written/seen a Clojure (into-bean bean map)
09:46chouserif you want something more verbose but less live, I think the main difficulty to overcome is keeping it up-to-date. All the books, and both wikis have this problem.
09:47stuarthallowaylike clojure into but reflective to get stuff into random java beans?
09:47chouserstuarthalloway: I've seen unbean somewhere I think.
09:47stuarthallowaychouser: thx, works as a search term
09:48chouserinto-bean's a better name
09:49stuarthallowayand implies the right semantics (starting with an existing bean)
09:49chouser'bean' may be misnamed as suggested in the ggroup thread. you found that?
09:49stuarthallowayyes
09:50stuarthallowayI am going to put into-bean into contrib somewhere
09:57lpetitchouser: I thought about somtheing totally "open to the community", just as a wiki with read/write access to anybody, but not a wiki, just 3 functions from the REPL to consult (rationale), add content (add-rationale), remove content (remove-rationale) (and/or rate/unrate). A simple "wikipedia" indexed by var
09:58lpetitchouser: but more an aggregator of links (per var) than containing the real content. But maybe it would just be yet another out of date source of info :-(
09:59chouserlpetit: well, it is a social problem not a techincal one. if lots of people use it and it's easy to update, it's likely to stay up to date.
10:00chouserperhaps having it in-repl would be enough to solve that.
10:00lpetitchouser: yes. And it's it does not cost too much to introduce the feature, ...
10:00lpetitchouser: yes, I bet that having it in repl could greatly help make the dream come reality
10:02lpetitchouser: I guess a minimalist approach could leverage the most useful part of the features very quickly
10:03lpetitthere is no http client in contrib, right ?
10:05hugodlpetit: a repl based tool would probably reduce the amount of spam too.
10:05hugodI have the start of a repl/command line feedback tool that uses google appengine
10:06hugodlpetit: clojure.contrib.http.agent
10:06lpetithugod: yay !
10:08lpetithugod: I was testing the idea. I don't intend to work on this *for real* in the next few weeks. If you like the idea, feel free to go ahead !
10:08hugodI've been put off by appengine startup times though, 10s to 20s. I assume it gets better with volume, but...
10:09lpetithugod: oh yes, this would be a breaker for using app engine, I guess
10:10lpetithugod: the evil will be in the detail (as for what differenciates an iphone to an ordinary mobile phone). If it ain't fast (as in "instantaneous"), it won't be used.
10:11hugodlpetit: asynch requests help to keep it feeling fast
10:25lpetithugod: can you tell us more 'bout your "repl/command line feedback tool that uses google appengine" ? Especially, I don't understand why it is tied to appengine. Just using GET/POST HTTP functions should suffice, no ?
10:26hugodlpetit: well, the data has to go somewhere, but it would be easy to move to some other storage
10:27hugodit would be trivial to change it to couchdb or similar
10:28lpetithugod: ok, but can't you make the client/server protocol independent of the server's underlying storage techno ?
10:29hugodlpetit: of course the the protocol is independent of the storage
10:29lpetithugod: sorry then
10:30hugodlpetit: I'm probably not explaining it well :)
10:31hugodlpetit: at the moment it uses hash tags to identitfy individual comments, and allows replies on particular tags
10:32hugodlpetit: but adding recoginition of clojure function names would be simple
10:32lpetithugod: let us know when you've implemented it ! :)
10:32hugodlpetit: each user is identified by an opaque handle
10:33hugodlpetit; which the user can attach to aomething less anonymous
10:33lpetithugod: I don't think we need to identify people. I'm thinking about a "no-config" "no-brainer" system for the "rationale" feature
10:34hugodlpetit: ranking would be per item then?
10:34lpetithugod: well, yes
10:34hugodlpetit: I think allowing people to identify their comments would be an incentive for some
10:36lpetithugod: I was more thinking about keeping it as simple as possible. You find something useful, you push it, done.
10:37lpetithugod: or maybe a "loose" identification, not via an id of any sort, but just an optional argument to the function : (add-rationale "my text" "lpetit")
10:37hugodlpetit: I'm all for the simpler the better, at least initially
10:37lpetit,(System/getProperty "user")
10:37clojurebotnil
10:37lpetit,(System/getProperties)
10:37clojurebot#<Properties {java.runtime.name=Diablo Java(TM) SE Runtime Environment, sun.boot.library.path=/usr/local/diablo-jdk1.6.0/jre/lib/i386, java.vm.version=10.0-b23, java.vm.vendor=The FreeBSD Foundation, java.vendor.url=http://www.freebsd.org/java/, path.separator=:, java.vm.name=Diablo Java HotSpot(TM) Client VM, file.encoding.pkg=sun.io, sun.java.launcher=SUN_STANDARD, user.country=US, sun.os.patch.level=unknown, java.vm.spe
10:38lpetit,(System/getProperty "user.home")
10:38clojurebot"/home/hiredman"
10:38lpetit,(-> (System/getProperties) bean)
10:38clojurebot{:empty false, :class java.util.Properties}
10:38lpetitargh
10:39lpetithugod: was thinking about maybe using the System env context, but I fear complaints for violation of privacy ....
10:40hugodlpetit: that's why I am using an opt-in scheme for identification
10:43hugodlpetit: I was aiming for a repl based version of something like uservoice
10:44lpetithugod: what is uservoice ?
10:44hugodlpetit: uservoice.com
10:45lpetithugod: ok
10:45hugodlpetit: but using #tags similar to thedeadline
10:45lpetithugod: I must leave, keep up the good work, cu later !
10:46hugodlpetit: :)
10:46jimdueyHi folks. Anyone have a favorite webhost company to serve a site of static pages.
10:46jimduey?
10:49bhenryjimduey: nearlyfreespeech.net unless your volume will be big
10:49jimdueyThanks, I'll check it out. Minimal volume
10:59arohnerbefore I start writing, are there any lein plugins that start a daemon process?
11:14chouserstuarthalloway: have you tried making the laprepl example in enclojure recently?
11:22AWizzArd,(instance? Long/TYPE (long 10))
11:22AWizzArd$(instance? Long/TYPE (long 10))
11:22sexpbot=> false
11:22AWizzArdWhy is that?
11:23AWizzArd$[Long/TYPE Long (class? Long/TYPE) (class? Long)]
11:23sexpbotCommand not found. No entiendo lo que estás diciendo.
11:23AWizzArd$(vector Long/TYPE Long (class? Long/TYPE) (class? Long))
11:23sexpbotjava.lang.SecurityException: Code did not pass sandbox guidelines: (#'clojure.core/class? #'clojure.core/class?)
11:24cemerickwhat happened to clojurebot?
11:24stuarthallowayAWizzard: long doesn't promise it will return a Long/TYPE
11:24AWizzArdanyway, (identical? Long Long/TYPE) ==> false
11:24stuarthallowayand the assumption that such things hold is making rhickey crazy as he fixes overspecified tests in the various num branches
11:25cemerickIn any case, the (long 10) is going to get boxed going into instance?
11:25stuarthallowaycemerick: I don't think the doc promises that either
11:26stuarthallowayif you call (long x) on the way into a Java interop form, you don
11:26stuarthalloway't want boxing
11:27cemerickRight, but if instance is a clojure fn, then everything is boxed -- modulo prim
11:33arkhWhat's a good way to loop over something x times or until (testfunc) returns false
11:34hiredman~ping
11:34clojurebotPONG!
11:36chouser,(for [i (range 10) :while (even? i)] i)
11:36clojurebot(0)
11:37arkhchouser: thank you
11:37chouserarkh: note that's a lazy seq, not a loop in the imperative sense
11:38arkhchouser: so wrap with (doall) ?
11:38arkhchouser: ... assuming I wanted the whole thing realized
11:38chouseryou want side effects?
11:39chouseryou could try doseq instead of for
11:39chouser,(doseq [i (range 10) :while (even? i)] (println "Mutate the universe:" i))
11:39clojurebotMutate the universe: 0
11:41arkhchouser: doseq looks good; side effects are involved
11:46cemerickclojurebot: nice to have you back :-)
11:47clojurebotexcusez-moi
11:47cemerickexactly
11:48bhenrychouser: i can't figure out why those code snippets don't display 0 2 4 6 8.
11:49bhenryah nevermind
11:50chouserbhenry: right, for that you'd use :when instead of :while
12:02bhenrychouser: does :while withhold laziness so that (range 10) never sees the 1?
12:06chouserno, :while has to realize 1 in order to see that it's not even. But it won't realize any more than that.
12:07chouser,(for [i (iterate inc 0) :while (even? i)] i)
12:07clojurebot(0)
12:15arohnertechnomancy: did you get my github email last night?
12:16technomancyarohner: yeah, still working through a slight backlog on pull requests. hope to get to it this weekend.
12:17arohnertechnomancy: no problem. I had another thought, which is a plugin that hooks lein deps would work if src/ was on the lein classpath
12:17arohnertechnomancy: nm. something else must have been broken
12:30defnlancepantz: sorry if you already answered this, but did you get your JRuby + Rails + Clojure project up for viewing?
13:18KjellskiHi there, I'm trying to build a function that blocks a seq like this: [1 2 3 1 4 5 1 6 7] into these: [[1 2 3] [1 4 5] [1 6 7]] with a signature like this (defn block-by [pred coll] ...) is there already something that does this?
13:19AWizzArd$(map vector (partition 3 [1 2 3 1 4 5 1 6 7]))
13:19sexpbot=> ([(1 2 3)] [(1 4 5)] [(1 6 7)])
13:20mmarczyks/vector/vec/
13:20chouserKjellski: http://clojure-log.n01se.net/date/2010-06-23.html#12:40
13:20bhenrykjellski do you want to make a new group whenever you get to something lower than the previous number or do you want to actually do it by 3's?
13:21AWizzArdor do you want to start a new group whenever you hit a 1?
13:21bhenrythat too
13:21AWizzArdmmarczyk: identity would also be an option
13:22chouserhe asked this a couple days ago
13:22mmarczykAWizzArd: better not use map at all then
13:22AWizzArdchouser: how do you know this? You don't remember everything you read in here, do you? ;)
13:22KjellskiI want it to split the vector by 1, whatever pred is should split...
13:22mmarczyk$(doc split-with)
13:22sexpbot=> ------------------------- clojure.core/split-with ([pred coll]) Returns a vector of [(take-while pred coll) (drop-while pred coll)] nil
13:22AWizzArdmmarczyk: yesss *lol*
13:22KjellskiAWizzArd: exactly!
13:23mmarczykAWizzArd: :-)
13:23chouserKjellski: I posted a couple answers for you on Wednesday, after you left. :-P
13:23AWizzArdKjellski: you can not answer an or-question with yes/no/exactly
13:23Kjellskimmarczyk: but split with looses the relation between the elements and groups them into one
13:23mmarczykwell, that's what the questions above are about...
13:24chouser,(map #(apply concat %) (partition 2 (partition-by #{1} [1 2 2 1 3 3 1 4 4])))
13:24clojurebot((1 2 2) (1 3 3) (1 4 4))
13:24mmarczykthere'll be different solutions depending on what you want to apply the predicate to
13:24Kjellskichouser: Oh sorry mate... but thanks for that, I think this would be useful as a standard funtion...
13:24AWizzArdmmarczyk: I was thinking of matrix transposition, such as (map list [1 2 3] [4 5 6] [7 8 9]) and started out with map, doh!
13:25chouserKjellski: what would you name it?
13:25mmarczykAWizzArd: ah, then prefixing your snippet with apply would work
13:26Kjellskichouser: something like "block-by" or "block-by-pred" ...? I would use this for parsing, but maybe the name would be good for other viewpoints?
13:27Kjellski,(map #(apply concat %) (partition 2 (partition-by #{1} [1 2 3 4 1 5 6 7 1 8 1 9])))
13:27clojurebot((1 2 3 4) (1 5 6 7) (1 8) (1 9))
13:28Kjellskichouser: what a dream... I'm always thinking way to complex to get to such solutions...
13:28chouserKjellski: well, me too, pretty often. did you scroll up from that link and see my first solution?
13:28mmarczykoh, something like Haskell's groupBy then?
13:28mmarczykgroupBy (\x y -> if y == 1 then False else True) [1,2,3,1,4,4,1,5,5]
13:29mmarczyk[[1,2,3],[1,4,4],[1,5,5]]
13:29chouser(doc group-by)
13:29clojurebot"([f coll]); Returns a map of the elements of coll keyed by the result of f on each element. The value at each key will be a vector of the corresponding elements, in the order they appeared in coll."
13:29Kjellskichouser: yes
13:29mmarczykgood function, to be sure, but we've already got a group-by which does something completely different
13:29mmarczykah, right.
13:29mmarczykso not sure what to call it now...
13:30chouserit's closes to partition-by
13:30chouserclosest
13:30chouserperhaps partition-starting-when :-)
13:30Kjellskimmarczyk: I thought of "block-by" but that could be confusing too...
13:30mmarczykchouser: yeah
13:31mmarczykshall we hold a naming contest? ;-)
13:31Kjellskichouser: what about "collect-blocks"
13:31mmarczykor maybe call it partition-with and laugh diabolically each time somebody confuses it with partition-by :-P
13:31Kjellskimmarczyk: ^^
13:32chouserhm, I thought we already had a partition-with, but I guess not
13:33Kjellski,(map #(apply concat %) (partition 2 (partition-by #{1} [1 2 3 4 1 5 6 7 1 8 1 9 1 1 1 2 1])))
13:33clojurebot((1 2 3 4) (1 5 6 7) (1 8) (1 9) (1 1 1 2))
13:33Kjellskichouser: see the end?
13:33chouserooo, you broke it!
13:34chouser,((fn [p s] (->> [nil s] (iterate (fn [[_ [_ & xs]]] (split-with (complement p) xs))) (partition 2 1) (map (fn [[[_ [i]] [r]]] (cons i r))) (take-while first))) #{1} [1 2 3 4 1 5 6 7 1 8 1 9 1 1 1 2 1])
13:34clojurebot((1 2 3 4) (1 5 6 7) (1 8) (1 9) (1) (1) (1 2) (1))
13:35Kjellskichouser: actually, that rocks
13:36Kjellskichouser: thanks
13:36chousera bit of a mess, but you're welcome.
13:36Kjellskichouser: *thinking*: I´ll try to understand it the next two weeks ^^
13:37chouserI deny allegations of destructuring abuse
13:39Kjellskichouser: could you do me favour? I would love to see it indented the best, so I could try to figure out what it does...
13:39chouseryeah, sure.
13:40rhickeyupdated docs for equiv branch, ready for people to check it out: https://www.assembla.com/wiki/show/b4-TTcvBSr3RAZeJe5aVNr/Enhanced_Primitive_Support
13:41chouserKjellski: http://gist.github.com/453174
13:42Kjellskichouser: thanks a lot!
13:47chouserKjellski: just updated the gist to a simpler version
13:48Kjellskichouser: I´ll have a look...
13:52Kjellskichouser: this function comes in really handy *happy*
13:52eivindglq
13:53Kjellskichouser: how nice to split logs with it... ^^
13:53chouserKjellski: :-) great.
13:54chousercemerick: I played with stack traces some yesterday, basing a lot on clojure.stacktrace
13:55cemerickchouser: any breakthroughs?
13:56chouserno, but I segmented the code differently -- have a fn that returns a seq of stack-trace lines, so that you can then filter, map, etc. to get what you want
13:56chouserthen another fn that prints them once you've filtered
13:57chouserI'll keep playing with it, but I wanted to mention that your code was a nice starting place.
13:57cemerickmy code?
13:57chouserdidn't you write clojure.stacktrace?
13:58cemerickNo -- I think SS did?
13:58cemerickI would never produce something so useful.
13:58chouseroh. sure enough named right there at the top. I wonder how I got confused.
13:59chousersorry.
13:59cemerickno worries
13:59Kjellskithere is no way to step through clojure code right? ^^ like good old debugging?
13:59cemerickPeople often think I'm responsible for awesome stuff. I just make sure I'm next to people that do real work, or I think out loud and often someone will do something I can take credit for. ;-)
13:59chouseranyway, I've got shorter stack by throwing away RestFn patterns that show up on every apply, and non-core .clj lines highlighted
13:59cemericklike, shell highlighted, or otherwise?
14:00chouseryeah, shell. ANSI color codes. I live in the 70s
14:00chouseror was that 80s
14:01cemerickNah, I'm jealous of good shell highlighting, etc.
14:01cemerickNot jealous enough to actually use a shell for real work, of course.
14:01chouserI want to throw away multi-line patterns that show up on seq-walking. probably collapse compiler lines since I normally don't care.
14:01cemerickSounds awesome.
14:02cemerickIs it reasonable to screen out clojure.* frames by default in general?
14:02cemerick(however much that might irritate rhickey? ;-)
14:02chouserdunno. I'll keep playing with it.
14:03chouserthe seq thing is pretty key though -- allows modular filtering.
14:03chouserI want to play with reversing the causes and/or lines within each cause.
14:03chousermaybe the root cause and it's line should be immediately above the prompt
14:04chouserwalking up the screen would be walking back in time
14:05cemerickare you working on a patch to be grabbed somewhere?
14:05chouserhrm. no. dumb.
14:06cemerickchouser: oh, #322 is done AFAIK. Not sure if you remember, but we were poking at some solutions a few months ago. http://www.assembla.com/spaces/clojure/tickets/322
14:07chousercool. I've been watching the conversation, but haven't looked at the code.
14:07cemerickIt was pretty simple, once I had a clue as to what was going on.
14:08chouserhttp://gist.github.com/453211 stack-trace-playground.clj
14:09chouserso the idea is people can write up different filters, colorizers, etc. then mix and match as desired.
14:10technomancychouser: have you tried http://github.com/mmcgrana/clj-stacktrace ?
14:10chousertechnomancy: once long ago
14:10technomancywe just started using it, and it makes me very glad.
14:10chouserhm... ok!
14:10technomancyI would love to see it in clojure 1.3
14:10cemerick"\033[31m" == red?
14:10technomancyit's pretty easy to hack into clojure.test
14:11technomancy(with some monkeypatching)
14:12technomancyhttp://p.hagelb.org/clj-stacktrace-monkeypatch.html
14:12chousernice. mmcgrana writes good code.
14:14chouseroh, man. I clearly need to start with clj-stacktrace and work from there.
14:15chouseralpha-punc-subs, trim-redundant, color-codes, all good stuff I would have ended up doing roughly the same way, but he's already done it better.
14:16chouserbut I do want to do filtering which I don't see a way to plug in very cleanly.
14:39arkhbeing unable, at this point in my clojure education, to comprehend the source for 'for', does anyone know if 'for' realizes all seq-exprs on each iteration, regardless of modifiers, or will it short circuit evaluation of a seq-expr if a :while is false on an earlier listed seq?
14:39arkhe.g., does for behave like and ?
14:42chouser,(for [x [1 2 3], y [4 5 6] :while (< y 6)] [x y])
14:43clojurebot([1 4] [1 5] [2 4] [2 5] [3 4] [3 5])
14:43chouserI guess I'm not quite sure what you're asking.
14:43arkhyou know ... I might not either ...
14:44chouserI have a vague recollection of :while not short-circuiting in quite the way one might expect, but I'm having trouble remembering the details
14:44chouser,(for [x [1 2 3], y [4 5 6] :while (odd? x)] [x y])
14:45clojurebot([1 4] [1 5] [1 6] [3 4] [3 5] [3 6])
14:46arkh,(for [x [1 2 3], y [4 5 6] :when (odd? x)] [x y])
14:46clojurebot([1 4] [1 5] [1 6] [3 4] [3 5] [3 6])
14:47mmarczyk,(for [x [1 2 3] :while (odd? x) y [4 5 6]] [x y])
14:47clojurebot([1 4] [1 5] [1 6])
14:47chouserso, :while only will skip the rest of the seq it's applied to
14:47mmarczykclj-stacktrace looks awesome.
14:48arkhchouser: thank you again
14:48briancarpermmarczyk: Cool, I didn't know `for` worked that way.
14:49briancarperI never tried sticking a :while in the middle.
14:49mmarczykaye... still, nowhere near as funky as PLT Scheme/Racket's list comprehensions :-)
14:50arkhmmarczyk: I meant to thank you also! Thanks.
14:50mmarczykarkh: np :-)
15:08dnolenheh "equiv the revenge of num"
15:16jcromartieWhy would a Common Lisp user say that Clojure can be "incredibly slow?"
15:16jcromartieIs that just the "Java is slow" myth extended?
15:17RaynesProbably.
15:17jcromartieSBCL ranks pretty far behind Scala on the benchmarks game
15:17jcromartiebut SBCL is JVM too
15:17jcromartieweird
15:17qbgNo...
15:18qbgSBCL is native
15:18RaynesCommon Lispers can be "incredibly elitist".
15:19qbgWell, CL does lay waste to many other languages...
15:19jcromartieoh wait, I see, it was comparing it to Java... I got it confused with ABCL
15:20technomancyCL'ers might be looking for excuses to stick with CL and not try new stuff
15:20technomancysince that strategy has worked for them since the mid-80s
15:21jcromartiehe says it's because it's all because they "have to make refs"
15:21jcromartieto interop with Java
15:23jcromartieand that Kawa (a JVM Scheme) is "over 1000 times faster than optimized Clojure"
15:23jcromartie"All because it doesn't have to make refs"
15:24technomancyhe's clearly not interested in having a discussion; he just wants to Be Right.
15:24qbgWow...
15:24dnolenjust another troll looking for a good time it sounds like
15:53yacini've got a project in emacs
15:53yacinand i moved some functions to a separate file
15:53yacinnow, i'm obviously going to run into namespace/functionname clashes
15:53yacinhow can i remove the defined functions from the old file?
15:53yacinwithout having to restart my swank session?
15:54bhenryyacin: i am also curious about this. i don't think you can.
15:54bhenryi always just restart
15:55yacinrestarting isn't a big deal, but it'd be nice to not lose my current state
15:55mmarczykns-unmap
15:56bhenry,(doc ns-unmap)
15:56clojurebot"([ns sym]); Removes the mappings for the symbol from the namespace."
15:56bhenrymmarczyk nice.
15:56mmarczykI use this for convenience: (defmacro undef [& syms] `(doseq [s# '~syms] (ns-unmap *ns* s#)))
15:57mmarczyk(undef foo bar baz) / (clojure.contrib.with-ns/with-ns my.old.ns (undef foo bar baz))
15:58mmarczykgot it in my init scripts (user.clj on the classpath)
15:59yacinmmarczyk: thanks!
16:00mmarczyk(doseq [old-name (keys (ns-interns 'my.old.ns)) :when (contains? (ns-interns 'my.new.ns) old-name)] (with-ns my.old.ns (undef old-name)))
16:00mmarczykfor some generalised cleanup
16:00mmarczyk(wrote it here, so sorry for any typos etc. missed)
16:01mmarczykah, the name 'old-name' for the local doesn't make any sense, should be 'sym' or sth
16:08yacinmmarczyk: for setting up a user.clj, do i need any (ns ...) declaration? or just a bunch of functions?
16:08mmarczykyacin: no (ns ...) form, no
16:08yacinkk
16:08yacinthat's what i figured
16:08yacinthanks
16:09mmarczykwhatever you put in there will be loaded into the user namespace on startup
16:09mmarczykI've got a bunch of requires... [clojure [set :as set] [walk :as walk]] etc.
16:09mmarczyk^requires in there...
16:10polypus~ping
16:10clojurebotPONG!
16:10yacingotcha
16:10mmarczykthe script goes into any directory present directly on the classpath; clojure.jar has "Class-Path "."" in its MANIFEST, so if you put user.clj alongside it, it should work fine
16:12mmarczyk...at least I think that's why my setup for experimental repls involving ~/.clojure/{clojure.jar,clojure-contrib.jar,swank-clojure.jar,user.clj} works :-)
16:13yacinyeah, i just dumped it in ~/.clojure
16:13polypusif i define a seq using cycle or repeat and hold on to the head while bang on it for a while, is the seq caching aware of the cyclic nature of the seq, i.e. does it cache all the values, or just the period of the cycle? if that makes any sense
16:15polypusi.e. (def s (repeat 4)) (take 1000000 s) are 1000000 values cached or just 1 because it's a repeat
16:16mmarczykit's aware of its cycling value
16:17mmarczykif I understand you correctly
16:17mmarczyk(def t (cycle [(promise)])) (deliver (first t) :foo) @(second t)
16:17mmarczykgets back :foo
16:18mmarczyk(meant to say "cyclic nature" above)
16:19mmarczykah, wait, I guess I did misunderstand...
16:19polypusmmarczyk: what i mean is will the seq cache consume 1000000 int's worth of memory or just 1
16:20polypusbecause i've held on to the head
16:20mmarczykyeah
16:20polypusyeah 1000000
16:20polypus?
16:20mmarczyk(let [foo (cycle [:foo])] [(first foo) (first (drop 100000000 foo))]) ; => see if memory runs out :-)
16:24mmarczykhaving looked at the code I'd still say it knows it's cyclic
16:26mmarczykhowever that's not to say the generated lazy seq cannot get bigger... I guess it will, due to bookkeeping (multiple pointers to the same seq bundled with instructions to go on cycling when the end is reached)
16:26mmarczykthat's as far as I can tell, anyway.
16:27polypusmmarczyk: ok ty, the code you just posted did not run out of memory but i'll mess around a bit more. would be good to know for sure though, cuz you don't seem %100 convinced
16:28mmarczykwell the seq cycle returns will doesn't make copies of the cycled seq as it goes
16:29mmarczykit sorts of "chains together" multiple pointers to the same seq
16:29mmarczykand at the end there's a "terminator" which, if you hit it when traversing the cycled seq, will produce extra elements
16:29mmarczykso whatever was in the cycled seq will not be replicated (as the promise/deliver example demonstrates)
16:30mmarczykbut there will be a growing lazy seq scaffolding
16:30polypusmmarczyk: thanks again
16:30mmarczyknp
16:30mmarczykI am, say, 99% convinced ;-)
16:30polypus:)
16:31Kjellskiis it deprecated to use (defstruct ...) ?
16:31polypusKjellski: yeah, use defrecord or deftype
16:31Kjellskipolypus: thanks =)
16:32polypusnp
16:33Kjellskipolypus: ... they´re not in the cheatsheet at clojure.org/cheatsheet =(
16:35mmarczykKjellski: actually they haven't been released... 1.2 stuff
16:35polypusKjellski: http://clojure.org/datatypes
16:36mmarczykKjellski: so, if you're on 1.1, you won't be able to use them, but transitioning from structs to records should be entirely painless
16:37Kjellskithanks to both of you, but in that case I could use (defstruct ...) nevertheless?
16:38polypusKjellski: yeah, like mmarczyk says, it'll be easy to upgrade later
16:38polypusand np :)
16:38Kjellskipolypus: alrightyyyy thennnn ^^
16:38mmarczyk:-)
16:47dnolenrhickey: equiv isn't quite as zippy for me as the latest equal. but perhaps the more important issues are addressed.
16:53arohnerstupid question: in paredit mode, how do you split strings? i.e. "foo bar" -> "foo" "bar"
16:53polypusarohner: option shift s
16:53mmarczykM-S
16:54arohnerpolypus mmarczyk: thank you
17:00polypusbest performing clojure datastructure for a stack?
17:01polypusi assume it's a list
17:05mmarczykcore functions seem to encourage vector usage -- peek/pop
17:07polypusmmarczyk: did you see that in commented code?
17:07mmarczykI just mean that the mere existence of functions called peek/pop suggests that whatever they work on should be a good fit for a stack
17:08polypusbut they're defined on lists too
17:08mmarczykor a queue, I guess; and indeed, they also work with clojure.lang.PersistentQueue
17:08mmarczykhey... never noticed that :-D
17:08mmarczykthanks! :-)
17:08polypusnp :)
17:09mmarczykI thought a transient vector could do well in a single-threaded context, but there is no peek!, only pop!
17:09mmarczykand peek doesn't work
17:09mmarczykso probably a list after all, though definitely use conj over cons
17:10riddochcp WhyteShadow=Well, there's a few particular "parameters" you can tweak to adjust the perception of height in a figure...
17:10mmarczykhm, really no peek! ...? checking again... nope
17:10riddochcAck! Sorry.
17:10riddochcWrong window.
17:13polypusmmarczyk: i am in a single threaded context and don't need peek so maybe it'll do. ty
17:14mmarczykpolypus: you don't need to know what's on top of the stack?
17:17ataggartsince peek doesn't modify anything, why would there need to be a transient version of it?
17:17mmarczykbecause the regular version works with IPersistentStack instances
17:17mmarczyknothing transient is IPersistent*
17:18polypusmmarczyk: oops forgot pop returns the rest not the popped
17:18mmarczykpolypus: right
17:18ataggartah, good point
17:18mmarczykpolypus: actually, why not use java.util.Stack?
17:19ataggarthopefully all things that will become nonissues when cic is done
17:19mmarczykataggart: agreed
17:19polypusmmarczyk: that's an idea
17:20mmarczykataggart: though in this case, I don't see a reason not to provide a transient counterpart to IPersistentStack *or* to use a persistence-agnostic interface
17:20mmarczykthat's far from saying there isn't one -- just wondering :-)
17:21ataggartmmarczyk: agreed. As Rich says: "patches welcome" :)
17:21mmarczykpolypus: it's likely to have been beaten to death and back with optimisation sticks
17:21mmarczykataggart: I might oblige when my CA gets processed :-)
17:22mmarczykappears to be stuck in the queue
17:25mmarczykis there any way to see pull requests one has sent off on GitHub? my memory is failing me and I'd like to check one...
17:36SirNickHow can I use apply with an arbitrary symbol?
17:36polypusSirNick: elaborate
17:37polypusmmarczyk: trying out java's stack now. ty 4 tip
17:37SirNickpolypus: Given I have a variable holding a symbol, how can I call apply with that symbol, for example (apply the-variable [])
17:37mmarczykpolypus: cool, np :-)
17:37qbg(apply (resolve the-variable) ...)
17:38SirNickqbg: Resolve is exaclty what I was looking for, thank you
17:38replacadoes anyone know why the IntrenalReduce version of reduce is commented out currently?
17:38replacain core.clj: #_(defn reduce... )
17:39mmarczykreplaca: which branch?
17:39qbgIt isn't for me
17:40replacammarczyk: master
17:41mmarczykhm, so it is
17:41mmarczykno idea
17:41mmarczyka08eac88766fa5eca96d: disable direct binding (and internal reduce with it, for now)
17:41replacaoh well. It breaks the doc string, but that's not the end of the world as long as it's temporary
17:41mmarczykno rationale
17:42mmarczykbut if it's somehow connected to direct binding, pre-:static stuff maybe...?
17:42replacammarczyk: yeah, that would make sense
17:43mmarczykoh? personally, I can't make heads or tails of it ;-)
17:43mmarczykplanning on a mystery-hunting trip to find out why there's any relation :-)
17:48mmarczykwhile of course I jest, I notice that equal has reinstated internal-reduce (with no mention of :static in core.protocols... oh well)
17:49Kjellskign8 all =)
17:49Kjellskithanks for the help
17:49Kjellski;)
18:01SirNickSay I have a function defined in namespace A and I call the function from namespace B, resolve then resolves from namespace B but how can I make it resolve from the place it was defined, namespace A?
18:03AWizzArdns-resolve maybe
18:03qbgOr you could namespace-qualify the variable
18:03SirNickyea I was thinking ns-resolve, but is there anyway I can get around writing out the namespace name explicitly? Something like ns but that doesn't change perhaps?
18:04rhickeydnolen: go a git of something that's slower?
18:05SirNickI meant to say ns (with astericks) not bold ns
18:05dnolenrhickey: ahh, all this different operators because of your research, was using something that got slower (unchecked-multiply), replacing with unchecked-multiply-long fixed it. no equiv is light speed like equal.
18:05SirNickWell it did it again even with added spaces... that's annoying
18:06ataggartAm I the only one who never seems to pass around symbols? Is this a CL thing?
18:07AWizzArdSirNick: would it work that your function in A becomes a closure, capturing its own ns at compile time and using that then with ns-resolve?
18:07mmarczykSirNick: functions can have metadata attached currently, so you can put the ns name there
18:07mmarczykin fact
18:08mmarczyk$(meta #'reduce)
18:08sexpbot=> {:ns #<Namespace clojure.core>, :name reduce, :file "clojure/core.clj", :line 773}
18:08SirNickAWizzArd: Hmm that might work, but I am not sure how to accomplish such a thing in clojure
18:08mmarczykhere you go
18:08mmarczyk(meta #'your-var)
18:08SirNickmmarczyk: Oh interesting idea... I'll look into that as well, thanks
18:09mmarczykah, no, actually that presupposes an ability to resolve the Var
18:09SirNickmmaryczyk: would there be a way to get the metadata of the function you're currently in perhaps?
18:09mmarczykI guess so
18:09qbgSirNick: Any reason why you can't namespace-qualify the symbol in the variable?
18:10SirNickqbg: well the function takes one argument and that argument is converted to a string for one purpose and is also used to call other functions in the same namespace
18:10mmarczyk$(^{:foo :foo} (fn foo [] (meta foo)))
18:10sexpbot=> nil
18:11mmarczyk:-(
18:11mmarczykbut it works for me at the repl :-/
18:12mmarczyk$(^{:foo true} (fn foo [] (meta foo)))
18:12sexpbot=> nil
18:12mmarczykan equal-branch repl, but I don't see how that would be relevant
18:13qbg,(name 'clojure.core/+)
18:13clojurebot"+"
18:13SirNickHmm interesting, I thought name would include the namespace
18:14SirNickwell then I suppose that would work... makes things a bit more bulky to call the function though since I would have to write the function twice
18:14SirNickSorry, I mean the namespace twice
18:14qbg`+
18:14qbg,`+
18:14clojurebotclojure.core/+
18:14mmarczyk,(.namespace 'clojure.core/+)
18:14clojurebotjava.lang.IllegalArgumentException: No matching field found: namespace for class clojure.lang.Symbol
18:15mmarczyk,(.getNamespace 'clojure.core/+)
18:15clojurebot"clojure.core"
18:15qbg,(namespace `+)
18:15clojurebot"clojure.core"
18:16mmarczykoh, missed the wrapper
18:16qbgfind-doc is useful
18:16SirNicksee what I'm trying to avoid is having to call it like this (feeds/fetch-cached feeds/feed-name)
18:16mmarczykright :-)
18:17mmarczykwell, if you're just going to evaluate something in a different namespace
18:17mmarczykhave a look at clojure.contrib.with-ns/with-ns maybe
18:17mmarczyk(with-ns feeds (fetch-cached feed-name))
18:18SirNickhmm that might work
18:18mmarczyknot a good idea if this should cause side effects in the current namespace, of course
18:18mmarczykbut for a pure function it works fine
18:20rhickeyhrm, clj: http://github.com/liebke/clj, but the shell script to run clojure is likely to be called clj...
18:21mmarczykSirNick: going funky (probably nonsensical, too) now: (clojure.walk/prewalk-replace #(if-let [v (and (symbol? %) (get (ns-publics 'feeds) %))] v %) '(fetch-cached feed-name)) ...use in a macro
18:22SirNickheh, wow, haven't been using clojure long enough to follow exactly what's going on there
18:22mmarczykrhickey: indeed it is... plus, is this significantly different from lein + plugins?
18:23technomancymmarczyk: it's remarkably similar to what I had in mind for lein 1.3 but haven't gotten around to implementing yet. =)
18:24mmarczyktechnomancy: I see... so now not only do we not use the well-established JVM-land build tools (because mvn is icky), but also have two build tools of our own? hm :-P
18:25mmarczykum, not really build tools, more like "dev environment setup tools"
18:26Raynestechnomancy: Speaking of leiningen, put out a new version already. You're slow, and I'm impatient. You've only got like 75 projects to work on, it isn't like you have time. ;)
18:26mmarczykah, scratch that... doesn't if lein doesn't need to duplicate that functionality
18:27technomancyRaynes: RC2 this weekend, dude
18:28RaynesI don't do release candidates, because I'll bork something. I just can't wait to do "lein upgrade". :D
18:33technomancyit's actually pretty easy to use a from-source lein now; the bootstrap process is way simplified.
18:33technomancycourse you can always wait too
18:35SirNickmmarczyk: This seems to work, but is it a good idea to do this way? http://gist.github.com/453545
18:37mmarczykSirNick: ah, that would be AWizzArd's suggestion
18:37mmarczyksure, if it makes life easier for you somehow
18:37SirNickAh, so that's what he was meaning... well good then, thanks to both of you
18:38riddochcHm. It looks to me like liebke's clj project overlaps slightly with leiningen or maven? This is interesting.
18:39riddochcOr not, I suppose. Looks like it's not doing build-systemy things.
18:40dnolenriddochc: it's much more like gems it seems to me. simpler though less flexible then lein. but perhaps easier for people new to clojure
18:43mmarczykits name clashes with my Python launcher for Clojure though -- grrr :-P
18:43dnolenalso simplifies writing a decent bundle for an editor like TextMate it seems.
18:45riddochcIts name clashes with my use of hashdot, too, but I suppose if clj becomes an "official" launcher, I wouldn't complain much.
18:45technomancyriddochc: you're using hashdot? sweet.
18:46riddochcAlternatively, we could look for a word for some mineral or rock that has the letters 'cl' in it somewhere.
18:46riddochcYeah, hashdot helps me keep my classpath sane.
18:48technomancyriddochc: does it have a sane build yet? I wanted to fix it, but the madness of makefiles plus .deb creation scared me off.
18:49riddochcOne thing I haven't done yet is figure out good way to develop a hashdot-based script with slime/swank...
18:50riddochcSane build? I don't know, it's not the simplest system possible, that's for sure, but it solves the problem for clojure, jruby, and sisc all at once.
18:50mmarczykriddochc: clinohumite :-P
18:50technomancywhen I was using it you had to manually edit the makefile to point to your java home... this was basically right after it came out though.
18:51technomancyI used to work with its author.
18:51riddochcFor most things I build from scratch, like hashdot, I do something like ./configure --prefix=/usr/local/stow and then use Gnu stow to manage a ton of symlinks from /usr/local/bin/x etc. to /usr/local/stow/package/bin/x etc.
18:51technomancycool
18:51mmarczykwhoa.
18:52riddochcI don't recall having to tell it to point to my java home, but it was a while ago I did it. Not sure.
18:53riddochcYeah, someone pointed me to gnu stow a few years ago, and it's become a seriously indespensible tool for me.
18:53riddochcI use it and a shell script to switch between a zillion versions of ruby, for example.
18:54mmarczykwhat OS?
18:55riddochcLinux, mainly. But I don't see why it wouldn't work on mac.
18:56riddochcSo, for example, I have /usr/local/stow/clojure-07f05862c2362f6b51e7c92ccd9476c45c9dff6e/lib/clojure.jar which is pointed to by a symlink, /usr/local/lib/clojure.jar To switch to a different version of clojure, I use stow like a package manager.
18:56mmarczykI'm a penguin too ;-)
18:57riddochcCool, mmarczyk. A lot of my fellow linux friends RL switched to apple systems over the years, I feel like a holdout.
18:58mmarczykyeah... a friend of mine who as good as introduced me to Linux has bitten the devilish apple too... now he calls my notifications service "growl" :-(
18:59riddochcAnyway, that's my system. Usually, my hashdot scripts reference jarfiles in /usr/local/lib/ so they follow the updates as I build new versions of things. When I need to refer to a specific version, I refer to files within /usr/local/stow/...
19:00riddochcThough now that I think of it, maybe I should have /usr/local/jar instead. I suppose jarfiles don't *really* belong in a lib directory.
19:04lpetitthinking about the fact that currently, in counterclockwise (and I guess in enclojure as well ?), we always AOT compile namespaces, "to be certain" that the relevant bits that must absolutely be AOT compiled "by essence" (generating java classes/interfaces/protocol interfaces/type classes for java interop) are AOT compiled
19:04RaynesThat's horrifying.
19:06lpetitwouldn't it make sense to have a mode where only those parts I qualified as "relevant" are AOT compiled ? that is only compile in memory everything, but genclasses, geninterfaces, protocol interfaces, definterfaces, type classes (close world of type of things which *need* to be AOT compiled for java interop)
19:06lpetit?
19:06mmarczyklpetit: could you possibly delegate some of the work to a build manager? say, use lein as a library?
19:07mmarczykor maybe clojure-maven-plugin if that's required to play nice with the ide
19:07lpetitmmarczyk: I don't see how lein could help. I want something totally automatic.
19:07riddochcI still seem to be tripping over issues related to AOT compiled stuff and version stuff.
19:07mmarczykwell, you could just allow the user to specify what needs to be aot'd
19:08lpetitI don't want my users to have to specify the list of namespaces to be AOT compiled. I even don't want "namespaces" to be AOT compiled. Only the relevant parts. If a namespace defines 3 regular functions and 2 protocols, I just want the interfaces related to the protocols
19:08mmarczykah, that's actually what you suggest
19:08mmarczykhmmm
19:08mmarczykoh, so it isn't.
19:08lpetitmmarczyk: that's exactly what I want to avoid :-)
19:08mmarczyklpetit: got that now :-)
19:09mmarczykI wonder if (binding [*compile-files* true] (eval '(definterface ...))) would do that...?
19:10lpetitthings that must be AOT compiled for java interop will always (in java) be things that can only be loaded once per JVM, I guess. I just want to minimize the disk I/O work while recompiling the whole project. And also minimize the number of files in the disk after a day full of work !
19:10riddochcWell, have fun clojuring. Gotta run.
19:11lpetit(because everytime a ns is recompiled, new function names appear in the classes/ folder ...)
19:11lpetitmmarrczyk: maybe. but, again, code cluttering ....
19:11mmarczyklpetit: ah, so you want a new, really fine-grained compile function
19:12lpetitmmarczyk: yes, balancing the potential virtues of that
19:12lpetits/balancing/contemplating/
19:12sexpbotmmarczyk: yes, contemplating the potential virtues of that
19:13mmarczykthat would be cool, especially since I guess interfaces don't really depend on Clojure, so they could be AOT'd and not break cross-clojure.jar compatibility
19:13mmarczykright?
19:15lpetitright for interfaces.
19:16lpetitfor types, I guess not right. for gen-classes, which generate stubs, I guess not right. :-(
19:20lpetittime to go to bed, let's continue this discussion later :)
19:23mmarczykgood night :-)
19:23ataggartOther than nil punning is there a rationale for using next vs rest? I tend to use next, but much of the code I see online is using rest.
19:25mmarczykrest is lazier
19:26mmarczyknext evaluates the head of its return value, whereas rest doesn't
19:26defnhttp://www.youtube.com/watch?v=KrfpnbGXL70
19:27defnlol.
19:27rfgdefn: Yeah, it's great :)
19:27ataggartmmarczyk: that was my thinking as well.
19:29defnThey enable us to send XML messages through SOAP. Through SOAP!"
19:31mmarczykdefn: that... is... AMAZING!!! :-DDD
19:31defnmmarczyk: :)
19:31defnI wish they would have mentioned Clojure in there
19:31defnthey only have Scala Johannson
19:32technomancyclojurebot: soap is <reply>"They enable us to send XML messages through SOAP. Through SOAP!!!" (http://www.youtube.com/watch?v=KrfpnbGXL70)
19:32clojurebotc'est bon!
19:32defnhahaha, well done technomancy
19:35defnlol I missed how his dad actually dies
19:36defnHis dad rips his shirt and finds the Java tattoo with a heart around it, bahahaha
19:36defnah man -- brilliant
19:37ataggartthe shutdown chime when the guest gags at the kids announcement: priceless.
19:37mmarczykthen he has "Where do you want to go today?" on his gravestone
19:37mmarczykjust watched again, still can't believe this :-D
19:49ataggarttechnomancy: do you foresee any reason to avoid augmenting lein to optionally process/emit dependencies a la ivy? There are a few cases I'm running into where maven's all-or-nothing approach is causing problems.
19:53technomancyataggart: I evaluated Maven, Ivy, and maven-ant-tasks before starting Leiningen, and the latter was the only one I could get working at all. I think it would be doable with Ivy, but it would be a lot of work, and I don't know what the benefits would be.
19:53technomancythat said, it would be easy to write a plugin that could emit an ivy.xml file which you could use for certain ivy-specific operations.
19:53ataggartivy's dependency system is far more flexible than maven's
19:54ataggartbasically ivy is a superset of maven w/r/t dependency management
19:54technomancysure, but maven's is a lot more flexible than leiningen's, and I've never found myself needing more flexibility than that. =)
19:54ataggartheh I do
19:55ataggartmaven's dependency stuff is pretty limiting for us
19:55technomancyI guess I would need to see some use cases.
19:57ataggartone hypothetical example would be c.c.logging emitting multiple configurations depending on what implementation you wanted to use
19:57ataggartso I could depend on a particular configuration of the logging lib, and only those transitive deps for that configuration would be pulled in
19:57ataggartnot every single possibly needed transitive dependency
19:58technomancyhmm... I still haven't figured out why you'd want to use c.c.logging against anything other than log4j, but maybe I'm missing something.
19:58technomancyit's not like you can have a medium-to-large-sized clojure project without already pulling in log4j. =)
19:58ataggartit was an example of the filtering of transitive dependencies
20:00ataggartfor a more real world example, we have a rest framework that supports representing resources as xml, json, etc. each of those are underpinned by a transitive lib. if one doesn't care about the json stuff, then one could depend on the rest framwork's "runtime" and "xml" configurations
20:00ataggartand only get those dependencies
20:01ataggartit's not a big deal when one has a shallow dependency tree, but for more complex systems without that kind of specification someone could end up pulling in many dozens of unneeded jars
20:02technomancyit seems like you could get close to the same effect by just splitting it into multiple artifacts
20:03technomancyI don't know... I'm unlikely to implement it myself. if you would like to experiment with it and try to determine if it'd be possible without doubling the complexity of the deps task, I might be convinced if it's clear people would use it.
20:03ataggartyes you could move the cost into the project organization, and break things up as needed, but sometimes that's not very useful when it's one new local class that needs some lib that in turn needs a dozen other libs
20:03ataggartit's already possible since I made it work
20:03ataggartI'm just trying to guage the pushback
20:05technomancywhy don't you ask on the mailing list to see if that problem is affecting many other users?
20:06ataggartk
20:11yacinare there already jars set up for clojure 1.2 for lein?
20:12technomancyyacin: [org.clojure/clojure "1.2.0-master-SNAPSHOT"] should do the trick
20:23technomancy(def foo (constantly (bar))) ;; <= bar is only evaluated at compile-time, right?
20:38hiredmantechnomancy: eh, functions are called at runtime
20:39technomancyhiredman: I mean bar isn't called for every call of foo.
20:40technomancy,(let [a (atom 0) foo (constantly (do (swap! a inc) :hi))] (foo) (foo) (foo) @a)
20:40clojurebot1
20:42tomojconstantly is a function, so
20:42technomancy(pardon the gratuitous do)
20:42technomancyyes, that. =)
21:28polypusanybody know why peek is not supported on a transient vector?
21:58ataggartpolypus: no one cared enough to submit a patch?
21:59ataggartbut since you know it's a vector: (let [t (transient [1 2 3])] (get t (dec (count t))))
22:06polypusataggart: ok, ty
22:09ataggartbtw why do you need peek if you're the one modifying the transient?
22:11polypusataggart: cuz i'm using it as a stack and it get recursed over
22:12ataggartk
22:13polypuss/get/sets
22:13polypuss/sets/gets :)
22:26RaynesIs there a way to run uncompiled clojure code inside of a jar? I think we need to get rid of jars and start using special cljars. :D
22:26tanobRaynes: I would name "clars" :)
22:27Raynes>_>
22:28lancepantzRaynes: you're actually not supposed to compile clojure inside of jars
22:28lancepantzwars you have to
22:29RaynesHuh?
22:29RaynesI'm not sure I caught that right.
22:29lancepantzi think i may be misunderstanding
22:29lancepantzbut you shouldn't put class files generated from cljs inside of jars
22:30tomojuncompiled clojure code in a jar works fine
22:30lancepantzthe idea being that your jars are not dependent on a specific version of clojure
22:30RaynesOh, I don't want to.
22:30Raynestomoj: Not if you're trying to *run* the code.
22:30polypusRaynes: if you do 'lein jars' and unzip the jar you'll see just plain uncompiled clojure files
22:31tomojoh, I see
22:31tomojno main class?
22:31hiredmanlancepantz: pretty sure you don't really need to in wars either
22:31RaynesI don't want to compile the code.
22:31RaynesI'm just saying. There is no way to package up a Clojure application without compiling the code, as far as I know.
22:31hiredmanyou just need a compiled servlet class and it can load and compile clojure at runtime
22:32polypusRaynes: just try lein jars. no compilation involved
22:32RaynesThat doesn't help.
22:32tomojcertainly need compilation
22:32tomojof _something_ anyway
22:32lancepantzhiredman: that may be true
22:32hiredmanRaynes: https://www.assembla.com/spaces/clojure/tickets/315-add-support-for-running--main-namespace-from-clojure-main-without-aot
22:34tomojthat wouldn't help for a runnable jar, would it?
22:34RaynesYeah, it would.
22:34tomojrun some wrapper instead?
22:35RaynesIt's not hard to work around, but it sucks to have to work around it.
22:35RaynesIt will be really cool to be able to make use of jars without AOT.
22:35RaynesFor applications, I mean.
23:18RaynesIs there a way to stop Clojure from printing the already refers to warnings?
23:35Raynes,(clojure.contrib.string/ltrim " blah")
23:35clojurebot"blah"
23:58defnAnyone here meditate?