2012-09-16
| 00:07 | abaranosky | Could any of you poin me in the right direction regarding this exception I'm seeing? |
| 00:08 | abaranosky | => Caused by: java.lang.IllegalArgumentException: No single method: single_val_error of interface: clj_schema.validation.ErrorReporter found for function: single-val-error of protocol: ErrorReporter |
| 00:08 | abaranosky | googling the exception didn't give me anything |
| 00:10 | tomoj | clojure.data extends protocols to interfaces |
| 00:10 | tomoj | java.util.{Map,List,Set} |
| 00:11 | tomoj | how might this be translated to cljs? |
| 00:11 | tomoj | naive way is to extend the protocol to every known implementation of IMap, ISequential, and ISet |
| 00:12 | S11001001 | abaranosky: it's difficult to say without more context |
| 00:13 | Sgeo | Quick question: What is the difference between importing a class and using only the class? |
| 00:13 | Sgeo | use'ing :only |
| 00:13 | abaranosky | S11001001: I just wrote a defprotocol w/ one implementer, one method is called single-val-error |
| 00:14 | akhudek | Sgeo: can you elaborate on what you mean by importing a class? |
| 00:14 | S11001001 | Sgeo: the former means something :) |
| 00:14 | Sgeo | (import 'some.package.SomeClass) |
| 00:14 | abaranosky | I found something: http://dev.clojure.org/jira/browse/CLJ-735 |
| 00:14 | Sgeo | vs (use '[some.package :only Class]) ; if I got the usage right |
| 00:15 | akhudek | Sgeo: I wasn't aware that you could use the "use" form to import java classes. I've always just used import. |
| 00:15 | S11001001 | Sgeo: you can't clojure.core/use classes; use is for ns bindings |
| 00:16 | S11001001 | sometimes there are associated ns bindings like with protocols |
| 00:16 | Sgeo | So Clojure doesn't consider a Java class to be in a package .. namespace... blah |
| 00:16 | Sgeo | Is this like the difference between fns and methods? |
| 00:16 | S11001001 | Sgeo: clojure nses are totally separate from the java packages |
| 00:17 | Sgeo | But couldn't I use a class like some.package/Class? |
| 00:17 | S11001001 | no |
| 00:17 | Sgeo | Which looks like some.package/something |
| 00:17 | Sgeo | Oh |
| 00:18 | S11001001 | it's better this way |
| 00:18 | abaranosky | found my issue: when I refactored to a protocl-based design, I missed one fn call, and forgot to change the args passed -- the error message is indeed criptic |
| 00:18 | Sgeo | How can you use a class without importing it |
| 00:18 | Sgeo | ? |
| 00:18 | S11001001 | Sgeo: put a top-level (Class/forName "...") before your references in the .clj file |
| 00:19 | Sgeo | O.O |
| 00:19 | S11001001 | you could also have all the imports in another module which you require |
| 00:20 | Sgeo | Why can't I just refer to it in a fully qualified way if I've required the package? |
| 00:20 | S11001001 | since the goal here is to get the classloader to wake up the relevant classes without adding ns entries for yourself |
| 00:20 | S11001001 | Sgeo: you didn't require "the package"; nses are not java packages |
| 00:20 | S11001001 | java packages don't really exist outside package-visibility terms, if you look at the vm and java.* apis |
| 00:21 | S11001001 | now, if, as a consequence of :require-ing a ns, you know that a classload will be implied (such as if the class is from a deftype in said module), then it's safe to make a fully-qualified reference |
| 00:22 | S11001001 | but if you're deftype-ing, you should already be able to access the class as an ns entry, as deftype is defined to add a public ns entry that just so happens to have the relevant class as the value |
| 00:23 | Sgeo | "relevant class as the value" |
| 00:23 | Sgeo | I thought the . form looks at the literal name given? |
| 00:23 | S11001001 | . operates in fairyland |
| 00:23 | Sgeo | ?? |
| 00:23 | lazybot | Sgeo: Uh, no. Why would you even ask? |
| 00:23 | S11001001 | ,(do (deftype blahblah []) (class blahblah)) |
| 00:23 | clojurebot | #<Exception java.lang.Exception: SANBOX DENIED> |
| 00:23 | S11001001 | hah |
| 00:23 | S11001001 | anyway |
| 00:24 | Sgeo | lazybot, are you good at your job?? |
| 00:24 | lazybot | Sgeo: Uh, no. Why would you even ask? |
| 00:27 | amalloy | S11001001: Class/forName to load a deftype seems perverse. it will work in exactly the cases where an ordinary (fully-qualified) reference to it would, i think |
| 00:27 | S11001001 | amalloy: I didn't suggest that |
| 00:28 | tomoj | why does (cljs.analyzer/analyze-file "cljs/core.cljs") return nil? |
| 00:28 | Sgeo | If I Class/forName a Java class, how do I refer to it? |
| 00:29 | Sgeo | Can I do a fully-qualified thing then? |
| 00:29 | S11001001 | Sgeo: yes |
| 00:29 | amalloy | then i don't understand "put a top-level (Class/forName "...") before your references in the .clj file", or the thing after it about putting imports in another module |
| 00:29 | S11001001 | amalloy: that's for the case where there isn't a related deftype |
| 00:30 | S11001001 | I don't know which situation Sgeo is in |
| 00:30 | Sgeo | S11001001, the situation of trying to fully understand the difference between all these functions and how they work together |
| 00:31 | amalloy | S11001001: (Class/forName "x.y.Z") is literally not ever any better than x.y.Z, except in the case where you have the class available at runtime but not at compile time. since those are basically the same in clojure, this is very rare |
| 00:31 | Sgeo | amalloy, what about for the side-effect of bringing in x.y.Z? |
| 00:31 | S11001001 | amalloy: merely referencing the class x.y.Z doesn't necessarily imply a load of it |
| 00:31 | S11001001 | s,load,classload, |
| 00:32 | S11001001 | this isn't typically observable in java.*, but crops up with third-party java libs |
| 00:33 | amalloy | S11001001: evidence or source? as far as i know, if you have a handle to a Class object, which is what x.y.Z resolves to, the class has been loaded |
| 00:34 | amalloy | in java projects, this sort of Class/forName is used mainly for a sort of dynamic linking, so that you can get at runtime a class you didn't know about at compile time |
| 00:41 | S11001001 | amalloy: ho hum. My source is me, running into side-effecty :import in the past, which I can't reproduce (at least in 1.4.0). So I guess Sgeo go with amalloy's suggestion of referencing the fqn to load |
| 00:57 | aperiodic | in clojure code, a naked fully unqualified java class reference will result in the class being loaded. source: me needing to use a Class/forName to get around not having a class that was being gen-classed in a different namespace that was being compiled later |
| 01:01 | amalloy | fully unqualified! that sounds exciting |
| 01:10 | Raynes | amalloy: What about the naked part? |
| 01:10 | aperiodic | heh |
| 01:10 | aperiodic | fully qualified |
| 01:11 | aperiodic | it's saturday night, guys. #clojure after-hours |
| 01:11 | mpan | funny that, I just got followed by a drunk stranger most of the way home |
| 01:12 | mpan | nice timing of you to mention that |
| 01:13 | aperiodic | protip: don't leave your house |
| 01:14 | aperiodic | it's totally overrated and stuff |
| 01:14 | uvtc | aperiodic: Maybe not even safe there! : http://xkcd.com/742/ |
| 01:15 | mpan | ah the joys of a campus full of alcoholics |
| 01:30 | akhudek | does wrap-reload now work with compound routes of routes? |
| 01:30 | akhudek | err not work |
| 01:33 | akhudek | damn, it seems not |
| 01:44 | akhudek | this is actually sort of surprising |
| 01:45 | akhudek | do people who use compojure with bigger nested routes not use wrap-reload during development? |
| 01:47 | mpan | where's a recent list of examples of clojure being used in production? |
| 01:47 | mpan | I recall there was one from a year ago, but anything newer? |
| 01:48 | akhudek | mpan: not that I know of, maybe someone else know though |
| 01:49 | akhudek | twitter and prismatic are two though |
| 01:49 | mpan | google isn't showing anything tech related for "prismatic company" |
| 01:49 | mpan | and twitter uses pretty much everything these days, right? |
| 01:50 | akhudek | http://getprismatic.com/ |
| 01:50 | akhudek | there are some other clojure based startups too |
| 01:50 | mpan | shiny |
| 01:52 | akhudek | http://lonocloud.com/ |
| 01:53 | mpan | so like, which parts of their system do these types of companies usually write in clj? |
| 01:54 | akhudek | prismatic has some blog posts about their usage |
| 01:54 | akhudek | seems like they use it for nearly everything |
| 01:54 | akhudek | even high performance machine learning algorithms via macros and low level java arrays |
| 02:09 | aperiodic | we're a still-in-beta startup (have a seed round) that uses clojure for roughly 2/3rds of our backend http://luckysort.com/ |
| 02:10 | mpan | oh cool |
| 02:10 | mpan | is your web frontend also clojure? |
| 02:11 | aperiodic | no, that's all js |
| 02:11 | aperiodic | we have a js wizard |
| 02:11 | aperiodic | he's great |
| 02:11 | aperiodic | there's a decent page about it on the clojure dev wiki: http://dev.clojure.org/display/community/Clojure+Success+Stories |
| 02:12 | akhudek | aperiodic: that looks like a neat product and good team! |
| 02:13 | mpan | cool, thank you! |
| 02:13 | aperiodic | i'm using cljs a little on the side (https://github.com/aperiodic/c2-cljs-examples so far), but no production experience with that, really |
| 02:15 | aperiodic | akhudek: thanks! |
| 02:36 | _ulises | morning all |
| 02:36 | mpan | hello |
| 02:37 | Sgeo | It would be nice if we had a bot that would let us play with macros |
| 02:38 | Sgeo | ,(do (use 'clojure.template) (macroexpand-1 '(do-template [a b] (+ a b) 1 2 3 4))) |
| 02:38 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: Could not initialize class clojure.lang.RT> |
| 02:38 | Sgeo | &(do (use 'clojure.template) (macroexpand-1 '(do-template [a b] (+ a b) 1 2 3 4))) |
| 02:38 | lazybot | ⇒ (do (+ 1 2) (+ 3 4)) |
| 02:38 | Sgeo | ,(+ 1 1) |
| 02:38 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: Could not initialize class clojure.lang.RT> |
| 02:38 | Sgeo | Who broke clojurebot and how? |
| 02:38 | mpan | that error looks oddly familiar |
| 02:39 | mpan | for future reference, what does it mean? |
| 02:50 | l1x | hey |
| 02:51 | l1x | how can i iterate over this map {0 [1 2 3], 1 [2 3 4], 2 [5 6 7]} i am trying to decompose it but no success :( |
| 02:52 | l1x | i just would like to do some ruby .each like stuff where i can access the key and the value as well |
| 02:55 | mpan | you can use map |
| 02:55 | mpan | map will get you a seq of 2-vectors containing key, val |
| 02:56 | l1x | like? |
| 02:56 | mpan | &(map pprint {0 [1 2 3], 1 [2 3 4], 2 [5 6 7]}) |
| 02:56 | l1x | this is not what i want |
| 02:56 | l1x | i need the keys and the values |
| 02:57 | mpan | that's (indirectly) what you want |
| 02:57 | mpan | if you need the individual values, do destructuring or indexing |
| 02:58 | l1x | this was my question, how to decompose (destruct) the nested map |
| 02:58 | Sgeo | l1x, are you hoping to produce a value or do side-effects? |
| 02:58 | mpan | ah ok, so there's two steps |
| 02:58 | mpan | map gets you each of the pairs, and then you destructure the pairs w/ let or similar |
| 02:58 | l1x | Sgeo: no just count the elements in the vectors |
| 02:59 | l1x | mpan: yep, i am just not sure how |
| 02:59 | Sgeo | &(let [[a b] [:key "val"]] (str "key: " a " val: " b)) |
| 02:59 | Sgeo | .. |
| 02:59 | mpan | http://clojure.org/special_forms look under the section on let |
| 02:59 | mpan | the bot got netsplit :( |
| 02:59 | Sgeo | Oh |
| 02:59 | scottj | (map (fn [[k v]] [k (count v)]) {0 [1 2 3] 1 [2 3]}) => ([0 3] [1 2]) |
| 03:00 | mpan | like let and other binding forms let you do that sort of destructuring |
| 03:00 | l1x | mpan: thanks |
| 03:01 | l1x | perfect |
| 04:40 | _ulises | to all functional gurus here, how would you implement the concept of nil using functions? would it be a function that takes an arbitrary number of parameters and does nothing? |
| 04:41 | _ulises | this is in reference to my church-numerals FizzBuzz I posted a few days ago; I'm now implementing hashtables and, of course, it gets tricky when you want to GET the value for a key and the key is not in the table |
| 04:57 | amalloy | _ulises: that wouldn't inspire me to invent nil |
| 04:58 | amalloy | (get m k (fn [v] ...) (fn [not-found] ...)) is sufficient, right? |
| 04:58 | _ulises | amalloy: I'm now wondering if I should be returning something else instead of nil when the key does not exist |
| 04:58 | _ulises | amalloy: ah, see, I'm trying to only use and return functions everywhere |
| 04:59 | amalloy | i'm aware |
| 05:00 | amalloy | instead of returning either the map's value (some function), or a function that somehow represents nil, instead ask the caller to pass you two continuations: one to be called with the value if there is one, and one to be called if no value is present for that key |
| 05:00 | _ulises | ah, gotcha |
| 05:01 | _ulises | I was now toying with the idea of returning EMPTY when the key doesn't exist, and (key value) otherwise |
| 05:01 | _ulises | then you're representing nil with EMPTY and can check with EMPTY? |
| 05:01 | amalloy | i don't know if that's the usual way to handle this in lambda calculus, but it seems as reasonable as anything else |
| 05:01 | _ulises | what I've seen so far is that NIL is equated to the EMPTY LIST |
| 05:01 | _ulises | which is unfortunate |
| 05:02 | _ulises | thanks for the suggestion though, I'll definitely try it |
| 05:02 | amalloy | i haven't studied church numerals at all, but it seems like the way you encode numbers makes it different to invent a separate nil value without conflicting with, say, zero |
| 05:03 | _ulises | I reckon you can't without clashing with anything else in the language |
| 05:03 | amalloy | _ulises: yeah, i really enjoyed the Programming With Nothing post, and i was happy to see you'd ported it to clojure |
| 05:03 | _ulises | what I've seen is that it generally clashes with the empty list; this is somewhat not that unfortunate since that means you can conj items to NIL as well as EMPTY |
| 05:04 | _ulises | amalloy: yeah, it's a fun exercise and I'm now seeing how far I can push it |
| 05:04 | amalloy | all the way to infinity, guaranteed |
| 05:04 | _ulises | excellent then! I shall be entertained ad-infinitum |
| 05:04 | mpan | is this why some dialects intentionally have nil as empty-list? |
| 05:05 | _ulises | mpan: no idea, perhaps? |
| 05:08 | amalloy | probably it's nice to have a small number of primitive types |
| 05:08 | amalloy | if the empty list is falsey, you don't need booleans or a separate nil type |
| 05:24 | _ulises | yikes, this is getting ugly |
| 05:37 | _ulises | oh, hum, here's another one. I'm using lists as a backend for hashtables. I'm storing key-value pairs as a pair (k v) inside a node in a the list. Of course this has horrible performance, but I'm not caring about this right now. |
| 05:41 | _ulises | the question is: PUT will CONJ to the list, effectively overriding already existing keys, which is fine, however the way REMOVE has been implemented, it'll return a new hashtable (a LIST) with the first pair that matches the key removed. That is fine, except that the new list is reversed in the process of removing the matching key-value pair. |
| 05:41 | _ulises | this is of course, wrong, since the reversing of entries means that older values for the same key will override newer values. |
| 05:42 | _ulises | I see 2 solutions here: 1) reverse the new LIST before returning it in REMOVE or 2) REMOVEing the key inside PUT before putting the new value for the key |
| 05:42 | _ulises | I'm taking votes/accepting feedback at this stage |
| 05:44 | pistolpete | question: I'm trying to compare a keyword value to a value that I'm trying to pull out of a map (one of the keys)...but I'm confused by its behavior. |
| 05:45 | pistolpete | (def testmap {:buildings {:1 {:apartment-building {}}, :2 {:apartment-building {}}, :3 {:apartment-building {}}}} ) |
| 05:45 | pistolpete | (keys testy) ;; => (:buildings) |
| 05:45 | pistolpete | (first (keys testmap)) ;; => :buildings |
| 05:45 | pistolpete | |
| 05:45 | pistolpete | (contains? (keys testmap) :buildings) ;; => false...why? |
| 05:46 | _ulises | ,(doc contains?) |
| 05:46 | clojurebot | "([coll key]); Returns true if key is present in the given collection, otherwise returns false. Note that for numerically indexed collections like vectors and Java arrays, this tests if the numeric key is within the range of indexes. 'contains?' operates constant or logarithmic time; it will not perform a linear search for a value. See also 'some'." |
| 05:46 | _ulises | ,(doc keys) |
| 05:46 | clojurebot | "([map]); Returns a sequence of the map's keys." |
| 05:47 | _ulises | pistolpete: contains? will check the presence of a key in a collection, not the value. |
| 05:47 | _ulises | ,(contains? [1 1 1] 2) |
| 05:47 | clojurebot | true |
| 05:47 | _ulises | perhaps you could wrap keys in a set? |
| 05:47 | pistolpete | d'oh, thanks. I'll have to change how I'm thinking about this data. |
| 05:47 | _ulises | ,(contains? (set (keys {:foo "" :bar ""})) :foo) |
| 05:47 | clojurebot | true |
| 05:48 | _ulises | ,(contains? (keys {:foo "" :bar ""}) :foo) |
| 05:48 | clojurebot | false |
| 05:48 | _ulises | there. |
| 05:48 | pistolpete | sweet! That's the solution. Thank you!! |
| 05:48 | _ulises | pistolpete: no worries; contains? is the source of confusion to many (including myself) |
| 05:48 | _ulises | pistolpete: I've seen the question and the answer so many times that now I remember :) |
| 05:50 | pistolpete | _ulises: hah, thanks. I need to make sure to remember that; most of my datastructures are maps |
| 05:50 | tomoj | &(contains? {:foo "" :bar ""} :foo) |
| 05:50 | lazybot | ⇒ true |
| 05:50 | pistolpete | &(println test) |
| 05:50 | lazybot | ⇒ #<core$test clojure.core$test@168be30> nil |
| 05:50 | pistolpete | oops |
| 05:53 | _ulises | tomoj: +1 |
| 07:18 | aperiodic | (inc tomoj) ; FYI, _ulises |
| 07:18 | lazybot | ⇒ 3 |
| 07:26 | aperiodic | lazybot: logs? |
| 07:26 | aperiodic | clojurebot: logs? |
| 07:26 | clojurebot | logs is http://clojure-log.n01se.net/ |
| 08:05 | hyPiRion | Is there any specific reason 'keep' doesn't take more than one collection as input? |
| 08:06 | hyPiRion | it's bugging me, as I kind of need that functionality. |
| 08:32 | luxbock | is there a way for me to disable *nREPL error* from popping up on Emacs when nREPL raises an exception? I would be alright with getting all of that information in the background without having to close that buffer every time |
| 08:35 | polycosm | hyPiRion: why don't you use a map to do that ? |
| 08:37 | polycosm | (just trying to understand what you mean) |
| 08:39 | polycosm | ,(map (partial keep #(if (odd? %) %)) [(range 1 10) (range 10 20)]) |
| 08:39 | clojurebot | ((1 3 5 7 9) (11 13 15 17 19)) |
| 08:39 | hyPiRion | polycosm: I can use (remove nil? (map f c1 c2)), but why can't I just use (keep f c1 c2) |
| 08:39 | hyPiRion | What I'm basically asking, is why keep is limited to one collection only. |
| 08:43 | augustl | http://stackoverflow.com/questions/12443236 - feel free to chip in.. Trying to figure out how to be able to execute a "python" process when the python scripts are packaged in a .jar file (resoufces) and isn't available directly on the file system |
| 08:49 | polycosm | hyPiRion: you can't use multiple cols with filter either, do yo |
| 08:49 | polycosm | should it also be possible ? |
| 08:54 | hyPiRion | polycosm: Well, for filter and remove, there's not much semantics in what you should return then (the first collection? all of them?). keep, on the other hand, will always return the computed value if it's non-nil. |
| 08:57 | nz- | how do I set the clojurescript version with lein-cljsbuild? |
| 09:57 | elliottw | morning all |
| 09:58 | elliottw | quick question: how do i turn a string into a symbol name (more specifically a function name)? |
| 09:59 | elliottw | i've tried things like (defn do-stuff [] "stuff!") (def data "do-stuff") (resolve (symbol data) but that doesn't seem to work |
| 10:00 | polycosm | ((load-string "f") args) ? |
| 10:01 | elliottw | polycosm jesus, i've been searching all over |
| 10:01 | elliottw | thanks, sorry for the noob-ish question |
| 10:01 | polycosm | but that looks so unsafe |
| 10:01 | elliottw | polycosm lol |
| 10:02 | elliottw | so what i'm trying to do is pass a bunch of function names as strings in noir from one page to another |
| 10:02 | elliottw | each function just takes in a few arguments and returns html (via hiccup) |
| 10:02 | elliottw | so to assemble a page, i just have a list of function names with args |
| 10:04 | polycosm | I don't know the specifics of noir and clojure stuffs but in any other language you probably shouldn't do that (anyone, please correct me if I'm wrong) |
| 10:05 | rcg | polycosm, because it is actually unsafe... |
| 10:05 | rcg | you are opening a barns door for injection attacks that way |
| 10:05 | rcg | imho |
| 10:05 | elliottw | i kind of thought this lisp thing was all about passing function names as args, it's just that in this case, it seems hard to pass funciton names between webpages |
| 10:06 | rcg | btw. i was just referring to using "load-string" |
| 10:06 | polycosm | why do you need to pass functions between webpages ? |
| 10:07 | elliottw | well i don't. it just seemed like the easiest thing to do. i have a bunch of functions that produce html. the input from one page will determine which functions should be run to product the html, so why not just pass a list of functions |
| 10:08 | elliottw | each function has a form when called with zero args, and result html when called with args |
| 10:09 | elliottw | so i can basically call a function with zero args, gather that data and call the function with the args someplace else |
| 10:18 | no7hing | i have troubles grokking this, but is there a post etc. out there that describes the route from multimethods to protocols? |
| 10:19 | no7hing | -but |
| 10:20 | nz- | clojurebot: logs? |
| 10:20 | clojurebot | logs is http://clojure-log.n01se.net/ |
| 10:25 | sandbags | Hi guys. Does anyone know how I can use 'apply' with 'and'. I looked up one trick for using macros here #(and %) but it doesn't seem to work with 'and' |
| 10:27 | sandbags | or is there an alternative to 'apply' that is macro-safe? |
| 10:27 | duck1123 | ,(reduce #(and %1 %2) [true true false]) |
| 10:27 | clojurebot | false |
| 10:27 | Hodapp | okay, I really wish I could edit Clojure code in Eclipse without pegging the CPU usage so much that, for instance, I can't repeat a key as fast as elsewhere in the system. |
| 10:28 | sandbags | duck1123: yes that works if you have a fixed number of parameters to and |
| 10:28 | sandbags | duck1123: but not in the general case |
| 10:28 | Hodapp | what in God's name is it doing? |
| 10:28 | sandbags | duck1123: well, either that or you're above my pay grade |
| 10:28 | duck1123 | sandbags: reduce will take them 2 at a time though |
| 10:28 | sandbags | oic |
| 10:29 | sandbags | nice bit of lateral thinking there |
| 10:31 | sandbags | seems a bit of a weakness that you can't use a macro here |
| 10:32 | sandbags | is 'and' a macro to allow for short-circuiting? |
| 10:32 | duck1123 | yes |
| 10:33 | duck1123 | otherwise, the second clause would be evaled before it was sent to and |
| 10:33 | sandbags | yep |
| 10:35 | sandbags | duck1123: what's the , at the start of your expression doing? I've just looked up Clojure syntax and can't see a comma pattern |
| 10:35 | gfredericks | clojurebot? |
| 10:35 | clojurebot | clojurebot is amazing |
| 10:35 | duck1123 | The comma is for the bot, and only used here |
| 10:35 | gfredericks | commas are whitespace |
| 10:36 | gfredericks | ,,,[,,,,8,,,7,,,5,,4,,],,,, |
| 10:36 | clojurebot | [8 7 5 4] |
| 10:36 | sandbags | oh, neat :) |
| 10:36 | duck1123 | ,(println "hello, I'm a bot") |
| 10:36 | clojurebot | hello, I'm a bot |
| 10:36 | duck1123 | &(println "so am I") |
| 10:36 | lazybot | ⇒ so am I nil |
| 10:36 | sandbags | i didn't grok that clojurebot had evaluated your expression |
| 10:36 | sandbags | that's very neat |
| 10:37 | gfredericks | sandbags: the macro has to know its arguments at compile-time |
| 10:38 | gfredericks | sandbags: this is part of why people avoid needless macros |
| 10:39 | sandbags | yes, it kind of breaks the fourth wall |
| 10:40 | ivaraasen | &(println "I have become") |
| 10:40 | lazybot | ⇒ I have become nil |
| 10:40 | ivaraasen | destroyer of worlds. |
| 10:41 | Hodapp | but how much do compile-time and run-time differ in Clojure? |
| 10:41 | gfredericks | significantly from a macro's perspective |
| 10:41 | Scriptor | Hodapp: in what sense? |
| 10:41 | Hodapp | hmmm |
| 10:41 | gfredericks | at macro-expand time the code is still an s-exp data structure |
| 10:41 | gfredericks | at runtime it is bytecode |
| 10:41 | duck1123 | in compile time, you don't have any of the runtime data. Your data is clojure code |
| 10:42 | gfredericks | that part too |
| 10:42 | gfredericks | you don't know what the "value" of the arguments is |
| 10:42 | gfredericks | just what they look like |
| 10:42 | gfredericks | ,(macroexpand-1 '(and foo bar baz)) |
| 10:42 | clojurebot | (clojure.core/let [and__2241__auto__ foo] (if and__2241__auto__ (clojure.core/and bar baz) and__2241__auto__)) |
| 10:42 | sandbags | so https://gist.github.com/7529c04e8836fe88b4d8 is my solution to writing a prefix function, any comments about style? Or a more idiomatic approach? |
| 10:43 | duck1123 | wouldn't this be a job for reducers? |
| 10:44 | sandbags | (I'm starting to read Brian Marick's book Functional Programming for the Object-Oriented Programmer |
| 10:45 | Scriptor | sandbags: I would use apply instead of reduce in there |
| 10:45 | sandbags | Scriptor: see above discussion, 'and' being a macro means you can't simply 'apply' |
| 10:46 | Scriptor | ah, now it all makes sense |
| 10:46 | Scriptor | please excuse me while I wake up :) |
| 10:47 | sandbags | duck1123: reducers appear to be a relatively new feature of clojure |
| 10:47 | sandbags | duck1123: you mean http://clojure.com/blog/2012/05/08/reducers-a-library-and-model-for-collection-processing.html ? |
| 10:48 | gfredericks | yes |
| 10:48 | sandbags | i think that's stretching my knowledge of clojure a little far right now |
| 10:49 | Scriptor | sandbags: you can also call (every? true? ...) on that |
| 10:50 | duck1123 | (every? identity (map = [1 2 3] [1 2 3 4 5])) |
| 10:50 | duck1123 | ,(every? identity (map = [1 2 3] [1 2 3 4 5])) |
| 10:50 | clojurebot | true |
| 10:50 | ludston | Question: Out of all of the books on clojure, which one is a must-read for someone who knows CL, but doesn't know very much about concurrency? |
| 10:50 | sandbags | ah yeah, neat |
| 10:50 | AimHere | Read them all at the same time |
| 10:51 | ludston | AimHere: Assuming I don't want to fork out $300 for a stack of books. |
| 10:52 | sandbags | yes, yet another library to learn... |
| 10:52 | AimHere | Don't do that just to appease my bad jokes |
| 10:52 | gfredericks | sandbags: I don't think there's any reason to use reducers if you're not concerned about performance |
| 10:52 | ludston | AimHere: I don't know man. It was a pretty convincing argument. |
| 10:53 | gfredericks | reducers might be pretty bad actually; I don't think it could short-circuit |
| 10:53 | duck1123 | I thought that was one of the benefits of reducers |
| 10:54 | gfredericks | not afaik |
| 10:54 | duck1123 | you could have a reduce that'd stop at a certain point |
| 10:54 | gfredericks | but if it's parallelized |
| 10:54 | gfredericks | and you have 20000 things |
| 10:54 | gfredericks | broken into size 500 chunks |
| 10:55 | gfredericks | and only the 2nd item in your list is false |
| 10:55 | gfredericks | then the first chunk short-circuits but the others will run I think |
| 10:55 | duck1123 | ok, I've only half listened to Rich's talk, I haven't really looked into using them yet |
| 10:55 | gfredericks | well I've WHOLE listened to Rich's talk and haven't really looked into using them yet |
| 10:56 | gfredericks | :) |
| 11:23 | duck1123 | Is there a way to silence the repeatability check? The Apache repo is down at the moment and I simply want to silence those checks until it's back up, but if I comment out that line, I get the repeatability failure |
| 12:39 | sandbags | ah, Brians solution is simpler still (def prefix-of? (fn [candidate seq] (= (take (count candidate) seq) candidate))) |
| 12:39 | sandbags | yes, i overcomplicated comparing item by item |
| 12:41 | sandbags | 33.. |
| 12:51 | dfd | I'm having trouble getting my JSON out of CouchDB, which has a field with (what seems to be) acceptable UTF-8 Japanese, without getting mangled. Anyone had any issues like this with clutch? When I look directly at the JSON from CouchDB, it seems fine. |
| 12:51 | sandbags | i wonder why it didn't occur to me to just compare the sequences directly since i'd previously made the leap to (take (count candidate) seq) before I realised that map will automatically only use the length of the shorter seq |
| 12:56 | dfd | Ah, nevermind, this seems to have been the issue: http://jkndrkn.livejournal.com/264856.html |
| 12:56 | dfd | verra interesting... |
| 12:56 | superparen | you can set -D in project.clj |
| 12:57 | superparen | or I assume a System/setProperty |
| 13:38 | TimMc | gfredericks: I *think* reducers allows you to specify a strategy for folding, and also provides a way to stop early. |
| 13:39 | gfredericks | TimMc: that would be cool |
| 13:39 | gfredericks | abort the other chunks before they finish? |
| 13:39 | gfredericks | I guess they aren't all necessarily running at once anyhow |
| 13:39 | TimMc | Right. This is just a vague impression/memory, anyhow. |
| 13:47 | darklajid | vim, vimclojure, nailgun. I guess I still don't understand what's going on behind the scenes. What are the requirements for classpath settings here? |
| 13:55 | Sgeo | I think the error monad may actually be more useful than a fixed maybe monad |
| 13:55 | Sgeo | Because then we could include exceptions as things that are usually "Left" |
| 13:56 | duck1123 | Does leiningen have a work offline mode? It's hitting a down server on every run for every one of my deps. And I'm running midje over and over |
| 14:28 | TimMc | duck1123: In the short term, can you use lein interactive? |
| 14:51 | ro_st | ckirkend`: i'm here, pm'd yo |
| 14:51 | ro_st | u |
| 15:05 | subversus | b#e |
| 15:52 | xeqi | duck1123: this is late, but you can set :offline true https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L207 |
| 15:56 | bruceadams | duck1123: you can add "offline? true" into your leiningen project.clj |
| 15:57 | bruceadams | it's an ugly approach for a temporary condition. there is a bug about this https://github.com/technomancy/leiningen/issues/678 |
| 16:14 | gfredericks | anybody heard of a cljs bug for :when in a doseq? |
| 16:16 | gfredericks | (doseq [a [1 2 3] :when a] a) fails to compile |
| 16:17 | gfredericks | CLJS-366 apparently |
| 17:14 | Hodapp | a lot of algebraic rules and other assorted syntactic nonsense for a system I'm re-implementing in Clojure... just collapsed down into a handful of functions in my head. |
| 17:14 | Hodapp | this must be why Lisp appeals to me. |
| 17:14 | amalloy | duck1123, gfredericks: in 1.5 you can short-circuit a reduce (but not a fold), whether or not you use reducers or just clojure.core/reduce |
| 17:15 | gfredericks | amalloy: wat |
| 17:15 | gfredericks | how you short-circuit in regular reduce? |
| 17:15 | amalloy | (reduced 10) ;; a value meaning "i'm done, return 10" |
| 17:15 | gfredericks | that is stinkin sweet. |
| 17:16 | gfredericks | I'm going to strive to use this in every function I write from now on. |
| 17:16 | mpan | ,(reduced 10) |
| 17:16 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: reduced in this context, compiling:(NO_SOURCE_PATH:0)> |
| 17:16 | mpan | &(reduced 10) |
| 17:16 | lazybot | java.lang.RuntimeException: Unable to resolve symbol: reduced in this context |
| 17:17 | mpan | is it special? |
| 17:17 | gfredericks | mpan: 1.5 only |
| 17:17 | gfredericks | ,*clojure-version* |
| 17:17 | clojurebot | {:interim true, :major 1, :minor 4, :incremental 0, :qualifier "master"} |
| 17:18 | mpan | ah thanks |
| 17:19 | gfredericks | no more "you can't use reduce for that" |
| 17:19 | Sgeo | Why not just use foldr and, in the function passed to it, not need the next value |
| 17:20 | mpan | does that mean you can reduce over an infinite seq now? |
| 17:20 | Sgeo | foldr in Haskell can reduce over infinite sequences |
| 17:20 | gfredericks | mpan: sounds like it |
| 17:20 | mpan | yay |
| 17:58 | Hodapp | hrmph. I am liking Clojure and Counterclockwise but it's regularly crashing Eclipse or just creating defunct REPLs |
| 18:04 | Hodapp | though this is doing a good job convincing me that I really should pick some other way than normal OOP to handle this. |
| 18:05 | Hodapp | and I'm finding that in a lot of cases it's easier this way, in that I'll just wrap a function in some form of a 'let' and all of what would normally be mutable ends up here |
| 18:06 | Hodapp | as I've lost track of the number of times when I see classes existing just to provide a function with a closure or partial application |
| 18:08 | Sonderblade | Hodapp: ymmv, but imho eclipse always feels too heavy weight for clojure, a shell and a good editor is all you need :) |
| 18:09 | Hodapp | Sonderblade: In CCW I'm able to swap in changes into the currently-running instance with one keystroke, and I find this very valuable |
| 18:09 | Hodapp | Sonderblade: I attempted to use vim & nailgun & lein-tarsier and it was just all too clunky |
| 18:10 | Hodapp | If I have the editor and the REPL separate then I must manually sync up the REPL with my code |
| 18:11 | Hodapp | so, yes, Eclipse is heavy and unstable but this is the only approach I've found so far that let me work quickly |
| 18:26 | akhudek | Hodapp: You could try Intellij + La Clojure. It doesn't sync up with lein or nrepl, but I find lein pom works with it well enough (just import the pom as a maven project). |
| 18:26 | akhudek | As an IDE, Intellij is much nicer than Eclipse. |
| 18:27 | casion | or emacs + nrepl.el. which is awesome |
| 18:28 | mpan | can you explain that second part about lein please? |
| 18:28 | luxbock | I'm having trouble with a lot of the hotkeys of Emacs / paredit for using it on Windows |
| 18:28 | luxbock | think I'll have to make make custom ones |
| 18:28 | casion | such as? |
| 18:28 | mpan | I'd be interested in trying a different feature-heavy IDE than Eclipse |
| 18:28 | luxbock | M-" { or [ don't work |
| 18:29 | luxbock | and a lot of the commands that use CM- |
| 18:29 | casion | using alt, or escape as M? |
| 18:29 | luxbock | alt |
| 18:29 | casion | does esc work? |
| 18:29 | luxbock | I haven't actually tried that |
| 18:30 | luxbock | though reaching for esc is not the greatest thing for work flow |
| 18:30 | casion | also http://www.gnu.org/software/emacs/manual/html_node/emacs/Windows-Keyboard.html |
| 18:30 | casion | i much prefer esc personally |
| 18:31 | luxbock | I'm a complete beginner with both Emacs and Clojure |
| 18:31 | scottj | esc rocks. I like it so much I swap esc and spacebar. |
| 18:31 | luxbock | so it's going to take some time to get started :) |
| 18:31 | luxbock | thanks for the link, that looks like it might solve some of my problems |
| 18:32 | casion | luxbock: keep in mind that using esc as meta is 'latching' |
| 18:32 | casion | so you can hit esc, let go, then C-m |
| 18:32 | casion | not esc-C-m at the same time |
| 18:32 | luxbock | oh |
| 18:32 | luxbock | I didn't know that |
| 18:35 | casion | luxbock: seems a lot of folks just map the windows key to meta in windows as well |
| 18:36 | casion | anyway, I like escape because I can hit it with my pinky easier than scrunching up to hit opt/alt |
| 18:36 | luxbock | yeah, I just installed Emacs two days ago so I'm still figuring things out |
| 18:37 | casion | always can ask in #emacs too :) |
| 18:38 | casion | and there's lots of starter kits out there that can help, such as https://github.com/technomancy/emacs-starter-kit and https://github.com/overtone/emacs-live |
| 18:40 | casion | Sgeo: what's the purpose of using monads in clojure? |
| 18:40 | Sgeo | Is there a way to do something conditionally based on whether or not a library is detectable? |
| 18:40 | Sgeo | Better yet, is there a _clean_ way to do so |
| 18:40 | Sgeo | casion, in many cases, convenience. |
| 18:40 | casion | Sgeo: wouldn't find-ns do that? |
| 18:41 | casion | for checking for a namespace's presence |
| 18:41 | Sgeo | casion, but hmm, is that a clean way to do it? |
| 18:42 | Sgeo | That is, what if my library ends up getting loaded in first |
| 18:42 | casion | there's something that was in clojure-contrib too |
| 18:42 | casion | let me see if I can find it |
| 18:43 | Sgeo | o.O olabini is here |
| 18:44 | casion | http://clojuredocs.org/clojure_contrib/clojure.contrib.find-namespaces |
| 19:08 | oich | more of a java question, but I'm trying to get ritz-nrepl to work and it can't connect to the socket. I'm using fedora 17 with either jdk 1.7 or jdk 1.5. I get the same result using jdb with selinux disabled and iptables rules flushed. Do you have any idea what the problem could be? |
| 19:09 | frio | oich: if you do lsof -n -i TCP, can you see the java process (and is it holding the port you expect it to?) |
| 19:13 | oich | frio no I don't see it but it could start and fail between invocations of lsof I guess. Using java -agentlib:jdwp etc. I can get a test java class to suspend and wait for jdb to attach. Then trying to attach it fails in the same way as ritz-nepl |
| 19:17 | frio | if it's not in that list, then it's not running :) |
| 19:17 | frio | which is why you won't be able to connect to it |
| 19:17 | frio | you can confirm with ps ax or something i guess |
| 19:20 | oich | Well, ritz-nrepl clearly runs because it produces an error message. It's not connecting, which is maybe why lsof doesn't show a socket for the process? |
| 19:41 | mindbender2 | is there something similar to (pwd) in clojure.java.io which was in clojure.contrib.io? |
| 19:42 | casion | just write it yourself (defn pwd [] (System/getProperty "user.dir")) |
| 19:43 | mindbender2 | casion: ok thanks |
| 20:32 | gfredericks | man himera is the ultimate in silent-fail: it simply prints nil on any compile or read error |
| 20:33 | mindbender2 | why is using set! to alter global dynamic vars in my repl throwing IllegalStateException. It's preventing my repl from being piggiebacked. I'm using 1.4 |
| 20:34 | gfredericks | does it have a thread-local binding? |
| 20:34 | mindbender2 | with binding form you mean? |
| 20:34 | gfredericks | yeah |
| 20:34 | mindbender2 | no, |
| 20:35 | gfredericks | set! only works on vars with thread-local values |
| 20:35 | mindbender2 | just direct set! within a fn |
| 20:35 | gfredericks | what var is this and why do you need to change it? |
| 20:35 | mindbender2 | it's piggieback.clj that's the culprit |
| 20:36 | gfredericks | okay; I'm not familiar with that |
| 20:36 | mindbender2 | trying to modify *cljs-repl-env* |
| 20:36 | gfredericks | you can change a var's root value if you want |
| 20:36 | gfredericks | with alter-var-root |
| 20:36 | mindbender2 | ok thanks I'll try to modify the file and see what happens |
| 20:38 | gfredericks | note you have to use a function there; so you might want clojure.core/constantly |
| 20:38 | mindbender2 | I was about to mention that it required a fn thanks for poiting out |
| 20:38 | mindbender2 | *pointing |
| 21:16 | oich | it seems like my problem running ritz-nrepl is a problem with using the jdi connector that it uses. Is anyone using ritz-nrepl and has it working? |
| 21:46 | ZEFRENCHACCENT | oich, last week |
| 21:46 | ZEFRENCHACCENT | I sawr a film |
| 21:47 | matt_d | i'm watching a film right now |
| 22:04 | oich | my problem with JDI doesn't happen in a different linux, so it's not ritz-nrepl |
| 22:20 | oich | thanks. I must reboot now. |
| 23:03 | ivan | anyone else have problems with La Clojure locking up IDEA for 10+ seconds? |
| 23:03 | talios | you mean La Clojure -works-? ;-) |
| 23:04 | talios | Actualy, it was updated for 12. but that was a fork afaik. |
| 23:04 | ivan | well, it can colorize Clojure source |
| 23:04 | ivan | I'm on 11 and the non-fork, I assume |
| 23:05 | talios | any exceptions in your ~/.IntelliJ11/logs/idea.log file? |
| 23:05 | talios | ( i think thats the path, for linux ) |
| 23:06 | frio | ooh |
| 23:06 | frio | is idea 12 out? |
| 23:06 | ivan | don't see anything out of the ordinary in that log, but I also have threadDumps that show 20 different threads waiting for things |
| 23:07 | ivan | frio: only EAP |
| 23:08 | ivan | I also have a CPU usage profile but I have no YourKit Java Profiler license |
| 23:08 | ivan | not that it's using any CPU while locked up |