2011-06-17
| 00:27 | seancorfield | promise/deliver vs delay - if you know what the resulting expression is going to be but you just don't want it available at initialization time (because it depends on some as yet uncomputed value), is there any reason to use promise (and deliver it when said uncomputed value is computed) vs delay (assuming you know it will never be accessed until after said value is computed? |
| 00:27 | seancorfield | it feels like using promise/deliver is "side-effecty" and not very functional... |
| 00:37 | ViciousPlant | \/join #python |
| 01:16 | zakwilson | I got to talk about Clojure to a .NET meetup I randomly went to because its organizer said it would be about things other than .NET. I wish I'd been more organized. |
| 02:32 | Scriptor | is there a nice way to view all the clojars besides http://clojars.org/repo? Alternatively is there a clojure lib for scraping clojars? |
| 02:42 | raek | seancorfield: I'm curious... what lead to the cyclic dependency? |
| 02:46 | tomoj | can you generate an efficient permutation on longs using a seeded Random? or do you need a skippable random? |
| 03:26 | nathanmarz | tomoj: i don't think so -- the docs for random say it won't generate all possible longs. I think you can do it by using the lower or upper half of a UUID |
| 03:28 | tomoj | hmm |
| 03:28 | tomoj | that will give me one piece of one permutation |
| 03:30 | tomoj | but how to generate the UUIDs repeatedly when you don't know which longs you'll need? |
| 03:30 | tomoj | s/repeatedly/repeatably/ |
| 03:30 | nathanmarz | oh you want it to be repeatable |
| 03:30 | nathanmarz | no idea there |
| 03:33 | tomoj | actually.. |
| 03:33 | tomoj | I think the problem is finding f so that (f seed) returns a pseudorandom bijection on the longs |
| 03:34 | tomoj | but since it's the longs, I bet having (f seed) just be a hash function would work well enough |
| 03:35 | tsdh | If there is some java method setFoo(Map<String, Integer>), can I call that from clojure with (.setFoo my-obj {"One" 1, "Two" 2})? |
| 03:38 | raek | tomoj: it might be possible to use a Linear Feedback Shift Register: http://en.wikipedia.org/wiki/Linear_feedback_shift_register |
| 03:39 | raek | I think I have read somewhere that you can configure the polynom so that for x bits, it will step through each of the 2^x states once, except for the all-zero one |
| 03:42 | tomoj | http://www.cs.rit.edu/~ark/pj/doc/edu/rit/util/DefaultRandom.html |
| 03:42 | tomoj | I wonder if that one has that property |
| 03:42 | tomoj | if so it would be especially convenient |
| 03:43 | tomoj | because it can skip to any step very quickly |
| 03:45 | tomoj | wow, it's so simple https://gist.github.com/85e0c07a7cbfe7367d75 |
| 04:17 | tomoj | that supposedly has a period of about 2^64, but you pass a positive long to skip ahead |
| 04:17 | tomoj | so you need two skips to exhaust the period? |
| 04:24 | tomoj | indeed |
| 04:29 | TobiasRaeder | Morning :) |
| 04:44 | tsdh | Is clojure.org down? |
| 04:47 | tsdh | Hm, works again... |
| 04:52 | tsdh | Is there some conversion utility to convert clojure collections to java collections? Like [1 2 3] ==> ArrayList<Integer>, {"1" 1, "1" 2} ==> HashMap<String, Integer>,... |
| 04:58 | sids | tsdh: clojure collections already implement the java collection interfaces |
| 04:59 | sids | ,(isa? (type []) java.util.List) |
| 04:59 | clojurebot | true |
| 04:59 | tsdh | sids: Yes, but that doesn't help when you need to set java attributes of Collection/Map types. |
| 05:01 | tsdh | Oh, wait. My test was wrong... |
| 05:02 | sids | you can get an an ArrayList from a vector like: ##(java.util.ArrayList. [1 2 3]) |
| 05:02 | sexpbot | ⟹ #<ArrayList [1, 2, 3]> |
| 05:05 | tsdh | Hm, but that doesn't work recursively. ,(java.util.ArrayList. [ [1 2 3] [4 5 6] ]) |
| 05:05 | tsdh | ##(java.util.ArrayList. [ [1 2 3] [4 5 6] ]) |
| 05:05 | sexpbot | ⟹ #<ArrayList [[1 2 3], [4 5 6]]> |
| 05:05 | fliebel | tsdh: check clojure.walk |
| 05:07 | tsdh | fliebel: Yes, I've already used it. Just wanted to be sure there's no existing solution. |
| 05:07 | raek | tsdh: why is it not enough to use the clojure data structures directly in your case? |
| 05:09 | tsdh | I work with some java lib, and when I invoke some java setFoo(List<String>) from clojure, it will most probably work, but as soon someone tries to use getFoo().add("Hi there"), he'll get an UnsupportedOperationException. |
| 05:10 | raek | ah, you need the mutation... |
| 05:10 | tsdh | Not *me*, *they*. :-) |
| 05:11 | raek | a recursivly define function would be very easy to write |
| 05:11 | raek | -d |
| 05:12 | raek | but protocols would be nice here |
| 05:13 | tsdh | raek: Yeah, I already have some defmulti for the other way round. Unpacking some java union-like type into native clojure structures. |
| 05:24 | raek | tsdh: my idea: https://gist.github.com/1031113 |
| 05:25 | tsdh | raek: Hey, very nice! |
| 05:32 | tsdh | raek: Plugged it in, tested it, and it works fine. |
| 05:49 | raek | tsdh: this might not work. there is an ambiguity in the dispatch since a PersistentList is both a ISeq and an Object. maybe a multimethod with a default implementation is better |
| 05:51 | tsdh | raek: Anything is an Object. Does the order of classes in extend-protocol not determine the exact dispatching? |
| 05:54 | raek | tsdh: it does not |
| 05:58 | tsdh | raek: Hm, ok. We support only a small range of attribute types, so I guess I would be fine if I delete Object and add Number, String, Boolean explicitly instead, right? |
| 06:02 | raek | tsdh: drop-in replacement with multimethods: https://gist.github.com/1031156 |
| 06:02 | raek | tsdh: mm, yes. I think so |
| 06:05 | tsdh | raek: I think I go with the modified protocol version. It might be faster and I get an error if I've forgotten some type. |
| 06:06 | raek | (discussion: http://groups.google.com/group/clojure-dev/browse_thread/thread/fb3a0b03bf3ef8ca/2b5701b57a28236b) |
| 06:08 | ilyak | Is there something like (map but not lazy? |
| 06:09 | ilyak | something that eagerly applies a function to each seq element |
| 06:10 | raek | ilyak: (doall (map ...)) |
| 06:10 | tsdh | ilyak: (doall (map ...))? |
| 06:10 | tsdh | Haha! |
| 06:11 | tsdh | :-) |
| 06:11 | tsdh | raek: You were faster, but I typed in one more char. |
| 06:11 | raek | ilyak: if you don't care about the values, use (dorun (map ...)) or (doseq [element coll] ...) |
| 06:12 | raek | doseq has the same syntax as for and can be defined as (dorun (for ...)) |
| 06:13 | ilyak | raek: That's two levels of indentation |
| 06:13 | ilyak | I guess I have to do my own domap |
| 06:15 | raek | ilyak: doseq is only one level |
| 06:17 | ilyak | nope, doseq is at least five |
| 06:17 | ilyak | because "coll" gets really really pushed right |
| 06:18 | ilyak | the problem with let-style [bin dings] |
| 06:18 | ilyak | is that they indent really bad if there's something complex in there |
| 06:29 | raek | then you can break up the complex stuff in with helper functions or let some of the parts |
| 06:34 | tsdh | In clj 1.3, is the doc function gone? |
| 06:37 | clgv | tsdh: not that I heard of |
| 06:38 | tsdh | Got it. It's in the clojure.repl namespace which is not used by default. |
| 06:39 | clgv | tsdh: it's used in the repl by default I guess ;) |
| 06:41 | tsdh | clgv: No, that's the problem. At least not in the REPLs I get with "lein repl" or SLIME. |
| 06:41 | clgv | tsdh: oh ok. |
| 06:41 | clgv | I had clojure 1.3 running in CCW |
| 06:42 | clgv | but I don't know if there is a possible scenario of a clojure 1.2 repl implementation running 1.3 inside |
| 06:42 | clojurebot | Alles klar |
| 06:42 | clgv | clojurebot: aber sicher doch |
| 06:42 | clojurebot | I don't understand. |
| 06:43 | tsdh | clgv: What version? I've seen some discussion on the net that said only version of clojure 1.3 starting with alpha4 are affected. |
| 06:45 | clgv | tsdh: what exactly do you mean? I ran the current CCW with a clojure 1.3 alpha8 1-2 weeks ago |
| 06:48 | tsdh | clgv: Hm, ok. I use a very recent git version which I frequently update. But I'm pretty sure I have that clojure.repl is not loaded behavior since I've switched to 1.3 a few month ago. |
| 06:49 | tsdh | clgv: Maybe CCW knows about this and executes (use 'clojure.repl) for you. |
| 06:50 | clgv | tsdh: likely. they don't simply start a clojure.main/repl but use nrepl |
| 06:57 | jonasen | Another proof reading / feedback request: https://github.com/jonase/mlx/wiki/Lottery |
| 07:32 | fliebel | Reading this, I'm wondering, will the work for Clojure, or is the JVM to bloated for that? http://www.lowendbox.com/blog/yes-you-can-run-18-static-sites-on-a-64mb-link-1-vps/ |
| 07:33 | fliebel | Running Clojure rockets to 80MB instantly, but even before Android, phones ran Java, so what gives? |
| 07:34 | fliebel | Is it just a matter of choosing a smaller heap size? |
| 07:41 | raek | (re-find #"^...$" s) == (re-matches #"..." s) |
| 08:46 | mattmitchell | is it possible to have a defmacro define multiple argument sets? |
| 08:46 | stuartsierra | sure, just like a function |
| 08:47 | pdk | (doc defmacro) |
| 08:47 | clojurebot | "([name doc-string? attr-map? [params*] body] [name doc-string? attr-map? ([params*] body) + attr-map?]); Like defn, but the resulting function name is declared as a macro and will be used as a macro by the compiler when it is called." |
| 08:47 | pdk | (defmacro foo ([arg1 arg2] ...) ([arg1 arg2 arg3] ...)) |
| 08:48 | mattmitchell | strange, what do you guys think the problem might be with this: https://gist.github.com/1031351 |
| 08:53 | raek | mattmitchell: you don't syntax-quote the single-arg version |
| 08:54 | raek | so you call the macro itself during macro expansion time |
| 08:54 | raek | ([body] `(with-server default-core ~body)) |
| 08:55 | pdk | if one of the arguments in the 2 arg version is optional |
| 08:55 | pdk | it's not gonna have an easy time telling which to run :p |
| 08:55 | mattmitchell | ahh ok! |
| 08:55 | mattmitchell | that makes sense |
| 08:55 | mattmitchell | pdk: yeah, i thought about that too |
| 08:56 | mattmitchell | pdk: maybe using a pre condition on the server-name arg? |
| 08:59 | raek | ,((fn ([_] :one) ([_ & _] :many)) 1) |
| 08:59 | clojurebot | :one |
| 12:10 | clgv | s/clojar/clojure/ |
| 12:10 | sexpbot | <clgv> always wanted a clojure slingshot :D |
| 12:17 | clgv | hmmm is it safe to use 'use multiple times? |
| 12:17 | gfrlog | what would be unsafe about it? |
| 12:17 | clgv | I mean multiple times for the same namespace in the same file? |
| 12:18 | gfrlog | why would you do that? normally you utilize (:use) within the (ns) declaration anyhow |
| 12:19 | gfrlog | I don't think I've ever written (use ...) within a clojure file |
| 12:20 | clgv | I build a DSL where I only want to have one (:use ..) in (ns ..) to keep it short, but I will have to load some other files which I want to do via a setup macro that I have to use anyway. |
| 12:20 | clgv | but it seems safe to call 'use multiple times for the same namespace |
| 12:21 | gfrlog | it might well be that calling it the second time has no effect unless you give it the :reload option |
| 12:21 | clgv | &(doc use) |
| 12:21 | sexpbot | ⟹ "([& args]); Like 'require, but also refers to each lib's namespace using clojure.core/refer. Use :use in the ns macro in preference to calling this directly. 'use accepts additional options in libspecs: :exclude, :only, :rename. The arguments and semantics for :exc... http://gist.github.com/1031738 |
| 12:22 | clgv | ,(doc use) |
| 12:22 | clojurebot | "([& args]); Like 'require, but also refers to each lib's namespace using clojure.core/refer. Use :use in the ns macro in preference to calling this directly. 'use accepts additional options in libspecs: :exclude, :only, :rename. The arguments and semantics for :exclude, :only, and :rename are the same as those documented for clojure.core/refer." |
| 12:22 | clgv | there is a :reload option? |
| 12:23 | gfrlog | yeah it's weird that it's not mentioned there. I use it in the repl all the time. |
| 12:23 | gfrlog | I bet the emacs folks don't need to bother with all that, so I can see how you might never need to know about it |
| 12:24 | clgv | I dont use emacs ;) |
| 12:24 | gfrlog | ~guards |
| 12:24 | clojurebot | SEIZE HIM! |
| 12:25 | technomancy | ~botsnack |
| 12:25 | clojurebot | thanks; that was delicious. (nom nom nom) |
| 12:25 | gfrlog | clojurebot needs to eat after a good seizing |
| 12:26 | arohner | does anyone have experience using c.c.lazy-xml on documents larger than RAM? |
| 12:27 | no_mind | is it possible to convert a lazy sequence to a list ? |
| 12:28 | gfrlog | ,(class (list* (range 10))) |
| 12:28 | clojurebot | clojure.lang.ChunkedCons |
| 12:28 | clgv | xml documents larger than RAM: for that document I wonder what the average information per symbol is |
| 12:28 | gfrlog | no_mind: for most purposes there's no distinction |
| 12:29 | gfrlog | clgv: 1/100 of a bit? :) |
| 12:29 | clgv | &(type (doall (range 10))) |
| 12:29 | sexpbot | ⟹ clojure.lang.LazySeq |
| 12:29 | clgv | humm no list obviously... |
| 12:29 | gfrlog | still a lazy seq, just already realized |
| 12:29 | gfrlog | ,(class (list* (range 100000000000))) |
| 12:29 | clojurebot | java.lang.ExceptionInInitializerError |
| 12:29 | clgv | gfrlog: lol @ 1/100 bit ;) |
| 12:29 | gfrlog | ,(class (list* (range 1000000))) |
| 12:29 | clojurebot | clojure.lang.ChunkedCons |
| 12:30 | gfrlog | hmmmm |
| 12:30 | gfrlog | ,(class (list* (range))) |
| 12:30 | clojurebot | clojure.lang.ChunkedCons |
| 12:30 | gfrlog | weird |
| 12:30 | no_mind | gfrlog: I am generating nodes for enlive. Where I use map to geenrate nodes, I get clojure.lang.LazySeq@905c02 in the output |
| 12:31 | gfrlog | no_mind: if you're converting to string, try pr-str instead of str |
| 12:31 | gfrlog | ,((juxt pr-str str) (range 10)) |
| 12:31 | clojurebot | ["(0 1 2 3 4 5 6 7 8 9)" "clojure.lang.LazySeq@9ebadac6"] |
| 12:32 | no_mind | gfrlog: nah, I need list not str |
| 12:32 | arohner | clgv: I can tell you the doc is 6GB compressed, 30GB uncompressed. that should give you an approximation :-) |
| 12:33 | gfrlog | 8/5 bits of info per byte of xml |
| 12:33 | clgv | arohner: uhhh less than 1/5 bit already ;) but probably much more |
| 12:33 | scgilardi | :reload is mentioned in the doc for require |
| 12:33 | clgv | err less^^ |
| 12:34 | gfrlog | no_mind: I'm not sure what you mean by "get clojure.lang.LazySeq@905c02" then |
| 12:35 | gfrlog | scgilardi: ah hah -- right, because the doc for use refers to require |
| 12:36 | no_mind | gfrlog: the output shows clojure.lang.LazySeq@905c02 instead of html tags. Which means the lazy-seq is not returning the maps contained |
| 12:37 | gfrlog | no_mind: what is "the output"? |
| 12:37 | gfrlog | to me that implies you're converting the lazy seq to a string at some point |
| 12:37 | no_mind | gfrlog: leave it |
| 12:39 | gfrlog | ,(let [x (range 10)] (map str [x (list* x)])) |
| 12:39 | clojurebot | ("clojure.lang.LazySeq@9ebadac6" "(0 1 2 3 4 5 6 7 8 9)") |
| 13:07 | amalloy- | raek, tsdh: you can defmethod Object without worrying about order/overriding, because the multimethod dispatch will check isa? and find the most specific impl |
| 13:16 | Cozey | good day. Is there a way to add system-scoped jars to cake project? |
| 13:18 | amalloy- | Cozey: there might be, but you shouldn't |
| 13:18 | amalloy- | hm. my bouncer seems to be stealing the plain "amalloy" nick |
| 13:19 | gfrlog | well that was fun |
| 13:19 | amalloy- | gfrlog: that's bizarre. it won't let me. this is like being homeless |
| 13:19 | gfrlog | yes, just like it |
| 13:19 | halfprogrammer | gfrlog: amalloy: wat u guys up to? |
| 13:19 | Cozey | ok so how should I do this: I will deploy to a container, which provides javax.mail.* classes, but for running tests etc i should have this jar somehow added to the project. |
| 13:20 | gfrlog | halfprogrammer: mischief? |
| 13:20 | justinko | how do I get a symbol's id? |
| 13:20 | halfprogrammer | swapping identities |
| 13:20 | justinko | the "unique identifer" |
| 13:20 | dnolen | justinko: ? |
| 13:20 | amalloy | you can do anything with juxt |
| 13:20 | justinko | dnolen: the hash id |
| 13:21 | amalloy- | gfrlog: i guess i don't understand irc at all. i have that nick registered, even |
| 13:21 | dnolen | ,(hash 'foo) |
| 13:21 | clojurebot | -1634041172 |
| 13:21 | dnolen | ,(hash 'bar) |
| 13:21 | clojurebot | -1634229906 |
| 13:21 | gfrlog | amalloy-: I don't think the NickServ asked me for a pw; but I'm in ERC so I'm not really sure of anything |
| 13:22 | dnolen | justinko: I don't think those are guaranteed to be unique tho. |
| 13:22 | dnolen | justinko: do you just want to check for object equality? |
| 13:22 | justinko | dnolen: sorry, I meant its function representation |
| 13:22 | halfprogrammer | gfrlog: you started using emacs! |
| 13:23 | gfrlog | amalloy-: I guess the only reasonably way to deal with this is for you to consider me your voice from this point forward. If you ever want to say anything, just let me know. |
| 13:23 | gfrlog | halfprogrammer: so far just for IRC |
| 13:23 | dnolen | justinko: ? |
| 13:23 | justinko | dnolen: the stuff that looks like adfs@fUre74s |
| 13:23 | gfrlog | man my fingers are always typing "reasonably" for "reasonable" |
| 13:23 | dnolen | justinko: that's just Clojure munging to generate class names for fns. |
| 13:23 | halfprogrammer | gfrlog: have fun |
| 13:24 | kryft | Are there fancier repls available than the standard + jline? |
| 13:24 | dnolen | kryft: cake |
| 13:24 | amalloy- | emacs |
| 13:24 | gfrlog | halfprogrammer: I gotta do things like google for how to switch buffers :( |
| 13:24 | hiredman | https://github.com/hiredman/Repl |
| 13:25 | justinko | dnolen: fns? |
| 13:25 | dnolen | justinko: functions. |
| 13:25 | hiredman | http://www.thelastcitadel.com/images/Screenshot-Repl.png |
| 13:25 | dnolen | ,(fn []) |
| 13:25 | clojurebot | #<sandbox$eval142$fn__143 sandbox$eval142$fn__143@92d6d2> |
| 13:25 | dnolen | justinko: every function generates a class. |
| 13:25 | halfprogrammer | gfrlog: ha ha ha. There is a w3m mode available in emacs for web surfing. use that :P |
| 13:26 | gfrlog | oh heavens |
| 13:26 | kryft | dnolen: Thanks. |
| 13:26 | justinko | dnolen: (def a "foo") <-- is there a unique identifier (or id) for this? |
| 13:26 | justinko | dnolen: for "a" |
| 13:26 | kryft | hiredman: Your repl attained perfection in January 2010?-) |
| 13:27 | hiredman | Yes |
| 13:27 | dnolen | justinko: if such a thing a did exist, what would it be useful for? |
| 13:27 | Cozey | ok, this is the answer to my question: http://maven.apache.org/guides/mini/guide-coping-with-sun-jars.html |
| 13:27 | hiredman | (fyi it spins up 23 threads at start) |
| 13:27 | chouser | justinko: like this? ## (var a) |
| 13:27 | sexpbot | java.lang.Exception: Unable to resolve var: a in this context |
| 13:28 | chouser | bleh. #'user/a |
| 13:28 | gfrlog | ,(let [a 10] (var a)) |
| 13:28 | clojurebot | java.lang.Exception: Unable to resolve var: a in this context |
| 13:28 | gfrlog | what are function parameters? |
| 13:28 | chouser | locals |
| 13:28 | chouser | not vars |
| 13:28 | amalloy | gfrlog: not easily accessible |
| 13:28 | gfrlog | locals is the formal term? |
| 13:29 | chouser | well. formally they're variables in the mathematical sense |
| 13:29 | gfrlog | but if we're discussing what (let ...) does, we would talk about locals? |
| 13:29 | chouser | but locals highlights both that they're immutable and that they always have lexical scope |
| 13:30 | chouser | That's the term Rich suggested once, and I like it. |
| 13:30 | gfrlog | sounds good to me |
| 13:30 | kryft | chouser: I love the final version of JoC, by the way. It inspired me to resume my learning project which was temporarily shelved before Christmas. |
| 13:30 | justinko | in Ruby, you can call .object_id on any object, and it is guaranteed to be unique |
| 13:30 | chouser | kryft: excellent! |
| 13:31 | hiredman | justinko: ick |
| 13:31 | justinko | (I ordered JoC last night) |
| 13:31 | amalloy | justinko: that doesn't really exist |
| 13:31 | hiredman | doing things that rely on pointer identity is icky |
| 13:31 | kryft | chouser: Actually that's what inspired my repl question, as I was just about to try the interactive examples in chapter three. :) (Or, er four, or whatever it was. I've had too much work and too little sleep.) |
| 13:32 | amalloy | hiredman: meh. often that's true, but eg keywords are interned and that's useful |
| 13:32 | seancorfield | raek: sorry i missed you re: cyclic dependency last night |
| 13:32 | dnolen | justinko: but what do people use actually .object_id for? |
| 13:32 | justinko | I'm just playing around in the repl and just wanted to see how things relate to each other: (def a "foo") (def b a) |
| 13:32 | gfrlog | amalloy: that's a performance thing, not a functionality thing |
| 13:33 | amalloy | gfrlog: i could probably be convinced, but that was not my previous understanding |
| 13:33 | seancorfield | the cyclic dependency was compiling file A (a log4j appender) which depended on file B which depended on ... which imported c3p0 which relied on log4j which tried to load the appender in its initializer (while it was still being compiled) |
| 13:33 | gfrlog | justinko: oh man, now you're going to have to find out about vars |
| 13:34 | justinko | dnolen: If there is an array of "foo"'s, and I want to get a specific "foo", I can find it via its object_id |
| 13:34 | gfrlog | amalloy: what was your understanding? My assumption is they are interned for faster comparisons |
| 13:34 | amalloy | justinko: you can use ##(identical? 'a 'a) to test for that sort of thing |
| 13:34 | sexpbot | ⟹ false |
| 13:34 | dnolen | justinko: but doesn't Ruby have an object identity equality operator? |
| 13:34 | gfrlog | ,(let [x "foo"] [(identical? x x) (identical? x "foo")]) |
| 13:34 | clojurebot | [true true] |
| 13:35 | amalloy | gfrlog: i guess maybe that's all it is |
| 13:35 | amalloy | i can't think of any other specific benefits |
| 13:35 | gfrlog | amalloy: although the results of that last call to clojurebot are making me question everything |
| 13:35 | justinko | yes, you don't really need to ever use object_id, I just use it to look at things "under the hood" |
| 13:36 | amalloy | gfrlog: java interns strings in some circumstances but not all |
| 13:36 | gfrlog | amalloy: compiler optimization? |
| 13:36 | gko | How to I change the value of clojure.java.javadoc/*core-java-api* in user.clj? |
| 13:36 | gfrlog | ,(let [is-foo? #(= % "foo")] (is-foo? "foo")) |
| 13:36 | clojurebot | true |
| 13:36 | amalloy | &(let [x "foo" y (str "fo" "o")] (identical? x y)) |
| 13:36 | sexpbot | ⟹ false |
| 13:36 | dnolen | justinko: yeah there's nothing like that in Clojure, tho as you say, it's not really a useful feature. |
| 13:36 | gfrlog | ah hah |
| 13:36 | gfrlog | there it goes |
| 13:36 | chouser | sybols aren't interned the way keywords are, because they support metadata |
| 13:37 | chouser | but Java is free to intern strings |
| 13:37 | amalloy | gfrlog: iirc java interns any string that appears as a constant in a source file, basically |
| 13:37 | gfrlog | that is sensible |
| 13:37 | amalloy | strings you compute on the fly aren't interned |
| 13:37 | chouser | if anything, all this shows why you generally don't want to be using 'identical?' |
| 13:38 | justinko | ,#(symbol "foo") |
| 13:38 | clojurebot | #<sandbox$eval154$fn__155 sandbox$eval154$fn__155@67e92a> |
| 13:38 | dnolen | chouser: except when you need to ;) |
| 13:38 | chouser | right-o |
| 13:38 | amalloy | justinko: just the , will do. or & if you want to talk to sexpbot; no # |
| 13:39 | amalloy | the ##(+ 1 2) notation is for evals embedded in conversation, and needs two #s |
| 13:39 | sexpbot | ⟹ 3 |
| 13:40 | justinko | ,#(keyword "foo") |
| 13:40 | clojurebot | #<sandbox$eval158$fn__159 sandbox$eval158$fn__159@b11287> |
| 13:40 | justinko | that's guaranteed to be unique, right? |
| 13:40 | amalloy | uh |
| 13:40 | amalloy | as long as, again, you stop putting # in there |
| 13:40 | amalloy | #(...) is defining a new anonymous function and then throwing it away, so it will be different every time |
| 13:40 | justinko | amalloy: I meant to do that |
| 13:41 | gfrlog | Object#hashCode says it usually returns the object's address, if not overridden |
| 13:41 | justinko | ohhh okay |
| 13:41 | amalloy | ,[#(keyword "foo"), #(keyword "foo)] |
| 13:41 | clojurebot | EOF while reading string |
| 13:41 | dnolen | justinko: but it's generally overidden in Clojure. |
| 13:41 | amalloy | ,[#(keyword "foo"), #(keyword "foo")] |
| 13:41 | clojurebot | [#<sandbox$eval162$fn__163 sandbox$eval162$fn__163@157011e> #<sandbox$eval162$fn__165 sandbox$eval162$fn__165@ac8360>] |
| 13:41 | gfrlog | ,(.hashCode (new Object)) |
| 13:41 | clojurebot | 3411100 |
| 13:41 | amalloy | dnolen: you can get at it anyway though |
| 13:42 | amalloy | i think it's in System |
| 13:42 | hiredman | justinko: are you sure you just don't want to call gensym? |
| 13:42 | gfrlog | ,(System.identityHashCode :foo) |
| 13:42 | clojurebot | java.lang.ClassNotFoundException: System.identityHashCode |
| 13:42 | gfrlog | ,(System/identityHashCode :foo) |
| 13:42 | clojurebot | 25476649 |
| 13:42 | amalloy | &(let [x "test"] [(hash x) (System/identityHashCode x)]) |
| 13:42 | sexpbot | ⟹ [3556498 2933385] |
| 13:42 | gfrlog | how do I browse my previous statements in ERC? |
| 13:43 | amalloy | M-p, M-n |
| 13:43 | gfrlog | like up-arrow in other clients |
| 13:43 | gfrlog | very good |
| 13:43 | gfrlog | thx |
| 13:43 | amalloy | gfrlog: that's another nice thing about emacs. i don't use erc, but M-p is used all over so i figured it'd be right |
| 13:44 | Scriptor | previous/next sentence |
| 13:44 | gfrlog | funny I can loop back to the beginning of the history with M-n |
| 13:44 | amalloy | Scriptor: except when it does something else :P |
| 13:44 | gfrlog | see stuff I said yesterday |
| 13:45 | Scriptor | ooh, that reminds me |
| 13:45 | Scriptor | is there a nice way to view all the clojars besides http://clojars.org/repo? Alternatively is there a clojure lib for scraping clojars? |
| 13:45 | technomancy | Scriptor: there's lein-search |
| 13:45 | clojurebot | Huh? |
| 13:46 | technomancy | it uses lucene rather than scraping in recent versions |
| 13:46 | technomancy | https://github.com/technomancy/lein-search/tree/lucene if you are not on the latest from git |
| 13:46 | technomancy | works with other mvn repos too |
| 13:46 | halfprogrammer | gfrlog: C-h m - This will list down all the possible key combinations for the current buffer |
| 13:47 | halfprogrammer | gfrlog: C-h k - Takes a input key combination and will tell you what it will do. |
| 13:47 | amalloy | halfprogrammer: untrue |
| 13:47 | Scriptor | technomancy: thanks! |
| 13:47 | amalloy | C-h m displays mode-specific bindings; C-h b displays all |
| 13:48 | halfprogrammer | I said for the current buffer. So whatever is applicable for the current modes :) |
| 13:49 | amalloy | halfprogrammer: that wouldn't list C-b, for example |
| 13:49 | amalloy | granted he might not want that |
| 13:49 | halfprogrammer | hmm |
| 13:52 | gfrlog | can I use VIM from emacs? |
| 13:52 | Scriptor | supposedly |
| 13:52 | arunkn | why would you want that? |
| 13:52 | gfrlog | then I would know how to use emacs |
| 13:52 | amalloy | gfrlog: (1) M-x shell, (2) vim, (3) cry |
| 13:53 | arunkn | gfrlog: (4) use emacs again |
| 13:53 | gfrlog | I use vim because an old mathematician/CS-prof told me to |
| 13:53 | justinko | dnolen: you're right, hash isn't guaranteed to be unique: http://stackoverflow.com/questions/909843/java-how-to-get-the-unique-id-of-an-object-which-overrides-hashcode |
| 13:54 | amalloy | srsly though even if you love vim that would make you cry. emacs/shell will mess up all the vim bindings |
| 13:54 | amalloy | &(hash "x") |
| 13:54 | sexpbot | ⟹ 120 |
| 13:54 | amalloy | &(hash 120) |
| 13:54 | sexpbot | ⟹ 120 |
| 13:54 | Scriptor | isn't there an emacs plugin for vim? |
| 13:54 | arunkn | I use vim when I am not using lisping. |
| 13:54 | arunkn | mostly |
| 13:54 | amalloy | Scriptor: viper |
| 13:54 | gfrlog | Object#hashCode isn't even guaranteed to be the address; docs just say it probably is |
| 13:54 | amalloy | oh, the other way around |
| 13:54 | kryft | Any vimpulse users here? |
| 13:54 | gfrlog | arunkn: it is possible to do both? |
| 13:55 | Scriptor | gfrlog: it's weird when you switch back |
| 13:55 | Scriptor | and you'll always be worse at one than the other, I think |
| 13:55 | halfprogammer | somewhat |
| 13:55 | gfrlog | Scriptor: it strikes me as being similar to trying to maintain qwerty and dvorak skills |
| 13:55 | gfrlog | or ruby and python :) |
| 13:56 | halfprogammer | sometimes i confuse the key bindings. but mostly I am okay with it |
| 13:57 | Scriptor | gfrlog: or xbox and ps3? :) |
| 13:57 | gfrlog | yes |
| 13:57 | gfrlog | or....pants and kilts? |
| 13:57 | halfprogammer | ha ha ha |
| 13:57 | Scriptor | but yea, I definitely still prefer vim for non-lispy stuff |
| 13:57 | Scriptor | (non-lispy coding) |
| 13:58 | gfrlog | Scriptor: what advantages does it have? I don't know of any, I'm just locked in |
| 13:58 | gfrlog | other than familiarity when shelling into an HPUX machine |
| 13:58 | amalloy | gfrlog: the main thing i hear cited is modal editing |
| 13:59 | aaelony | what is the most idiomatic way to "loop" over 2 or more collections in a nested fashion? Is something like (map #(myfn) %1) list) extensible to not only an i from 1 to n but also i & j, or even i & j & k ? |
| 13:59 | Scriptor | gfrlog: for emacs? The best sum-up I've heard is that emacs is a better dev environment, while vim is the better text editor (in terms of actually moving around making edits) |
| 13:59 | halfprogammer | gfrlog: you can edit things very fast. Has excellent plugin support. And as amalloy said, it has modal editing. |
| 13:59 | amalloy | aaelony: ##(doc for) is great |
| 13:59 | sexpbot | ⟹ "Macro ([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 ... http://gist.github.com/1031908 |
| 13:59 | gfrlog | if I abandon vim I could quit binding my capslocks to escape |
| 14:00 | amalloy | gfrlog: and bind it to ctl instead |
| 14:00 | gfrlog | haha |
| 14:00 | halfprogammer | gfrlog: it is especially useful when you are doing a ssh over a 56kbps line where echoing back the key you pressed takes abt 1 sec |
| 14:00 | amalloy | &(for [x (range 4) y (range 4)] [x y]) ; aaelony |
| 14:00 | sexpbot | ⟹ ([0 0] [0 1] [0 2] [0 3] [1 0] [1 1] [1 2] [1 3] [2 0] [2 1] [2 2] [2 3] [3 0] [3 1] [3 2] [3 3]) |
| 14:00 | Scriptor | heh, one nice thing about windows-on-macbook is that my thumb is always on C |
| 14:01 | aaelony | excellent, thanks! I like avoiding loop & recur :) |
| 14:01 | amalloy | aaelony: for is extremely powerful. read the docstring to see its other cool features |
| 14:02 | halfprogammer | am not too familiar with common lisp myself. but why does clojure not have CL style loop? |
| 14:02 | aaelony | amalloy: thanks, re-reading the documentation. Often the docs are written in a way that takes me a while to truly understand what the docs are intending to describe. |
| 14:02 | technomancy | halfprogammer: mostly because working with sequences is just more pleasant |
| 14:04 | halfprogammer | Its funny when CL books (land of lisp and practical common lisp) dedicate one full chapter to describe what a loop construct can do |
| 14:04 | amalloy | halfprogammer: probably not enough chapters |
| 14:04 | hiredman | can cl's loop execute in parallel? |
| 14:06 | dnolen | halfprogammer: from what I understood CL's loop is there because TCO is not a requirement for CL. Clojure has lazy-sequences / recur. |
| 14:06 | halfprogammer | hiredman: no idea |
| 14:06 | hiredman | answer is: no because the cl spec doesn't deal with threads at all |
| 14:07 | hiredman | setting aside the imperative nature of cl's loop |
| 14:07 | amalloy | dnolen: that seems overly specific; i think it's there because it lets you express a lot of notions compactly, much like clojure's for |
| 14:07 | amalloy | my main gripe is its imperative nature, as well |
| 14:08 | dnolen | amalloy: why? loop does what map/filter/reduce does in Clojure in constant space. |
| 14:08 | hiredman | clojurebot: what can the hyperspec tell us about this problem? |
| 14:08 | clojurebot | hyperspec is not applicable |
| 14:09 | hiredman | clojurebot: please solve my problems using the knowledge contained in the hyperspec |
| 14:09 | clojurebot | hyperspec is not applicable |
| 14:11 | chouser | When suggesting new features for 'for' or 'doseq', rhickey has at times pointed to the size of the docs for CL's LOOP as sufficient reason for why we don't want it. |
| 14:12 | hiredman | mmmm |
| 14:12 | chouser | hm. that was pithy and succinct in my head. oh well. |
| 14:12 | halfprogammer | hmm |
| 14:13 | amalloy | chouser: pithy, succint, concise, and terse? |
| 14:13 | chouser | amalloy: and also short |
| 14:19 | jweiss_ | in a construct like (take-while #(not (zip/end? %)) (iterate f root)), where f does stuff with the tree and returns zip/next, the seq stops one too soon. it doesn't process the last node. anyone know how to fix that? |
| 14:20 | hiredman | have f return [node (zip/next node)] |
| 14:22 | gfrlog | amalloy: how'd you get your nick back? |
| 14:22 | amalloy | gfrlog: went around znc and logged into freenode directly |
| 14:22 | amalloy | when Raynes wakes up or whatever, i'll make him explain irc to me again |
| 14:24 | amalloy-` | amalloy: maybe you could have used juxt? |
| 14:24 | gfrlog | so sorry |
| 14:24 | arohner | chouser: did your lazy-xml improvements get published anywhere? |
| 14:25 | halfprogammer | gfrlog: http://www.irchelp.org/irchelp/irctutorial.html |
| 14:25 | amalloy | i hope there's an etiquette section in there :P |
| 14:26 | gfrlog | halfprogammer: earlier amalloy was on the alternate nick "amalloy-" and for some reason I was able to switch to "amalloy" but he wasn't |
| 14:26 | Scriptor | gfrlog: it didn't ask you to auth with nickserv? |
| 14:26 | gfrlog | Scriptor: not that I noticed, which I thought was weird. But I'm on ERC so it's possible I didn't see it |
| 14:27 | Scriptor | the promp will show up in the mini-buffer thing at the bottom |
| 14:29 | chouser | arohner: they're wip in clojure.data.cml |
| 14:29 | chouser | clojure.data.xml |
| 14:29 | halfprogammer | gfrlog: http://www.magic-league.com/play/register_nick.php |
| 14:29 | halfprogammer | gfrlog: ^ how to register your nick |
| 14:29 | gfrlog | halfprogammer: yeah, both amalloy and I have done that |
| 14:29 | amalloy | halfprogammer: i get the feeling you're providing helpful advice to people who aren't here |
| 14:30 | gfrlog | amalloy: ? |
| 14:30 | amalloy | gfrlog: in the sense that this would be cool stuff to know but isn't really relevant to the issues you and i were having |
| 14:30 | gfrlog | gotcha |
| 14:31 | arohner | chouser: thanks |
| 14:31 | halfprogammer | amalloy: I thought you have not registred your nick and gfrlog was able to use your nick. My bad. |
| 14:31 | amalloy | halfprogammer: my nick is registered |
| 14:31 | amalloy | which is why i don't understand that gfrlog could use it |
| 14:31 | amalloy | and i couldn't :P |
| 14:32 | gfrlog | halfprogammer: the weird parts are 1) he IS registered and 2) he couldn't switch to it himself |
| 14:32 | Scriptor | I think gfrlog just missed the nickserv password prompt, it's not very obvious |
| 14:32 | gfrlog | anybody know any registered nicks I could try? |
| 14:32 | Scriptor | you can switch to a registered nick but only temporarily, I think |
| 14:32 | amalloy | Scriptor: if you can "miss" the password prompt it's not really securing anything, is it? |
| 14:32 | amalloy | i see |
| 14:32 | halfprogammer | try mine |
| 14:33 | gfrlog | halfprogammer: somebody not in the room I mean |
| 14:33 | gfrlog | erc automatically appends a punctuation apparently |
| 14:33 | halfprogammer | hmm |
| 14:33 | Scriptor | gfrlog: try Scriptonomicon |
| 14:33 | Scriptor | alt nick of mine |
| 14:33 | Scriptor | I think |
| 14:33 | Scriptonomicon | hmm |
| 14:33 | halfprogammer | hey, try rhickey :P |
| 14:33 | Scriptonomicon | I think something happened |
| 14:34 | Scriptor | alright, now is there a prompt at the very bottom? |
| 14:34 | Scriptonomicon | nothing obvious |
| 14:34 | Scriptonomicon | lemme check the buffer list |
| 14:34 | Scriptor | hmm, maybe I forgot to group it |
| 14:34 | Scriptonomicon | or just wait a minute and see if it kicks me out :) |
| 14:34 | Scriptonomicon | C-x o doesn't switch to anything... |
| 14:34 | no_mind | I have a map expresion which calls a function f returning map. The result of map expression is a sequence of maps as required. The problem is, for certain conditions, the function f called by map returns a sequence of maps instead of map. How do I ensure that the maps in the sequence of maps returned by f are merged with other maps ? |
| 14:34 | Scriptor | Scriptonomicon: that switches windows |
| 14:34 | Scriptor | try C-x b |
| 14:35 | jcromartie | How do I make "binding" play well with parallelized routines |
| 14:35 | Scriptonomicon | not seeing anything |
| 14:35 | gfrlog` | dangit |
| 14:35 | amalloy | no_mind: make it always return a sequance of maps, sometimes only one item long |
| 14:35 | jcromartie | hypothetically: I have a web app, and I want to render parts of it in parallel, and I use (binding [*user* current-user] (pmap render parts)) |
| 14:36 | Scriptor | gfrlog`: you do see a horizontal blank space right below your buffer, right? |
| 14:36 | amalloy | "sequance". incredible |
| 14:36 | jcromartie | instead of passing all of the interesting "global" (really per-request) special variables in to each function that might be interested in them |
| 14:36 | jweiss_ | hiredman, sorry, your earlier suggestion you meant (take-while (fn [[i j]] (not= i j)) (iterate f root)) |
| 14:36 | gfrlog` | Scriptor: yes |
| 14:36 | no_mind | amalloy: ok |
| 14:36 | Scriptor | and nothing showed up in there? |
| 14:36 | gfrlog` | no |
| 14:36 | amalloy | &(doc bound-fn) is often helpful for that, jcromartie |
| 14:36 | sexpbot | ⟹ "Macro ([& fntail]); Returns a function defined by the given fntail, which will install the same bindings in effect as in the thread at the time bound-fn was called. This may be used to define a helper function which runs on a different thread, but needs the same bindings in place." |
| 14:37 | Scriptor | weird |
| 14:37 | jcromartie | awesome, amalloy |
| 14:37 | gfrlog` | there's a "[i]" thing in the buffer status bar that I think highlighted when I first switched to Scriptonomicon |
| 14:37 | jcromartie | also http://cemerick.com/2009/11/03/be-mindful-of-clojures-binding/ |
| 14:37 | Scriptor | gfrlog`: right click it and it'll switch you to that |
| 14:37 | gfrlog` | amalloy: that is a terribly interesting function |
| 14:37 | gfrlog` | Scriptor: I'm using emacs over SSH, not sure right-clicking will be effective |
| 14:37 | halfprogammer | halfasleep. bfn |
| 14:37 | gfrlog` | didn't do anything |
| 14:38 | Scriptor | ah |
| 14:42 | gfrlog | so I guess it's probably my fault with ERC. still doesn't explain why amalloy couldn't switch though |
| 14:42 | amalloy | gfrlog: i assume that's an issue with my znc config somehow |
| 14:47 | arohner | chouser: I'm still seeing memory usage go up when doing (dorun (pull-parser/lazy-source-seq)) |
| 14:52 | amalloy | arohner: of course memory usage will go up. it's using memory. but it will be memory that's eligible for garbage collection, in theory |
| 14:57 | zerokarmaleft | https://gist.github.com/1032035 <= is this a result of floating point error or what? |
| 14:57 | opqdonut | no |
| 14:58 | opqdonut | the latter predicate is false for 2.725 |
| 14:58 | opqdonut | so no numbers are taken |
| 14:58 | opqdonut | you might've been looking for filter |
| 14:58 | zerokarmaleft | oh derp |
| 14:58 | opqdonut | or (take-while #(<= % upper) (drop-while #(< lower %) measurements)) |
| 14:59 | chouser | arohner: I've got unit tests in there that are meant to demonstrate that xml events and nodes are not being help unnecessarily. |
| 15:00 | chouser | arohner: if you can find or write a test like that which fails, that would be a huge help. |
| 15:01 | chouser | arohner: I haven't gotten around to testing large inputs yet, but in the small it seems to be working in several cases where it used to hold onto too much. |
| 15:04 | zakwilson | Is there a way to get ClojureQL to use fully qualified column names all the time? I want to be able to joins on tables that have columns of the same names and get back maps that aren't too hard to use in updates. |
| 15:28 | mattmitchell | how do i test if a variable is bound or unbound? |
| 15:28 | amalloy | &(doc bound?) |
| 15:28 | sexpbot | ⟹ "([& vars]); Returns true if all of the vars provided as arguments have any bound value, root or thread-local. Implies that deref'ing the provided vars will succeed. Returns true if no vars are provided." |
| 15:29 | chouser | huh. seems weird that's variatic |
| 15:29 | amalloy | mattmitchell: just too simple sometimes, eh? |
| 15:29 | amalloy | chouser: you'd prefer [vars], or [var]? |
| 15:31 | mattmitchell | amalloy: :) well I tried that, but seeing the docs there, I noticed that it takes a var, so I had to do (bound? (var my-un-bound-var)) |
| 15:31 | amalloy | indeed, or #'my-var |
| 15:31 | mattmitchell | amalloy: ahh ok coo |
| 15:32 | mattmitchell | cool that is |
| 15:32 | hiredman | only one usage in src/clj with a single arg |
| 15:35 | hiredman | clojurebot: unix vm is http://www.cs.gmu.edu/cne/itcore/virtualmachine/unix.htm |
| 15:35 | clojurebot | You don't have to tell me twice. |
| 15:36 | gfrlog | hiredman: does clojurebot keep old bindings? |
| 15:36 | hiredman | old bindings? |
| 15:37 | gfrlog | you just gave it a definition right? |
| 15:37 | gfrlog | bound "unix vm" to that url? |
| 15:38 | hiredman | yes, clojurebot stores them in a derby db on disk |
| 15:38 | gfrlog | and they can be overwritten? |
| 15:38 | hiredman | they can be deleted and added to |
| 15:38 | gfrlog | hmm |
| 15:38 | hiredman | (it is effectively a multi-map) |
| 15:39 | gfrlog | ah, so it gives a random value? |
| 15:39 | gfrlog | ~unix vm |
| 15:39 | clojurebot | unix vm is http://www.cs.gmu.edu/cne/itcore/virtualmachine/unix.htm |
| 15:39 | hiredman | yes |
| 15:39 | gfrlog | okay. then my question is less important. |
| 15:39 | gfrlog | I thought it would be worrying that good information gets overwritten |
| 15:39 | hiredman | and you and specify other relations besides 'is' |
| 15:40 | hiredman | clojurebot: two things |are| more than one thing |
| 15:40 | clojurebot | You don't have to tell me twice. |
| 15:40 | gfrlog | clojurebot: unix vm isn't http://www.yahoo.com |
| 15:40 | clojurebot | it's a UNIX system! I know this! |
| 15:40 | hiredman | clojurebot: two things? |
| 15:40 | clojurebot | two things are more than one thing |
| 15:40 | gfrlog | ~two things |
| 15:40 | clojurebot | two things are more than one thing |
| 15:40 | hiredman | for relationships besides 'is' you use the pipe syntax |
| 15:40 | gfrlog | so just for grammar? |
| 15:41 | hiredman | for now |
| 15:41 | gfrlog | cool |
| 15:42 | Evious | Are there any good guides/tutorials/references about functional programming in Clojure? Specifically, the macros/conventions/tricks developed for said purpose? |
| 15:42 | hiredman | clojurebot's data layer is kind of disgusting |
| 15:42 | gfrlog | :) |
| 15:43 | Scriptor | wait, clojurebot can be trained? |
| 15:43 | gfrlog | clojurebot: Scriptor |doesn't| know you can be trained |
| 15:43 | clojurebot | You don't have to tell me twice. |
| 15:43 | gfrlog | clojurebot: Scriptor? |
| 15:43 | clojurebot | Scriptor doesn't know you can be trained |
| 15:44 | gfrlog | aw dang |
| 15:44 | Scriptor | gfrlog: sit |
| 15:44 | Scriptor | I guess you might need to indicate what 'you' is referring to |
| 15:45 | gfrlog | it's got a bit of templating I think...at least for nicks |
| 16:00 | cemerick | hiredman: derby? How quaint. :-) |
| 16:01 | cemerick | I remember killing myself trying to get cloudscape working back in the day. |
| 16:10 | mattmitchell | I need to write a test, that proves that a clojure fn calls a method on a java object. How can I do this? |
| 16:11 | opqdonut | produce a mock object that logs calls and then delegates them to the real object |
| 16:11 | opqdonut | and inject it |
| 16:12 | tsdh | Are java enum constants not constant things I can use with `case'? |
| 16:12 | mattmitchell | opqdonut: how can i create a java mock in clojure? |
| 16:12 | opqdonut | use, e.g., reify |
| 16:12 | hiredman | tsdh: java enums are, if I recall, ints |
| 16:13 | hiredman | but there are a couple of different ways to use them together with case |
| 16:13 | tsdh | hiredman: No, they are basically singleton objects I think. |
| 16:13 | hiredman | tsdh: incorrect |
| 16:14 | tsdh | hiredman: Really, I mean you can have enums with constructors and methods... |
| 16:14 | hiredman | sure, but each "constant" is infact an int |
| 16:15 | tsdh | hiredman: Hm, but then, why does my (case Foo/BAR 1 Foo/Baz 2 (throw (RuntimeException))) always throw? |
| 16:17 | amalloy | hiredman: those statements stopped being true in java 1.5, or else you're being misunderstood |
| 16:18 | hiredman | amalloy: no kidding |
| 16:18 | amalloy | java has enums, which are basically classes with N "singleton" instances, one for each enum constant |
| 16:18 | tsdh | From the JLS: An enum constant defines an instance of the enum type. |
| 16:19 | hiredman | well, then, carry on |
| 16:19 | amalloy | they're kinda a pain to use from clojure though, i believe |
| 16:19 | tsdh | Ok, so that means I cannot use enum constants in case, right? |
| 16:19 | amalloy | tsdh: there's an open ticket on jira somewhere discussing that |
| 16:21 | cemerick | Enum support will probably never land in case |
| 16:21 | cemerick | tsdh: you can get around it to some extent by doing something like: http://cemerick.com/2010/08/03/enhancing-clojures-case-to-evaluate-dispatch-values/ |
| 16:22 | amalloy | cemerick: when is the SoC survey closing? i need to see the results! |
| 16:22 | cemerick | amalloy: Monday |
| 16:22 | cemerick | Got to give the weekend tinkerers time to get in |
| 16:22 | tsdh | cemerick: Oh, great! I'll use that. |
| 16:23 | gfrlog | ls |
| 16:23 | gfrlog | whoops |
| 16:23 | gfrlog | well that could have been worse |
| 16:23 | cemerick | tsdh: Heed the note at the top of that post. :-) |
| 16:23 | amalloy | [sudo] Password for gfrlog: |
| 16:23 | gfrlog | iamrhickey123 |
| 16:23 | Bronsa | llol |
| 16:23 | mattmitchell | hmm, so I have an instance of a java object. Using reify, I'm not sure if that will allow me to mock a method on that object? |
| 16:23 | gfrlog | aw dang |
| 16:24 | amalloy | mattmitchell: reify only supports interfaces |
| 16:24 | mattmitchell | amalloy: ahh ok. Is there a way to mock a java class instance? |
| 16:24 | cemerick | tsdh: it works fine for me for enums, but if you AOT code that uses case+ and attempt to run it with a different version of an enum class on the classpath, bad things may happen |
| 16:24 | tsdh | cemerick: My enums come from an external java library that is in a jar. So no AOT here. |
| 16:24 | amalloy | your path of least resistance is probably to proxy the class, but someone else probably knows a "better" way |
| 16:24 | mattmitchell | amalloy: rather, a method on a java object? |
| 16:25 | cemerick | tsdh: AOT of your Clojure code; has nothing to do with the Java library |
| 16:25 | raek | mattmitchell: if the code you need to test accesses the object though an interface, it's very easy to make a mock object that implements the same interface |
| 16:25 | amalloy | &(.size (proxy [java.util.ArrayList] [] (size [] 10))) |
| 16:25 | sexpbot | java.lang.IllegalStateException: Var null/null is unbound. |
| 16:25 | cemerick | So, if you AOT your Clojure with v1 of the java lib, but then run the AOT'd classfiles with v1.1 of the java lib, things *may* break |
| 16:25 | amalloy | ,(.size (proxy [java.util.ArrayList] [] (size [] 10))) |
| 16:25 | clojurebot | java.lang.RuntimeException: java.lang.IllegalStateException: Var null/null is unbound. |
| 16:25 | tsdh | cemerick: I only compile one different namespace containing only gen-classes for some custom exceptions. That's ok, isn't it? |
| 16:26 | amalloy | hrm. anyyway mattmitchell, that's kinda-vaguely how you might mock out a method |
| 16:26 | opqdonut | mattmitchell: unfortunately there's no easy way if the method is not in an interface |
| 16:27 | cemerick | tsdh: Sounds like it — just make sure the code that's using case+ isn't being transitively included in the AOT. |
| 16:27 | mattmitchell | ok yeah, this is just a class with no interface |
| 16:27 | mattmitchell | http://lucene.apache.org/solr/api/org/apache/solr/core/CoreContainer.html |
| 16:27 | opqdonut | but being able to unit-test things like that means that you need to structure your code in a specific way |
| 16:27 | tsdh | cemerick: I added a notice so that I'll never forget. |
| 16:27 | cemerick | heh |
| 16:29 | fliebel | cemerick: Do you have any fancy visualization plans for the survey? |
| 16:30 | cemerick | fliebel: Nothing beyond what I did for the first one. |
| 16:30 | cemerick | Unless someone has other grand ideas. |
| 16:31 | cemerick | I remember seeing something equivalent to a mod_ring floating around a few months ago. Anyone have a link handy? |
| 16:34 | tsdh | cemerick: I get a compile error with your case+ (http://pastebin.com/CMzVs8G5) |
| 16:34 | Scriptor | tsdh: getting an unknown paste id on that |
| 16:35 | fliebel | cemerick: Really? Awesome! I need to compare that to ring-fastcgi. |
| 16:35 | tsdh | Scriptor: I don't. Maybe your IRC client copies the trailing ) ? |
| 16:35 | tsdh | http://pastebin.com/CMzVs8G5 |
| 16:35 | justinko | multi-methods are blowing my mind |
| 16:36 | cemerick | tsdh: funky; what if you pull (EdgeDirection/INOUT nil) out into two clauses? |
| 16:36 | cemerick | tsdh: which version of Clojure? |
| 16:36 | tsdh | cemerick: Tried that, same error. I use 1.3 from git. |
| 16:36 | tsdh | cemerick: State as of yesterday. |
| 16:37 | Scriptor | tsdh: oh, yes it does |
| 16:37 | Scriptor | damnit ERC |
| 16:37 | Scriptor | and damnit eyes for checking for that and still not seeing it earlier |
| 16:37 | tsdh | Scriptor: I use rcirc which DTRT. |
| 16:37 | cemerick | tsdh: hrm, I suspect the macro doesn't work under 1.3 — I've never seen an error like that before. |
| 16:37 | fliebel | cemerick: This was my answer to the all-in-one server: http://pepijndevos.nl/the-perfect-server/ |
| 16:38 | Scriptor | cemerick: I found a link about using a WAR file and using apache as a proxy to tomcat, assuming that's probably not it though? |
| 16:38 | cemerick | fliebel: yours is what I was thinking of :-) |
| 16:38 | cemerick | Scriptor: ^^ |
| 16:39 | fliebel | cemerick: Oh, I thought you had something in the other half of the venn. |
| 16:40 | amalloy | justinko: i find myself wanting to replace every if/cond with a multimethod. kinda overdoing it though |
| 16:40 | Scriptor | ah, ring_fastcgi |
| 16:42 | gfrlog | fliebel: clever email obfuscation |
| 16:42 | fliebel | gfrlog: You mean the rot13? :) I had one in Clojure as well... |
| 16:43 | gfrlog | fliebel: I like it because to a bot it still looks like a plain email |
| 16:43 | fliebel | gfrlog: Yea, I figured I should write a DSL that can be expressed in valid email addresses. |
| 16:44 | gfrlog | unless it checks tlds...I've never heard of .pbz |
| 16:45 | fliebel | gfrlog: Would be fun to set up that as an email and see how much spam it gets :) |
| 16:46 | gfrlog | pbz is the cTLD of the country Peanut Butterz |
| 16:47 | tsdh | cemerick: Really strange. The expansion looks correct to me. http://pastebin.com/THwz4N2S |
| 16:48 | tsdh | cemerick: But haveing the code in front of me, I can at least understand the error message. |
| 16:49 | amalloy | tsdh: you can't put objects in code :P |
| 16:49 | amalloy | ie, the expansion does NOT look good, because you would never type #<EdgeDirection INOUT> in code yourself |
| 16:50 | tsdh | amalloy: Exactly |
| 16:50 | tsdh | and the solution is also provided in the error message... |
| 16:50 | fliebel | gfrlog: http://en.wikipedia.org/wiki/.bz |
| 16:50 | gfrlog | ,(read-string "#<Foo BAR>") |
| 16:50 | clojurebot | java.lang.RuntimeException: java.lang.Exception: Unreadable form |
| 16:50 | amalloy | yes, although i don't know that defining a print-dup resolves the issue? |
| 16:51 | gfrlog | ah ccTLD is the term |
| 16:52 | amalloy | tsdh: fwiw, (fn [i] (normal-edge? i)) is just normal-edge?, and the next is just (complement normal-edge?) |
| 16:52 | tsdh | amalloy: indeed. |
| 16:52 | cemerick | tsdh: The more sane thing would be to, when it's clear that clauses are known to be enums, code is emitted to match on corresponding enums, and not the enum values themselves. |
| 16:52 | amalloy | gfrlog: does what? |
| 16:53 | gfrlog | amalloy: lets you refactor your code purely by deleting things |
| 16:53 | cemerick | I think that's how ataggart was making enums work in his early 1.3 case patches, anyway. |
| 16:53 | gfrlog | probably only the first of the two is an example of that |
| 16:54 | mattmitchell | is there a way to alias a var so that it points to another var in a diff namespace? |
| 16:54 | tsdh | cemerick: First I've thought wrapping a (binding [*print-dup* true] ...) around the case would help, but that's not true. What's a "corresponding enum"? |
| 16:56 | tsdh | Ah, I need to add a (defmethod print-dup ...) |
| 16:56 | cemerick | tsdh: case+ would determine that the dispatch values evaluate to enums, and emit a case form that used symbols for those enums instead of the enums themselves. So an enum Foo/Bar would turn into 'some.package.Foo/Bar. |
| 16:57 | cemerick | tsdh: I think the print-dup hint is a red herring rabbit hole in this case. :-) |
| 16:57 | tsdh | :-) |
| 16:58 | cemerick | tsdh: I have that blog post in my browser-tab-backlog; might take a whack at revising the code therein to be 1.3-friendly next week-ish. |
| 16:58 | tsdh | I'll check your blog. |
| 16:59 | mattmitchell | Hmm, I have a main ns. I want require other ns's and alias to a short name within the main ns. The problem is, my other ns's need a var in the main set in order to function. If I require the other ns's in the main ns, then "use" the main ns in the others, I get "java.lang.Exception: Cyclic load dependency" |
| 16:59 | cemerick | tsdh: what, you don't subscribe already? |
| 16:59 | mattmitchell | ^ I know that sounds confusing |
| 16:59 | cemerick | ;-) |
| 17:03 | gfrlog | ah good now I'm not the only one doing that |
| 17:04 | gfrlog | speaking of TLDs, the internets say ICANN will approve commercial TLDs |
| 17:06 | hiredman | clojurebot: destructuring |
| 17:06 | clojurebot | destructuring is http://clojure.org/special_forms#let |
| 17:09 | gfrlog | amalloy: figure it out yet? |
| 17:09 | amalloy | gfrlog: yes |
| 20:00 | cwmaguire | Is there a function to run multiple functions with a parameter? e.g. (for [f [+ - *]] (f 1)) |
| 20:02 | mids | cwmaguire: juxt? http://clojuredocs.org/clojure_core/clojure.core/juxt |
| 20:03 | cwmaguire | of course! |
| 20:03 | cwmaguire | thanks |
| 20:03 | cwmaguire | I'm rusty |
| 20:05 | mids | ,((juxt + - /) 4 3) |
| 20:05 | clojurebot | [7 1 4/3] |
| 20:11 | __name__ | Everyone loves juxt. |
| 20:17 | amalloy | __name__: and if you don't, we'll (juxt draw quarter) you |
| 21:08 | davekong | I clojure-contrib.jar to my classpath but am having trouble loading the namespace at the REPL, what should I be typing to add e.g. the seq namespace or say all of them |
| 21:10 | amalloy | davekong: you can't require them all at once; you need to specify each *namespace* you want, not each *library* (whereas in project.clj you specify at a library level) |
| 21:11 | amalloy | so eg (use 'clojure.contrib.seq) (separate even? (range 10)) |
| 21:16 | davekong | amalloy: thanks |