2010-04-14
| 00:15 | technomancy | hugod: what about that function specifically? |
| 00:15 | technomancy | just see that it makes sense? |
| 00:17 | hugod | ok, slime-autodoc works for me in slime head without the patch |
| 00:18 | technomancy | so it was just a temporary bug in an older slime head? |
| 00:18 | technomancy | the hackiness that's evident when looking at slime code makes me feel a little better about the hackiness of swank-clojure |
| 00:20 | technomancy | hugod: gotta take off; will sync up with you later. |
| 00:20 | hugod | technomancy: I'm making mistakes - time to sleep - it's hanging for me |
| 00:20 | technomancy | a fresh brain often helps =) |
| 00:20 | technomancy | bye |
| 00:57 | vIkSiT | hello all |
| 00:58 | vIkSiT | i was wondering - on a normal emacs-slime-clojure installation - how do you send a buffer where i'm writing code, to the repl for execution? |
| 00:58 | vIkSiT | i'm using aquamacs, but C-c C-k shows up as "not bound" for me. |
| 00:58 | tomoj | what mode are you in |
| 00:59 | tomoj | i.e. what's in parentheses in the modeline near the bottom |
| 01:00 | polypus | vIkSiT: try M-x slime-eval-buffer |
| 01:01 | vIkSiT | tomoj, ah - i've got a repl running in a split screen mode. the bottom contains [[(REPL)]] and the top has a clj file open which says [[(fundamental)]] |
| 01:01 | hiredman | should be clojure-mode |
| 01:01 | hiredman | or just clojuire |
| 01:02 | tomoj | did you install the clojure emacs stuff before or after opening the clj file? |
| 01:02 | vIkSiT | oh got it. clojure mode seems to send CcCk to the REPL. |
| 01:02 | vIkSiT | tomoj, ah, what i did was - typed in (println "foo") and then saved it as /tmp/foo.clj |
| 01:03 | tomoj | try C-x C-f /tmp/bar.clj |
| 01:03 | tomoj | if that buffer opens in fundamental mode, something's wrong with your installation |
| 01:03 | vIkSiT | looks like just M-xc lojure-mode will enable the mode, and I can then use Cc Ck |
| 01:03 | vIkSiT | tomoj, nope, its working now, I overlooked the clojure-mode! |
| 01:04 | tomoj | clj files should automatically turn clojure-mode on, though |
| 01:04 | vIkSiT | tomoj, indeed. just looking at me .emacs |
| 01:04 | vIkSiT | my* |
| 01:05 | vIkSiT | does anyone here use clojure for concurrency/parallel programming btw? |
| 01:06 | vIkSiT | (in the sense, they switched to it take advantage of agents, et al) |
| 01:07 | hiredman | omg |
| 01:07 | hiredman | incanter.latex |
| 01:09 | vIkSiT | sounds cool |
| 02:49 | zkim | ,(conj [1 2] 3) |
| 02:49 | clojurebot | [1 2 3] |
| 03:51 | LauJensen | Morning crew |
| 04:11 | vIkSiT | hmm, I'm running clojure-mode on a file named 2.clj in emacs - but I don't seem to be getting auto indentation anywhere |
| 04:11 | vIkSiT | any ideas on what I can check? |
| 04:14 | LauJensen | (global-set-key "\r" 'newline-and-indent) |
| 04:17 | LauJensen | @ vIkSiT |
| 04:17 | vIkSiT | LauJensen, ah this in my .emacs file? |
| 04:17 | LauJensen | Yup - Put it in there and eval the expression |
| 04:20 | vIkSiT | LauJensen, awesome, thanks! |
| 04:22 | LauJensen | np :) |
| 04:22 | npoektop | how to compare sets by their content? i have #{{:id 1} {:id 2}} and #{id1 id2}, (= for them should say true. |
| 04:26 | LauJensen | npoektop: Why should it be true? |
| 04:27 | LauJensen | You could do something like |
| 04:27 | LauJensen | ,(map = (vals {:id1 1 :id2 2}) #{1 2}) |
| 04:27 | clojurebot | (true true) |
| 04:27 | LauJensen | And that would make a little more sense, but you compare a set of hashmaps to a set of symbols should not be true |
| 04:30 | npoektop | LauJensen, i'd like to dereference those symbols so this comparison would give true |
| 04:31 | LauJensen | Then you need to convert them. You want to compare a keyword and an integer, in a concatenated form, to a symbol. |
| 04:32 | npoektop | LauJensen, ok. How to convert them? |
| 04:34 | npoektop | LauJensen, id1 = {:id 1}, id2 = {:id 2}. How to compare #{id1 id2} and #{{:id 1} {:id 2}}? |
| 04:34 | LauJensen | Is the actual comparison (= 2 2) or (= 'id2 'id2) ? |
| 04:34 | LauJensen | does {:id 1} => id1 or 1 |
| 04:36 | LauJensen | @ npoektop |
| 04:38 | npoektop | LauJensen, i do not understand what you mean( |
| 04:38 | LauJensen | I'm just trying to understand your data |
| 04:39 | LauJensen | Is this what you're trying to do |
| 04:39 | LauJensen | ,(= (set (mapcat vals #{{:id 1} {:id 2}})) #{1 2}) |
| 04:39 | clojurebot | true |
| 04:39 | npoektop | ,(let [id1 {:id 1}] (= id1 {:id 1})) |
| 04:39 | clojurebot | true |
| 04:42 | npoektop | LauJensen, ok, another way. I have a function profiles-by-ids wich returns a vector of maps. I want to write a test that would check if '(id1 id2) = '({:id 1} {:id 2}). I thought coercing to set would work. |
| 04:43 | LauJensen | Ok, so you have a vector of maps ala {:id 1} {:id 2} and you want some way of testing if an id is represented somewhere in that vector? |
| 04:44 | LauJensen | (let [id2 {:id 2}] (contains? #{{:id 1} {:id 2} {:id 3}} id2)) |
| 04:44 | LauJensen | ...true |
| 04:44 | LauJensen | :) |
| 04:46 | npoektop | LauJensen, ok. But what if there are hundreds of ids? (contains? ... id1) ... (contains? ... idn)? |
| 04:47 | LauJensen | Then perhaps you'd want to filter out those ids |
| 04:47 | LauJensen | ,(filter #{{:id 2}} #{{:id 1} {:id 2} {:id 3}}) |
| 04:47 | clojurebot | ({:id 2}) |
| 04:47 | LauJensen | The predicate in that case, is just a set containing the relevant keys |
| 04:53 | npoektop | LauJensen, what should i do now with that vector? |
| 04:53 | npoektop | ,(let [id1 {:id 1} id2 {:id 2}] (filter #{id1 id2} #{{:id 1} {:id 2} {:id 3}})) |
| 04:53 | clojurebot | ({:id 1} {:id 2}) |
| 04:53 | npoektop | s/vector/list. count it's members? |
| 04:56 | LauJensen | Factor it out into a predicate |
| 04:56 | LauJensen | (defn contains-ids? [ids coll] (not (empty? (filter ids coll)))) |
| 04:56 | LauJensen | So if there are no hits, the filter returns empty (true) which we reverse with not. |
| 05:01 | npoektop | LauJensen, i don't know why it didn't work ten minutes ago. I tryed smth like this: (= (set (profiles-by-ids [...]) (set (list id1 id2))) |
| 05:01 | npoektop | now it works |
| 05:02 | LauJensen | Try it with real data on Clojurebot |
| 05:04 | npoektop | ,(let [id1 {:id 1} id2 {:id 2}] (= (set '({:id 1} {:id 2})) (set (list id1 id2)))) |
| 05:04 | clojurebot | true |
| 05:07 | npoektop | LauJensen, my question was a little tangled, i know) thank you for help |
| 05:09 | LauJensen | npoektop: Ah ok. This will fail if the number of arguments differ, I thought you needed to avoid that, ie |
| 05:09 | LauJensen | ,(let [id1 {:id 1} id2 {:id 2} id3 {:id 3}] (= (set '({:id 1} {:id 2})) (set (list id1 id2 id3)))) |
| 05:09 | clojurebot | false |
| 05:09 | LauJensen | But I'm glad you worked it out |
| 05:15 | npoektop | is there a way to make a variable global, but for one file? |
| 05:15 | LauJensen | The file concept is tricky, think in namespaces |
| 05:16 | npoektop | ok. how to make non-public def? |
| 05:17 | LauJensen | ,doc defn- |
| 05:17 | clojurebot | java.lang.Exception: Can't take value of a macro: #'clojure.core/doc |
| 05:17 | LauJensen | ,(doc defn-) |
| 05:17 | clojurebot | "([name & decls]); same as defn, yielding non-public def" |
| 05:18 | npoektop | i'd like to def a variable |
| 05:21 | hoeck | (def #^{:private true} foo 10) |
| 05:21 | hoeck | or (clojure.contrib.def/defvar- foo 100) |
| 05:22 | LauJensen | Yea I was just about to say, check out contrib.def |
| 05:37 | _invis | guys could you help me to write this Graphics2D g2 = (Graphics2D) img.getGraphics(); on clojure in let ? |
| 05:39 | raek | (let [g2 (.getGraphics img)] (do-stuff g2)) |
| 05:41 | raek | _invis: rhickey does some graphics in the example in the end of this talk: http://clojure.blip.tv/file/812787/ |
| 05:42 | _invis | thank you |
| 05:43 | raek | (the "ants example" is available here: http://groups.google.com/group/clojure/files look for ants.clj) |
| 05:52 | LauJensen | Also my blog has more than a few examples of graphics sims |
| 06:05 | npoektop | hoeck, LauJensen, thank you. |
| 06:06 | hoeck | npoektop: np :) |
| 06:21 | vegai | do the authors of The Joy of Clojure visit here? |
| 06:21 | LauJensen | they practically live here |
| 06:21 | vegai | ah :) |
| 06:22 | vegai | I was about to ask where to send corrections, but now I see that every single page has a like to a forum... |
| 06:22 | vegai | like/link |
| 06:39 | LauJensen | For the european (or travel happy) people in here: http://www.bestinclass.dk/index.php/2010/04/clojure-meets-the-european-industry/ |
| 06:54 | esj | LauJensen: nice choice - good beer. |
| 06:54 | LauJensen | esj: You should talk to cgrand, that was his argument as well :) |
| 06:55 | esj | i tried to sell him on Cambridge, but no dice. |
| 08:12 | Raynes | LauJensen: European training sessions huh? :p |
| 08:13 | LauJensen | Thats right - You flying in ? |
| 08:13 | Raynes | LauJensen: For 1200€ sessions? I think not. :p |
| 08:13 | LauJensen | I'll throw in a free cheese burger :) |
| 08:14 | Raynes | I'm sold. |
| 08:14 | Raynes | ;p |
| 08:15 | LauJensen | Perfect |
| 08:15 | Raynes | I think the Rubylearning Clojure course guys like me. |
| 08:16 | LauJensen | Why wouldnt they ? |
| 08:16 | Raynes | Just sayin'. Stuff like this: http://twitter.com/IndianGuru/statuses/12158700306 |
| 08:17 | Raynes | Sure know how to make a fella' feel warm and fuzzy inside. :p |
| 08:17 | LauJensen | AWwwww :) |
| 08:18 | AWizzArd | Is there already an idiomatic way to serialize (print + read) deftypes? |
| 08:18 | Raynes | That was after I made the comment that I'm a "teacher undercover as a student". |
| 08:20 | AWizzArd | Best way is to add a print-dup method for user defined types? |
| 08:36 | AWizzArd | chouser: You implemented the printing for deftypes yes? |
| 08:41 | Raynes | We need a Clojure window manager. ._. |
| 08:41 | Raynes | I want a window manager I can configure in Clojure. |
| 08:51 | LeNsTR | =) |
| 08:52 | @chouser | Raynes: yes. abrooks is working on it. :-) |
| 08:52 | @chouser | AWizzArd: yeah, the current (unreadable) format. |
| 08:55 | AWizzArd | chouser: who calls print-deftype in http://github.com/richhickey/clojure/blob/master/src/clj/clojure/core_deftype.clj#L301 ? |
| 08:55 | AWizzArd | in core_print.clj i didn’t find the caller |
| 08:57 | rhickey | name game again |
| 08:57 | AWizzArd | uh oh ^_^ |
| 08:58 | rhickey | I am trying to support stable names for deftype/defrecord even when used dynamically, using the same technique that definterface does |
| 08:58 | rhickey | this means that it will be useful to auto-import the class name, and thus would conflict with the current factory fns |
| 08:58 | AWizzArd | rhickey: you wrote about stable nam.. ah, this is what I wanted to ask |
| 08:59 | rhickey | in addition, there *may* be a facility for providing bodies for the factory fn(s), if so these wil end up as static method(s) of the generated class |
| 08:59 | AWizzArd | Stable names means: (defrecord Foo [a b c]), (class (Foo 10 20 30)) <--- will keep the same name even after restarting JVM? |
| 09:00 | rhickey | thus we need name for static factory method, and possble wrapper fn for same |
| 09:00 | rhickey | I like Foo/create |
| 09:01 | AWizzArd | yes, better than make-instance |
| 09:01 | rhickey | not sure about wrapper fn, could be create-Foo |
| 09:02 | AWizzArd | In what situations would the wrapper be used? |
| 09:04 | rhickey | AWizzArd: hopefully most - it gives you some encapsulation of the host-iness of it. Also would be a first class fn (e.g. mappable) |
| 09:04 | AWizzArd | Foo/create and create-Foo sound good and clear. |
| 09:05 | AWizzArd | Instead of create maybe "new" or "make" could be used, but I like create more. |
| 09:05 | rhickey | "new" can't be used as static method name - Java keyword |
| 09:05 | AWizzArd | ok |
| 09:05 | liwp | assuming we want to use the same name in both cases, new is out of the question |
| 09:06 | liwp | and Foo.make sounds weird in Java land |
| 09:06 | liwp | so I too would vote for create |
| 09:06 | AWizzArd | yes |
| 09:07 | AWizzArd | Also interesting is this new question from the Wiki: "record equality: basic map rules, or incorporate type?". |
| 09:08 | rhickey | AWizzArd: one question at a time :) |
| 09:08 | jfields | what's the easiest way to create a seq of lines from a file? |
| 09:08 | AWizzArd | io/read-lines returns a lazy seq |
| 09:09 | AWizzArd | jfields: This means your jvm memory will not explode even for 10gb files, but it also means that you have to completely consume the file to have it closed again. |
| 09:09 | jfields | AWizzArd, thanks. |
| 09:10 | rhickey | jfields: or you can use with-open and line-seq for more control |
| 09:10 | AWizzArd | make, create, instantiate, create!, produce... "create" seems to be the best option |
| 09:12 | AWizzArd | gen / generate |
| 09:13 | @chouser | AWizzArd: 5 lines before that, in the deftype macro. (defmethod print-method ~tag ...) |
| 09:14 | @chouser | AWizzArd: create seems nice for the static method name, but I'm tending to agree with whoever it was that suggested against generating vars with computed names. |
| 09:14 | @chouser | sorry, that wasn't specifically for AWizzArd |
| 09:15 | @chouser | (defrecord Foo [a b]) (create Foo 1 2) (create-rec Foo :b 2, :a 1) |
| 09:15 | rhickey | chouser: well, we were generating computed names with the factory fn before, with conflict now on class name |
| 09:15 | AWizzArd | chouser: okay, thanks for the hint with the 5 lines in the deftype macro. |
| 09:16 | rhickey | (record Foo ...) means records are more verbose than new sugar |
| 09:16 | rhickey | and don't have single mappable fn |
| 09:16 | rhickey | will we get a lot of (comp record Foo) ? |
| 09:16 | @chouser | AWizzArd: It's ((var print-deftype) ...) to allow the macro expansion to call a private fn |
| 09:16 | @chouser | rhickey: Hm, I suppose. But Foo-create feels like such a hack |
| 09:16 | AWizzArd | I think for such an important mechanism like defrecord it is okay to auto gen Foo/create and create-Foo |
| 09:17 | rhickey | chouser: Foo/create works tough? |
| 09:17 | @chouser | :-) yeah |
| 09:17 | rhickey | hrm |
| 09:18 | @chouser | Foo is a thing that Foo/create is a part of |
| 09:18 | rhickey | there still might be (record Foo k1 v1 k2 v2 ...) |
| 09:18 | @chouser | You can ask Foo for its methods and find create. This doesn't feel like a hack. |
| 09:19 | rhickey | but any data-driven (maker Tag ...) is going to have overhead vs a dedicated fn |
| 09:19 | @chouser | But Foo-create is not a part of Foo, it's this other thing that was produced as a side-effect of defining the type. |
| 09:19 | rhickey | chouser: it would never be F00-create, more like create-Foo |
| 09:19 | AWizzArd | How would we like to create instances of Foos? (Foo/create 1 2 3) or (create-Foo 1 2 3) or (create-rec Foo 1 2 3)? |
| 09:20 | rhickey | AWizzArd: are you just restating the question? |
| 09:20 | @chouser | so a separate create fn will be: slower, compilcate usage of ->, probably produce a lots of (partial create Foo), ... all in exchange for "feeling" a little less like a hack. |
| 09:20 | rhickey | Foo/create will be there, is hosty, and non-mappable (at present) |
| 09:21 | rhickey | create Tag ... has overhead, needs comp/partial to map |
| 09:22 | rhickey | also, there will still need to be a separate keyvals factory |
| 09:22 | rhickey | in my mind that was (record Foo ...) |
| 09:23 | @chouser | they might as well have the same shape, right? create-Foo and record-Foo ? |
| 09:23 | @chouser | or (create Foo v1 v2) and (record Foo k1 v1 k2 v2) |
| 09:24 | @chouser | there's got to be some third way |
| 09:24 | rhickey | you have to also consider what Foo designates in (create Foo ...) |
| 09:25 | rhickey | Foo will be a class name |
| 09:25 | rhickey | thus as an ordinary arg will designate a class |
| 09:26 | @chouser | Is the only strike against just using Foo/create that it's not a proper function? |
| 09:26 | rhickey | chouser: and hosty |
| 09:27 | @chouser | I can easily pretend its namespacy instead |
| 09:27 | wthidden | rhickey: Was/is there a problem with the way CLOS does this sort of thing that Clojure want's to avoid? |
| 09:28 | rhickey | note that falling out of this will be the ability to define deftypes of all static methods |
| 09:28 | AWizzArd | wthidden: the proposed way is more like CL structs I find |
| 09:29 | hoeck | what about generating a Foo/create static method and a Foo/create static field, where the latter contians the wrapper fn? |
| 09:31 | wthidden | AWizzard: now that I think more about it I agree its closer to CL structs. |
| 09:31 | rhickey | wthidden: CLOS does the data-driven approach, will not compete perf-wise with direct fns |
| 09:31 | rhickey | hoeck: sounds confusing |
| 09:32 | wthidden | rhickey: Ah yes, the seventeen levels of indirection before we actually do some work. Now I rememeber some of the CLOS pain. |
| 09:34 | AWizzArd | So far it sounds that for technical reasons create-foo has advantages over (create-rec Foo ...). |
| 09:34 | wthidden | well if I had my druthers I'd go more towards CL structs way of doing things, but then I'm a lisp weeny at heart. |
| 09:35 | kzar | So I built Compojure and put the compojure.jar inside ~/.swank-clojure/ directory, restarted Clojure but (use 'compojure) isn't working. What should I do? |
| 09:37 | rhickey | wthidden: I think the data-driven approach is not the best foundation - since each ctor is really unique code, forcing them to live behind a generic data driven interface means you can't ever reach that code directly, whereas if you have the direct fn, you can always build a generic data-driven thingy |
| 09:39 | npoektop | if i do (assoc map key val), it returns a new map. Is there a way to destructively assoc? |
| 09:39 | @chouser | npoektop: not really -- why do you think you want to? |
| 09:40 | npoektop | chouser, i want to insert a new key/val pair into map |
| 09:40 | npoektop | into existing map |
| 09:40 | @chouser | npoektop: part of the promise of Clojure's persistent maps is that if you have one, you can rely on the fact that it *will not change* on you. It is immutable. |
| 09:41 | @chouser | npoektop: why not create a new map and just start using that one instead of the old one? |
| 09:42 | hoeck | kzar: class-not-found exception? |
| 09:43 | hoeck | kzar: try (->> (System/getProperty "java.class.path") (.split #":") seq (map println) dorun) and look wether your .swank-clojure/compojure.jar is actually on the classpath |
| 09:44 | npoektop | chouser, how to bind (assoc my-map ...) to my-map? |
| 09:44 | AWizzArd | if my-map is state then it could be a ref |
| 09:45 | npoektop | AWizzArd, it's a variable |
| 09:46 | hoeck | kzar: maybe you have to restart emacs too (after putting jars into .swank-clojure or .clojure) |
| 09:46 | AWizzArd | npoektop: when it needs to get accessed from several parts of your program and is something that could in principle get stored in a db, then you can say (def my-map (ref {})) and assoc into it within dosync |
| 09:47 | kzar | hoeck: Yea when I do it says it couldn't find anything like clojure.clj etc. Doing that command does list compojure.jar as one of the items. I have restarted emacs |
| 09:48 | npoektop | AWizzArd, yeah. I've just read that section. But i need smth simpler. I know it's a lame question, but i can't find how to do (_bind_ my-map (assoc my-map ...)) |
| 09:48 | @chouser | npoektop: it depends on your context. AWizzArd is correct, but often the "rebinding" can be done locally and so no reference type is needed. |
| 09:49 | @chouser | ,(loop [m {}, i 0] (if (> i 5) m (recur (assoc m i (str i)) (inc i)))) |
| 09:49 | clojurebot | {5 "5", 4 "4", 3 "3", 2 "2", 1 "1", 0 "0"} |
| 09:49 | hoeck | kzar: can you paste your error to lisppaste or gist.github.com? |
| 09:49 | AWizzArd | npoektop: for transient data you should follow chouser advice and rebind it locally, or use reduce or recursion. |
| 09:50 | @chouser | npoektop: there, each time through the loop, m and i are bound to a new value, even though the values themselves (a map and an integer respectively) never change. |
| 09:51 | hoeck | kzar: compojure has also some more dependencies in the deps/ directory, maybe you have to add them to .swank-clojure too |
| 09:54 | kzar | hoeck: hmm OK, here's the paste http://paste.lisp.org/display/97768 |
| 09:54 | sexpbot | Execution Timed Out! |
| 09:57 | kzar | hoeck: brb, trying again now that the deps are there |
| 09:59 | jfields | is there a good example of using (-> ) anywhere? |
| 10:01 | kzar | hoeck: hey that worked, copied everything from compojure/lib into ./swank-clojure, restarted and it works :) |
| 10:01 | hoeck | kzar: great :) |
| 10:01 | Raynes | $(-> 3 (+ 4) (+ 1) (quot 3)) |
| 10:01 | sexpbot | 2 |
| 10:02 | Raynes | jfields: Are you having trouble understanding it? |
| 10:03 | jfields | would prefer one example with each function, to help with understanding, I think I get it tho. |
| 10:04 | Raynes | My previous example would end up as (quot (+ (+ 3 4) 1) 3) |
| 10:04 | kzar | ah crap it didn't work I typed (use :compojure) by mistake which returned nil |
| 10:06 | Raynes | It's ignoring that link kzar posted, because it has "paste" in it, so it's odd that it just randomly timed out. |
| 10:06 | Raynes | kzar: Think you could drop in #clojure-causal for a moment and mention that link again? |
| 10:07 | hoeck | kzar: mhh, maybe your compojure.jar is corrupt? can you open it in midnight-commander and examine its contents? |
| 10:11 | hoeck | kzar: (or use jar -t compojure.jar on the commandline) |
| 10:12 | kzar | hoeck: Should that command take a long time? |
| 10:13 | hoeck | kzar: maybe, the jar command is slow, thats why I'm always using mc :) |
| 10:14 | kzar | hoeck: Heh ok, all this is new to me anyway. brb going to make some tea. Thanks for the help |
| 10:14 | kzar | so far |
| 10:14 | hoeck | kzar: unzip -l compojure.jar will also work, and its faster :) |
| 10:37 | kzar | still going heh |
| 10:38 | wlangstroth | jfields: http://java.ociweb.com/mark/clojure/article.html |
| 10:38 | wlangstroth | do a find for "(->" |
| 10:38 | wlangstroth | that's the clearest example I've found |
| 10:38 | hoeck | kzar: the jar -t ? |
| 10:39 | sexpbot | Execution Timed Out! |
| 10:39 | Raynes | Aha! |
| 10:39 | Raynes | Oh wait. |
| 10:39 | Raynes | Never mind. :| |
| 10:39 | wlangstroth | ie (-> x f3 f2 f1) is the same as (f1 (f2 (f3 x))) |
| 10:40 | kzar | hoeck: Yea, just tried the other command on a different machine and that was instat. Pasted an annotation to my paste with the output |
| 10:40 | AWizzArd | ((comp f1 f2 f3) x) is also an alternative |
| 10:40 | kzar | isntant* |
| 10:40 | kzar | ahh can't type |
| 10:40 | Raynes | That last one was because that article is huge and it didn't find a title in time. |
| 10:41 | Raynes | At least for URL grabbing. |
| 10:41 | hoeck | kzar: oh, there is something missing in your compojure.jar! |
| 10:42 | wlangstroth | AWizzArd: comp doesn't sit well with me, but maybe I have to warm up to it |
| 10:42 | kzar | hoeck: ah bugger, at least that 'splains it |
| 10:42 | Raynes | You don't like function composition? |
| 10:42 | Raynes | You'd hate Haskell. |
| 10:43 | wlangstroth | Raynes: no, it's the format - I prefer -> to comp |
| 10:43 | AWizzArd | wlangstroth: I also like -> because it lets us list the jobs in the order we think about them, while comp reverses this but reads like (f1 (f2 (f3 x))) === (comp f1 f2 f3) |
| 10:43 | hoeck | kzar: it should be about 0.5M in size, containing around 400 files |
| 10:43 | Raynes | Oh. I agree. |
| 10:43 | hoeck | kzar: maybe download it again or run ant/lein whatever to rebuild it |
| 10:43 | Chousuke | comp creates a new function though |
| 10:43 | kzar | hoeck: Yea I'll get a proper version, I know how to test it's good now as well |
| 10:44 | kzar | hoeck: Thanks for helping me |
| 10:44 | Chousuke | so ((comp x1 x2 x3) foo) is more wasteful than (-> foo x1 x2 x3) |
| 10:44 | hoeck | kzar: youre welcome :) |
| 10:44 | wlangstroth | Chousuke: haha - exactly |
| 10:45 | AWizzArd | Is something like reflection planned for defrecords? (defrecord Foo [a b c]), (reflect (create-Foo 1 2 3)) ==> {:class Foo, :create-fn #<ns$_create-Foo___36@e3ed>, :fields [a b c], :options {}} |
| 10:46 | Chousuke | you can always use the java reflection APIs :P |
| 10:47 | Chousuke | but hm. |
| 10:47 | Chousuke | I accidentally pressed Cmd-Q in emacs, and it then asked whether I want to quit, as there are processes running |
| 10:48 | Chousuke | I answered no, the dialog went away, and... emacs quit. |
| 10:49 | Chousuke | that's a wierd bug to have :P |
| 10:49 | Chousuke | weird* |
| 10:50 | rhickey | question #2 for the day - record equality can have either straight map semantics or include same-type check - preferences? |
| 10:50 | hoeck | Chousuke: mhh, doesn't he ask "there are active processes, still want to quit" yes/no? |
| 10:50 | AWizzArd | include same-type check please |
| 10:50 | Chousuke | hoeck: yes, it did. and I answered no, and it still quit :P |
| 10:51 | AWizzArd | rhickey: please allow me to ask if for Q#1 there is a descision yet. |
| 10:51 | Licenser_ | lein search has now update (which updates used libraries :) |
| 10:52 | rhickey | AWizzArd: no |
| 10:52 | Chousuke | rhickey: would there be a way to compare records with map-semantics too then? |
| 10:53 | rhickey | Chousuke: dunno, but there is only one = |
| 10:53 | AWizzArd | I just see that there will be more usecases for included types. |
| 10:55 | cemerick | rhickey: map semantics please. |
| 10:56 | rhickey | cemerick: current deftype uses type tag |
| 10:57 | cemerick | yeah, I noticed :-) |
| 10:59 | cemerick | Mixing the type tag into equality seems decidedly contrary to the general approach; records are just bags of slots (expandable, even), protocols cut across all hierarchies as necessary, etc. |
| 11:00 | rhickey | cemerick: I don't get your point re: protocols |
| 11:01 | AWizzArd | the name defrecord already implies for me that type information is an important one |
| 11:01 | AWizzArd | first of all it is a specific kind of data collection, and only secondary it is a map |
| 11:03 | AWizzArd | (into {} (create-Foo 1 2 3)) ==> {:a 1, :b 2, :c 3} |
| 11:03 | Chousuke | I'm more inclined to think that a record is just a map that has been given a name |
| 11:03 | AWizzArd | if that were possible then it would be easy to compare with map semantics |
| 11:03 | sattvik | rhickey: Is there a significant performance penalty for one approach over the other? To a certain extent, I think that type checking vs. general seems somewhat analogous to equals vs. equalsIgnoreCase. |
| 11:04 | AWizzArd | Chousuke: (def x {:a 1, :b 2}) is in my opinion a named map, while (defrecord Foo ..) is more general, it categorizes maps of a specific kind. |
| 11:04 | rhickey | sattvik: perf shouldn't matter for this decision |
| 11:04 | AWizzArd | Leaving out the the type in comparisons would miss the point. |
| 11:04 | cemerick | rhickey: my point (hardly made) was that IMO, records are their slots, for which the type tag is merely a shorthand, and it seems that protocols take the same stance. |
| 11:05 | rhickey | cemerick: protocols don't seem subject to meaningful equality |
| 11:05 | cemerick | hrm, now I'm arguing with myself in my head |
| 11:06 | sattvik | cemerick: So would two types with equivalent content be equivalent? |
| 11:06 | cemerick | sattvik: that's what I've been suggesting, yes. |
| 11:06 | cemerick | wait, I'm going to go get a Snapple, and then be back with an astonishingly convincing argument. |
| 11:07 | rhickey | or recant :) |
| 11:08 | AWizzArd | In principle we would have to see how people are using it. If the place is scattered with (and (instance? Foo obj1) (instance Foo obj2) (= obj1 obj2)) something is wrong. |
| 11:08 | AWizzArd | But (= (into {} obj1) random-map) is not bad for the case without the type. |
| 11:08 | sattvik | Hmm.. should (= (create-Type1 1 false) (create-Type2 1 false))? From a Java perspective, this generally is not the case, but this is not Java... |
| 11:09 | wlangstroth | I'm going to avoid toolshedding entirely, but is there anywhere the defrecord issue is laid out in detail? |
| 11:12 | AWizzArd | Not implicating the type means in principle that a programmer is forced to manually check for the types explicitly in every single comparison, if he/she wants clean and self-documenting code. |
| 11:13 | sattvik | More specifically, should (= (create-RadialPoint 0.4 1.0) (create-CartesianPont 0.4 1.0))? |
| 11:13 | AWizzArd | type errors may get detected much later without implicit type checking |
| 11:14 | cemerick | sattvik: presumably, the names of the slots are different for those objects. |
| 11:15 | rhickey | cemerick: that's a weak standard |
| 11:15 | cemerick | yeah, I know |
| 11:16 | AWizzArd | cemerick: now that defrecords will possibly get a stable name we can get even more useful serialization (long-term that is, and over the network) |
| 11:16 | seths | rhickey: OT: how likely are breaking changes to deftype before Apr 22? I'm presenting labrepl then and want to be ready to update the code |
| 11:16 | cemerick | Once concern I have w.r.t. including the tag is it potentially makes interop between two established, related libraries more difficult. |
| 11:16 | rhickey | AWizzArd: they always got a stable name when AOTed |
| 11:16 | rhickey | cemerick: how so? |
| 11:17 | sattvik | cemerick: That's true. Or, at least, one should hope so. I am not sure I have a preference. The more general approach does seem more in line with how clojure handles value in general. After all (= [1.0] '(1)). |
| 11:17 | AWizzArd | rhickey: I mean more the "even dynamically" part of your update today :) |
| 11:18 | rhickey | AWizzArd: that won't hold since while the names might be the same, the classes won't necessarily, and thus the serialization won't be dynamically viable |
| 11:19 | AWizzArd | rhickey: ok, i see. And what about this example case: I don't aot my code and serialize instances of (defrecord Foo [x]), then restart the jvm and reload the code and try to deserialize. Would that work, if the fields of the class didn't change? |
| 11:20 | cemerick | rhickey: well, consider ring and compojure -- for some time, the latter produced "ring-compliant" objects (requests, responses, etc). In such a situation, where one wants to produce records that are functionally equivalent to another lib's records, one would have to use that other lib's defrecord types. That seems like an unnecessary barrier. |
| 11:20 | rhickey | cemerick: your extending this equality limitation to a greater extent, other than equality, they will be substantially interoperable |
| 11:21 | rhickey | you're |
| 11:21 | cemerick | I suppose it's largely irrelevant in a world where everyone's using protocols. |
| 11:21 | AWizzArd | cemerick: even when you use Protocols? |
| 11:22 | AWizzArd | what if in this scenario my defrecord is incompatible? Then this would go unnoticed, because for a short moment some other ring defrecord may contain the same data/fields, but generally is incompatible. |
| 11:22 | AWizzArd | cemerick: also if (= your-map (into {} some-ring-record)) worked or something similar it would still be fine. |
| 11:23 | cemerick | sure, but I'd like to be sure we don't need/want that wart :-) |
| 11:23 | AWizzArd | When I vote for "please include the type check" I don't want to *forbid* map-like comparisons. |
| 11:23 | AWizzArd | Just getting the default right. |
| 11:23 | cemerick | OK, let's get into stupid question territory: what are the types *for*? (a) protocol dispatch, (b) construction of an object matching the type's declaration, (c) ....? |
| 11:24 | AWizzArd | program correctness |
| 11:24 | cemerick | AWizzArd: meaning what? |
| 11:24 | rhickey | (c) interface implementation, (d) primitive fields, (e) fast accessors |
| 11:24 | AWizzArd | or filtering specific objects out of a vector of records |
| 11:24 | cemerick | rhickey: yeah, I was (perhaps foolishly) trying to stay away from impl details |
| 11:25 | AWizzArd | cemerick: I have no concrete case for that, I just think that objects may slip through comparisons as equal and produce some problems later on |
| 11:26 | sattvik | cemerick: Perhaps interop with host libraries? If I understand it correctly, you could deftype an EJB. |
| 11:27 | AWizzArd | Btw, will the newdeftype be able to do (deftype clojure.lang.PersistentVector ...)? |
| 11:27 | cemerick | sattvik: sure -- and in that case, you're sort of opting into the host type hierarchy. |
| 11:27 | cemerick | AWizzArd: OK; say you have type A with slots :start and :end, and type B with slots :start and :end -- if your operations are protocols, where does an "erroneous" equality check lead you astray? |
| 11:28 | rhickey | cemerick: I'd flip it around, doesn't the fact that protocols won't match a same-shaped thing already create a difference? |
| 11:29 | rhickey | i.e. equality alone doesn't break interop |
| 11:29 | cemerick | rhickey: yeah, that was what I was getting at with the ring/compojure interop thing not really being germane given protocols. |
| 11:30 | rhickey | cemerick: there is a huge amount of data manipulating stuff around maps that will still work, but I'm not sure entire-map-equality is that important an operation |
| 11:31 | rhickey | when manipulating things like records |
| 11:31 | cemerick | yeah, neither am I |
| 11:31 | rhickey | and when it is, you don't ever want apples = oranges |
| 11:32 | rhickey | maybe a-map-literal = an-orange |
| 11:32 | rhickey | but I'm hoping for a convenient literal form for orange |
| 11:32 | rhickey | #Orange{:a 1 :b 2} or something |
| 11:33 | cemerick | I'm just trying to ferret out what it means for types to be involved in equality in general, i.e. why (= #Bar{:a 5 :b 6} #Foo{:a 5 :b 5}) would be bad |
| 11:33 | rhickey | cemerick: when Foos and Bars are used as keys in a map? |
| 11:33 | AWizzArd | Although there exists one case where it would be comfortable to have a map-like comparison: we don't need to create artificial Foos just for comparisons, or otherwise hack some verbose code. (= some-foo {:a 1, :b2}) vs (= some-foo (create-Foo 1 2)) |
| 11:34 | rhickey | cemerick: when Foos and Bars are placed in a set |
| 11:34 | rhickey | oops, some disappear |
| 11:34 | cemerick | rhickey: well, whether that's good or bad depends on one's preference w.r.t. equality semantics |
| 11:35 | AWizzArd | I already stumbled upon this with sorted-set-bys or sorted maps, don't remember, but I think it were sets. To get objects out of a set with subseq I had to artificially create deftype instances so that the comparator would work. |
| 11:35 | rhickey | cemerick: so, no oranges for me when I send you to buy groceries? :) |
| 11:35 | AWizzArd | I think rhickey got a point here, because that position is more safe. One may want another semantics, but then one should really write ones own comparator. |
| 11:36 | rhickey | cemerick: a common complaint when people were using metadata for types was that it *didn't* participate in equality |
| 11:37 | cemerick | the other side will be coming for you shortly :-P |
| 11:37 | rhickey | cemerick: likely |
| 11:37 | cemerick | Having to consider types at all is an odd-feeling reversion after a long time with just maps and multimethods. |
| 11:37 | rhickey | cemerick: but what were you using to distinguish your multimethods? |
| 11:39 | AWizzArd | I always added a :type slot *sigh* |
| 11:39 | cemerick | sometimes class or type, oftentimes existence of slots necessary to support the methods being dispatched to. |
| 11:39 | cemerick | Some would say the latter is "manifest typing". 0.0 |
| 11:39 | cemerick | hrm, wrong emoticon |
| 11:41 | cemerick | so, given protocol dispatch, I'm now flipping to include type in equality. |
| 11:41 | cemerick | But there has to be a better solution for untyped equality than (= some-map (into {} foo-record)) |
| 11:41 | AWizzArd | (: |
| 11:41 | cemerick | rhickey: the journey is the reward :-) |
| 11:42 | rhickey | cemerick: I agree, and it ends up type-including equality can be built on type-ignoring but not vice-versa |
| 11:42 | cemerick | plus, I got to scare AWizzArd a little ;-) |
| 11:43 | cemerick | rhickey: are we talking about anything fancier than a map-level = plus an instanceof? |
| 11:44 | Licenser_ | Is the (theoretical Foo) here a java object or something else? Idnd |
| 11:44 | rhickey | cemerick: I appreciate the push-back. Now with defrecord distinct from deftype it would be possible to do something slightly less efficient with defrecord, if the flexibility was there |
| 11:44 | rhickey | cemerick: nope, just that |
| 11:44 | Licenser_ | 't joined early enough sadly |
| 11:44 | rhickey | cemerick: actually identical? classes |
| 11:44 | rhickey | not instanceof |
| 11:44 | cemerick | oh, right |
| 11:45 | rhickey | one nice thing about types as metadata was that it was easy to spoof a type on the fly |
| 11:47 | rhickey | otoh, there's no way to get the perf that deftype + protocols can deliver |
| 11:47 | moshisushi | hello tehre |
| 11:47 | moshisushi | noob question: http://pastie.org/919515 |
| 11:48 | cemerick | moshisushi: you need to use clojure.contrib.duck-streams before you can invoke reader directly |
| 11:48 | cemerick | or, better yet, (require '[clojure.contrib.duck-streams :as io]) and then use io/reader |
| 11:48 | Licenser_ | moshisushi: you - okay cem was faster |
| 11:48 | moshisushi | :> |
| 11:50 | moshisushi | cemerick: Could not locate clojure/contrib/duck_streams__init.class or clojure/contrib/duck_streams.clj on classpath |
| 11:50 | bsteuber | rhickey: I'm currently working on docstring-support for def - will there be a chance you accept the patch once I sent you the contributor agreement? |
| 11:50 | moshisushi | hmm |
| 11:50 | cemerick | moshisushi: what does your classpath look like? |
| 11:50 | moshisushi | just clojure.jar right now |
| 11:51 | Licenser_ | ah you need clojure-contrib.jar too |
| 11:51 | cemerick | make sure it's the same corresponding version, though. |
| 11:51 | moshisushi | Licenser_: makes sense! sorry for bothering y'all with these lamey questions |
| 11:52 | Licenser_ | moshisushi: you are not bothering at all |
| 11:53 | moshisushi | oh by they way... anyone knows of a "quotable" paper/article on clojure STM? i'm writing a bachelors essay on STM (in Haskell specifically), and would love to add a short comparison to the clojure dito |
| 11:59 | cemerick | rhickey: you replied "not yet" to Stu's question re: protocol dispatch precedence on the list last month. Should I read that as "coming soon" or "should be possible, but it's not on the table", or something in between? :-) |
| 12:00 | rhickey | cemerick: I really don't want to repeat "prefers" |
| 12:01 | cemerick | rhickey: what was wrong with prefers? |
| 12:03 | rhickey | cemerick: less a problem with prefers than with the situation it addresses (MI of interfaces and the ability to hook protocols up to interfaces). I don't have another solution at present |
| 12:08 | cemerick | good luck on that one :-) |
| 12:08 | Licenser_ | rhickey: I'd watch out this practice is patented by Siemens |
| 12:11 | cemerick | Could just dispatch based on lexicographic order when there's ambiguity. Would make interface names a lot more amusing. |
| 12:12 | Licenser_ | a0001Cow a0002Sheep a0003Dog |
| 12:12 | Licenser_ | weeh for class names :P |
| 12:12 | rhickey | cemerick: but the problem is always pre-existing interfaces |
| 12:12 | cemerick | rhickey: sure |
| 12:12 | cemerick | that was a joke, there, son! :-P |
| 12:12 | Licenser_ | can't you give the multi method a kind of 'compare' function? |
| 12:13 | cemerick | Licenser_: you can declare dispatch value priority. |
| 12:14 | Licenser_ | so where is the problem? |
| 12:20 | rhickey | Licenser_: no similar capability for protocols yet |
| 12:22 | Licenser_ | oh okay |
| 13:39 | borkdude | Guys, whenever I start swank-clojure-project in Emacs, it keeps polling forever |
| 13:39 | borkdude | what could be wrong? |
| 13:41 | bsteuber | Borkdude: check your *inferior-lisp* buffer |
| 13:44 | Borkdude | bsteuber: it starts a server |
| 13:44 | Borkdude | (do (.. java.net.InetAddress getLocalHost getHostAddress) nil)(swank.swank/start-server "/tmp/slime.2347" :encoding "iso-latin-1-unix") |
| 13:44 | Borkdude | |
| 13:45 | Borkdude | And then this happens... Exception in thread "main" java.lang.NoClassDefFoundError: clojure/main |
| 13:47 | Borkdude | bsteuber: does swank-clojure-project use clojure+clojure.contrib from the project's lib directory? |
| 13:47 | polypus | Borkdude: yes it does |
| 13:47 | Borkdude | I have the lib directory at war/WEB-INF/lib |
| 13:47 | polypus | i don't think it'll find it there |
| 13:47 | cemerick | rhickey: Not sure if you're watching this, but this issue is a combination of mundane and really important: https://www.assembla.com/spaces/clojure/tickets/281-make-more-datastructures-serializable |
| 13:48 | sexpbot | #281 - Make more datastructures serializable (Test) | Clojure | Assembla |
| 13:48 | Borkdude | I am trying to run this project here http://github.com/sethtrain/beget |
| 13:49 | Borkdude | ah.. so swank-clojure-project doesn't really 'read' project.clj, it just supposes you use the same structure always? |
| 13:49 | Borkdude | that would explain |
| 13:49 | polypus | yep. that got me once too |
| 13:54 | s450r1 | Borkdude: since you have a project.clj, I'm guessing you're using lein? If so, you can run "lein swank" and then connect from emacs with M-x slime-connect. Then you can use the jars in war/WEB-INF/lib, I think. |
| 13:55 | bsteuber | Borkdude: so maybe you should go with lein swank then |
| 13:55 | bsteuber | s450r1: oh, didn't see your post |
| 13:55 | Borkdude | s450r1, ah that sounds helpful |
| 13:56 | Borkdude | I now made a symbolic link from lib to the war dir which also works |
| 13:56 | Borkdude | but lein swank sounds cleaner |
| 13:57 | Borkdude | s450r1: borkdude@Ubuntu-VM:~/temp/beget$ lein swank |
| 13:57 | Borkdude | swank is not a task. Use "help" to list all tasks. |
| 13:57 | Borkdude | |
| 13:58 | Borkdude | ah I see I need a plugin, sorry |
| 13:58 | bsteuber | yeah, they changed this |
| 13:59 | technomancy | no, it's always been a separate plugin |
| 14:00 | s450r1 | Borkdude: oops, sorry, should have included that information |
| 14:00 | s450r1 | http://wiki.github.com/technomancy/leiningen/emacs-integration |
| 14:00 | bsteuber | technomancy: oh - then I guess I used the plugin without realizing :) |
| 14:01 | Borkdude | s450r1: yup, it works, thanks! |
| 14:06 | s450r1 | np, technomancy did all the work :-) |
| 14:07 | s450r1 | technomancy: thanks for all your projects, I'm using a good number of them... oh wow, relax.el, I think I can use that right now. Sweet! |
| 14:07 | technomancy | s450r1: that makes one of us |
| 14:08 | technomancy | I haven't used it since I wrote it =) |
| 14:09 | wlangstroth | technomancy: lein is gold, though |
| 14:10 | wlangstroth | technomancy: I'm not trying to embarrass you or anything, but if I had to start with maven instead of being eased into the process with leiningen, that would have been painful |
| 14:11 | wlangstroth | so thanks from me, too |
| 14:15 | technomancy | great =) |
| 15:20 | Borkdude | How do I specify the namespaces to compile in a project.clj? |
| 15:20 | Borkdude | :namespaces [beget beget.templates] ?? |
| 15:22 | Borkdude | I changed the beget/templates.clj file lein says all :namespaces already compiled |
| 15:23 | jweiss | is there a fn, maybe in contrib that will automatically (use 'blah.blorg :reload-all) when i save blah/blorg.clj? |
| 15:28 | LauJensen | jweiss: You aren't that PHP blogger by any chance, are you? |
| 15:28 | jweiss | LauJensen: PHP? good lord, no |
| 15:28 | LauJensen | Ok, then I'll be happy to help |
| 15:28 | jweiss | hehe |
| 15:29 | LauJensen | Clojure doesn't know when you're saving files, you if you want that kind of functionality, you need to work it into Emacs |
| 15:29 | LauJensen | (just kidding, I have no hate for PHP bloggers) |
| 15:29 | jweiss | LauJensen: yeah i figured it'd either have to run as a thread or agent from the repl |
| 15:29 | jweiss | but your emacs suggestion sounds interesting as well |
| 15:40 | programble | wow |
| 15:40 | programble | you guys arent pricks |
| 15:41 | heejp | hey |
| 15:41 | heejp | can anybody help me with something, please? |
| 15:41 | programble | fuckin #python pricks |
| 15:41 | programble | heejp: just ask :) |
| 15:41 | heejp | I'm having trouble with multimethod dispatch functions |
| 15:42 | heejp | I'm working on an object system called Fenrir |
| 15:42 | heejp | and here's my instance making function: |
| 15:42 | heejp | (defmulti new-obj #(:_fenrir_class-name %)) |
| 15:42 | heejp | (defmethod new-obj ::fObject [fclass & kvals] |
| 15:42 | heejp | (with-meta (apply struct-map (conj kvals (:_fenrir_struct fclass))) |
| 15:42 | heejp | {:_fenrir_class (:_fenrir_class-name fclass)})) |
| 15:42 | kotarak | heejp: please paste somewhere and post the link here |
| 15:42 | LauJensen | ~paste |
| 15:42 | clojurebot | lisppaste8, url |
| 15:42 | kotarak | eg. paste.lisp.org |
| 15:43 | heejp | sorry |
| 15:43 | LauJensen | programble: One of the tricks of keeping a calm and friendly community, is to avoid from foul language and dissing other groups - So appologize and move on :) |
| 15:43 | heejp | I'll take that into account next time |
| 15:43 | heejp | anyway |
| 15:43 | heejp | with that code snippet I pasted |
| 15:43 | heejp | when I do something like this: |
| 15:44 | heejp | (new-obj fGameObject :location 1 :sprite 2) |
| 15:44 | heejp | I get this error: |
| 15:44 | heejp | java.lang.IllegalArgumentException: Wrong number of args passed to: core$fn (repl-1:17) |
| 15:44 | kotarak | heejp: you dispatch function must take the same number of arguments. Try: #(:_fenrir_class-nam (first %&)) |
| 15:45 | heejp | um... |
| 15:45 | heejp | I see |
| 15:45 | heejp | let me try it |
| 15:45 | hiredman | (comp :_fenrir_class-nam first list) |
| 15:46 | heejp | hey |
| 15:46 | heejp | it worked! |
| 15:46 | heejp | hehehehe |
| 15:46 | heejp | thanks, guys |
| 15:58 | dakrone | ,(.replaceAll "foo\bar" "\\" "SLASH") |
| 15:58 | clojurebot | java.util.regex.PatternSyntaxException: Unexpected internal error near index 1 \ ^ |
| 15:58 | dakrone | ,(.replaceAll "foo\\bar" "\\" "SLASH") |
| 15:58 | clojurebot | java.util.regex.PatternSyntaxException: Unexpected internal error near index 1 \ ^ |
| 15:58 | dakrone | ,(.replaceAll "foo\bar" "\\\" "SLASH") |
| 15:58 | clojurebot | EOF while reading string |
| 15:58 | dakrone | ,(.replaceAll "foo\bar" "\\\\" "SLASH") |
| 15:58 | clojurebot | "foo\bar" |
| 15:58 | dakrone | can someone tell me how to get the backslash replaced? |
| 15:59 | kotarak | ,(.replaceAll "foo\\bar" "\\\\" "SLASH") |
| 15:59 | clojurebot | "fooSLASHbar" |
| 15:59 | kotarak | I think "\b" is bell, no? |
| 15:59 | programble | it is |
| 15:59 | programble | no wait |
| 15:59 | programble | isnt that \a? |
| 16:00 | kotarak | backspace, maybe? |
| 16:00 | programble | yes |
| 16:00 | dakrone | okay, why the 4 slashes for 1 regular slash? |
| 16:00 | kotarak | 2 for the string, 2 for the regex |
| 16:01 | kotarak | regex requires \\, but \\ in a String is only one \. |
| 16:01 | opqdonut | the string "\\\\" is really the string "\\" which corresponds to the regex "\" |
| 16:01 | dakrone | ahh, so escaping for the reader, then escaping again for the regex |
| 16:01 | hiredman | ,(->> #"" class .getMethods (map #(.getName %))) |
| 16:01 | clojurebot | ("toString" "matches" "split" "split" "compile" "compile" "matcher" "quote" "pattern" "flags" "wait" "wait" "wait" "hashCode" "getClass" "equals" "notify" "notifyAll") |
| 16:02 | hiredman | split but no replace |
| 16:02 | opqdonut | dakrone: yeah, basically |
| 16:02 | kotarak | ,(.toString #"\\") |
| 16:02 | clojurebot | "\\\\" |
| 16:03 | kotarak | ,(str #"\\") |
| 16:03 | clojurebot | "\\\\" |
| 16:03 | Borkdude | And then suddenly 'lein swank' stopped working, no idea what happened |
| 16:03 | kotarak | ,(.replaceAll "foo\\bar" (str #"\\") "SLASH") |
| 16:03 | clojurebot | "fooSLASHbar" |
| 16:03 | dakrone | how does http://gist.github.com/366261 look for stripping out Clojure reader chars |
| 16:03 | dakrone | am I missing any? |
| 16:04 | Borkdude | still have this in my project.clj: :dev-dependencies [[swank-clojure "1.1.0"] |
| 16:04 | Borkdude | [leiningen/lein-swank "1.1.0"]] |
| 16:04 | Borkdude | then it should just work, right? |
| 16:04 | LauJensen | dakrone: ^ ? |
| 16:05 | hiredman | dakrone: http://github.com/hiredman/clojure/blob/readerII/src/clj/clojure/reader.clj#L516 |
| 16:05 | kotarak | ^ is deprecated |
| 16:05 | hiredman | oh |
| 16:05 | LauJensen | I vote for undeprecating it! |
| 16:05 | hiredman | reader macros |
| 16:05 | LauJensen | Oh wait, we're not voting :) |
| 16:05 | hiredman | it's going to be used for type hinting |
| 16:06 | kotarak | "clojure is not designed by public voting" rhickey (or something like that) (and that's good, IMHO) |
| 16:06 | dakrone | LauJensen: thanks, I'll add that one |
| 16:06 | dakrone | hiredman: cool, thanks |
| 16:07 | LauJensen | kotarak: Of course its good |
| 16:08 | StartsWithK | there should be a secret voting then :) |
| 16:08 | LauJensen | StartsWithK: oh there is... |
| 16:08 | LauJensen | I'm pretty sure :) |
| 16:09 | hiredman | clojurebot: secrets? |
| 16:09 | clojurebot | I don't understand. |
| 16:09 | StartsWithK | hmm.. is there a secret handshake too.. we may never know |
| 16:09 | hiredman | I think polls have been on the todo list for clojurebot forever now |
| 16:11 | kotarak | StartsWithK: #^'~@ (<- secret reader macro) |
| 16:12 | StartsWithK | kotarak, hehehe |
| 16:12 | LauJensen | The secret is, that when you see the Clojure Logo in a mirror, it reads "PERL" in swirly 3d letters |
| 16:13 | StartsWithK | repl is a hidden clue :) |
| 16:13 | kotarak | I use Clojure as my secret weapon at work. Maybe we'll be able to hide clojure in perl programs to perfect this technique. |
| 16:20 | raek | what is recommended for signaling exceptions? deftype'd java exceptions? c.c.error-kit? c.c.condition? |
| 16:23 | StartsWithK | raek, gen-class is your only option if you want new exception name (or java) |
| 16:23 | raek | I want the ability do distinguish different kinds of errors |
| 16:24 | hiredman | condition has a niggling little bug that I don't think is fixed upstream yet |
| 16:24 | raek | ...but not neccerarily by having a java class for each one |
| 16:24 | hiredman | the various java.lang exceptions aren't good enough? |
| 16:24 | Borkdude | Any idea why my 'lein swank' is not working anymore? |
| 16:24 | hiredman | clojurebot: exceptions! |
| 16:24 | clojurebot | http://paste.lisp.org/display/74305 |
| 16:25 | Borkdude | It worked an hour or so ago... |
| 16:25 | hiredman | clojurebot: botsnack |
| 16:25 | clojurebot | thanks; that was delicious. (nom nom nom) |
| 16:25 | bsteuber | Borkdude: what's the exact problem? |
| 16:25 | Borkdude | it says 'swank is not a task' |
| 16:26 | hiredman | have you run lien deps? |
| 16:26 | Borkdude | hiredman, yes, but I will do it now to be sure |
| 16:26 | hiredman | the swank plugin needs to be a dev dependency |
| 16:26 | hiredman | and deps will fetch it |
| 16:28 | Borkdude | ah I now get it |
| 16:28 | Borkdude | also with lein swank it doesn't support the lib directory to be something other than <proj-dir>/lib |
| 16:29 | Borkdude | even if specified otherwise in project.clj |
| 16:29 | Borkdude | even if > although I mean |
| 16:39 | slyphon | anyone else have slime sort of mysteriously change back to the 'user' namespace occasionally? |
| 16:41 | tomoj | when I tell it to switch into a namespace that doesn't exist, it goes back to 'user' |
| 16:41 | tomoj | that's the only time I've noticed it |
| 16:41 | slyphon | hmm |
| 16:41 | slyphon | oh, maybe it's when i open a namespace i haven't previously required |
| 16:41 | slyphon | or compiled |
| 16:41 | tomoj | yeah, that would do it |
| 16:42 | slyphon | ok, as long as i'm not just losing it :) |
| 16:48 | ztellman | ,(assoc {} :octaves 3) |
| 16:48 | clojurebot | {:octaves 3} |
| 16:48 | ztellman | hmm, in 1.2.0 that throws an exception for that particular keyword |
| 16:48 | ztellman | anyone know why? |
| 16:51 | @chouser | ztellman: seems to work fine here |
| 16:52 | dakrone | yea, same here |
| 16:52 | ztellman | hmm, when I open a fresh repl it works fine for me too |
| 16:53 | ztellman | weird, dunno how I got into this state |
| 16:53 | tomoj | what's the exception?? |
| 16:53 | ztellman | (class: example/opengl/marble$eval__70767, method: <clinit> signature: ()V) Incompatible argument to function |
| 17:19 | Licenser | is there a function to test if something is a map? |
| 17:19 | Licenser | aka hashmap |
| 17:20 | remleduff | associative? maybe |
| 17:21 | tomoj | well, there's map? |
| 17:22 | Raynes | $(map {}) |
| 17:22 | sexpbot | Wrong number of args passed to: core$map |
| 17:22 | Raynes | $(map? {}) |
| 17:22 | sexpbot | DENIED! |
| 17:22 | Raynes | Orly |
| 17:22 | Raynes | Must not have map? whitelisted. |
| 17:22 | remleduff | $(associative? {}) |
| 17:22 | sexpbot | false |
| 17:22 | remleduff | Color me surprised |
| 17:22 | remleduff | $(associative? []) |
| 17:22 | sexpbot | true |
| 17:23 | Raynes | Whoda thunk it? |
| 17:23 | remleduff | $(doc associative?) |
| 17:23 | sexpbot | ------------------------- clojure.core/associative? ([coll]) Returns true if coll implements Associative |
| 17:23 | tomoj | uhh |
| 17:23 | tomoj | here, (associative? {}) is true |
| 17:23 | Raynes | ,(associative? {}) |
| 17:23 | clojurebot | true |
| 17:24 | Raynes | Licenser: ^ That's kind of weird. |
| 17:24 | Licenser | no that my friend is a bug |
| 17:24 | Raynes | Oh. |
| 17:24 | Raynes | I thought so. |
| 17:30 | Licenser | thanks for the help and night people |
| 18:00 | maacl | Why would I get a null pointer exception if I try to do M-. (using emacs/SLIME) on a the name of a var in the same file as it is defined, while it works perfectly well if doing the same from within another file? |
| 18:08 | dnolen | maacl: that will only work if you ran compile file (C-c C-k) on that file, if you eval'ed a secpr with C-x C-e, M-. will not work |
| 18:09 | maacl | dnolen: ah, thanks |
| 20:27 | rhickey | it's alive! - first cut of defrecord is up |
| 20:33 | arohner | http://arohner.blogspot.com/2010/04/writing-jquery-code-with-scriptjure.html thoughts? |
| 20:33 | sexpbot | /dev/rohner: Writing JQuery code with Scriptjure |
| 22:27 | vIkSiT | hi all |
| 22:27 | vIkSiT | can anyone point me to some documentation on settings up slime / swank for a specific project started using lein? |
| 22:30 | slyphon | http://technomancy.us/126 |
| 22:30 | sexpbot | in which are found tricks of the trade concerning clojure authorship - Technomancy |
| 22:35 | vIkSiT | slyphon, ah my problem is that once I do M-x swank-clojure-mode .. and point it to the proejct dir.. |
| 22:36 | vIkSiT | I'm still stuck with a "Polling /var/folders.." message and slime never starts up. |
| 22:36 | slyphon | does "lein repl" work in your project dir? |
| 22:36 | clojurebot | http://www.thelastcitadel.com/dirt-simple-clojure |
| 22:37 | vIkSiT | hmm |
| 22:37 | vIkSiT | yes it does - but looks like it takes 1.1.0 rather than 1.2.0-master that I have otherwise |
| 22:38 | slyphon | 1.2.0 hasn't been released officially yet, afaik |
| 22:39 | Raynes | 1.2.0 master works with it. |
| 22:39 | vIkSiT | slyphon, ah yes, I mean that 1.2.0 is the JAR I'm using in my CP |
| 22:39 | vIkSiT | so I guess there are 2 issues : 1) lein repl picks up a 1.1.0 jar; and 2) swank doesn't connect to anything at all. |
| 22:40 | vIkSiT | so 1) can i specify a version of clojure for lein to use, and 2) is there a way to see the output of the swank-polling process to see where it hangs? |
| 22:40 | arohner | vIkSiT: the released version of lein starts the clojure version it's built with |
| 22:40 | arohner | sorry, the stable version of lein |
| 22:40 | vIkSiT | arohner, ohh I see. |
| 22:41 | arohner | that's fixed on lein HEAD |
| 22:41 | vIkSiT | that sucks |
| 22:41 | vIkSiT | do you recommend using the version of lein that runs 1.2.0? |
| 22:41 | arohner | I haven't tried it, but I think other people are using it successfully |
| 22:42 | vIkSiT | ah ok. |
| 22:42 | vIkSiT | and any ideas about question 2) ? |
| 22:43 | slyphon | *slime-events* buffer? |
| 22:43 | slyphon | i usually do lein swank |
| 22:43 | arohner | also check *inferior-lisp* |
| 22:43 | slyphon | and then connect using M-x slime-connect |
| 22:43 | slyphon | that way if there's a narsty stack trace i see it |
| 22:43 | slyphon | (it also lets you set properties on the command line) |
| 22:44 | slyphon | (more easily than the other way) |
| 22:45 | vIkSiT | wait, you do lein swank from the command line? |
| 22:45 | vIkSiT | is that a valid option? |
| 22:45 | slyphon | yes |
| 22:45 | vIkSiT | weird. It doesn't seem so in my case |
| 22:45 | slyphon | are you using a recent lein |
| 22:45 | slyphon | wait, hang on |
| 22:46 | vIkSiT | "swank is not a task. Use "help" to list all tasks." |
| 22:46 | slyphon | lein version? |
| 22:47 | liebke | make sure you have [leiningen/lein-swank "1.1.0"] in your project file in :dev-dependencies |
| 22:47 | slyphon | ah, that too |
| 22:47 | slyphon | it's a plugin |
| 22:51 | vIkSiT | one sec, checkingversion |
| 22:51 | vIkSiT | its 1.1.0 |
| 22:51 | vIkSiT | I've added :dev-dependencies [[leiningen/lein-swank "1.1.0"]] to my project.clj now |
| 22:53 | vIkSiT | and now doing a lein deps. |
| 23:07 | arohner | so if I have a deftype/defrecord, and I get its constructor, java claims the constructor takes n+2 arguments, where 2 is the number of fields I have |
| 23:07 | arohner | lisppaste8: url? |
| 23:08 | hiredman | arohner: I imagine it also takes a map of metadata and maybe other stuff |
| 23:08 | arohner | hiredman: oh right, there are two |
| 23:24 | arohner | hiredman: btw, props again on naming c.c.java-utils/wallhack |
| 23:24 | arohner | I have a legitimate use for it now, and I smile each time I see the name |
| 23:34 | timcharper | Is there a way to map a collection of values across a function that has a side effect and still get the return value? |
| 23:34 | timcharper | Actually using the return value (somewhere down the line) is optional. |
| 23:34 | timcharper | (I'm mapping over a collection of hash maps and inserting records in a database, returning the results from those inserts) |
| 23:35 | timcharper | However, doseq, while successfully causing the side effects to occur, returns nil |
| 23:36 | arohner | timcharper: you can (doall (for [] ...)) |
| 23:36 | arohner | or (doall (map...)) |
| 23:37 | timcharper | Excellent! That's exactly what I'm looking for :-) thank you! |