2012-03-01
| 00:00 | gtuckerkellogg | has anyone here had a look at the Clojure implementation in python that just showed up on github? |
| 00:01 | accel | Is there something equivalent to an OpenGL displaylist, but operates on Java Graphics2D environments? For example, I have a bunch of commands I end up sending a Java Graphics2D -- I would like to "save/replay" the list of commands -- basically a display list. Is there a way to do this? Alternatively, is there some Java component that operates as a Graphics2D, but then I can render into anotehr Graphics2D? (I don't want to render to image, then image to Gr |
| 00:01 | technomancy | gf3: I like the UI |
| 00:02 | gf3 | technomancy: thank you, I wanted something extremely basic |
| 00:03 | ibdknox | yeah, that's neat |
| 00:36 | choffstein | Anyone know why I might be getting a 'java.util.zip.ZipException: ZIP file must have at least one entry' from 'lein uberjar'? |
| 00:48 | choffstein | Damnit, I always forget to use _ instead of - with java interop... |
| 00:51 | amalloy | choffstein: you generally don't have to, right? clojure will munge the names |
| 00:52 | choffstein | Well, I had to do it with :import earlier, and I just had to change my :main config in my leiningen project from - to _ |
| 00:52 | choffstein | These little "gotchas" seem to get me wayyyyy too often |
| 00:57 | seancorfield | clojure.java.jdbc 0.1.2 just despatched to maven central... |
| 01:14 | MenTaLguY | hmm |
| 01:14 | MenTaLguY | can record definitions be made visible outside the namespace in which they are defined? |
| 01:14 | brehaut | MenTaLguY: what are you wanting to do with the record? |
| 01:15 | MenTaLguY | just instantiate it really |
| 01:15 | MenTaLguY | I could certainly create constructor functions and use those or something |
| 01:15 | brehaut | MenTaLguY: in 1.3 you should use the concstructor functions |
| 01:15 | brehaut | eg, (defrecord Foo …) creates ->Foo and map->Foo |
| 01:15 | emezeske | technomancy: Would you expect the rlwrap/jline stuff in the Leiningen shell script to work for trampoline" commands? |
| 01:16 | MenTaLguY | ->Foo? |
| 01:16 | xeqi | seancorfield: did you find a different fix for sqlite, transactions, and requiring the result set to be closed? |
| 01:16 | choffstein | MenTalguY: You should be able to import them |
| 01:16 | brehaut | choffstein: but you sjhouldnt need to if constructing them is all you want |
| 01:16 | MenTaLguY | yeah, I really just need constructors |
| 01:17 | brehaut | MenTaLguY: (defrecord Foo [a]) (->Foo 1) ;=>#user.Foo{:a 1} |
| 01:17 | choffstein | I really need to read something on "good clojure code" |
| 01:17 | MenTaLguY | hm, that doesn't work for me |
| 01:17 | MenTaLguY | I thought I was using 1.3 |
| 01:17 | MenTaLguY | hm, I guess not |
| 01:18 | brehaut | yeah you have to be in 1.3 or up. in 1.2 you probably want to create a constructor yourself |
| 01:18 | brehaut | (although dont name it the same as the autogenerated constructor) |
| 01:19 | choffstein | Is lein 1.7 stable? |
| 01:20 | brehaut | MenTaLguY: otherwise, you need to a) require the namespace containing the record definition (at least once, somewhere in the code, best to do it whenever you reference it) and b) then import it |
| 01:21 | brehaut | import without the require (or use) will fail because the class is generated at runtime (unless you AOT your project i guess) |
| 01:21 | MenTaLguY | b) = import it as a Java class? |
| 01:21 | brehaut | yup exactly |
| 01:21 | MenTaLguY | aha |
| 01:21 | MenTaLguY | okay, I was assuming that defrecord Foo created a var named Foo |
| 01:21 | MenTaLguY | but it's a class name instead |
| 01:21 | MenTaLguY | now I understand the behavior |
| 01:21 | brehaut | actually it does both |
| 01:21 | hiredman | in 1.3+ you get factory functions for records |
| 01:22 | hiredman | (->Foo ...) |
| 01:22 | brehaut | but the var is bound to stuff other than the class |
| 01:22 | MenTaLguY | mm |
| 01:22 | brehaut | wait. i might be thinking of records; ignore my foolishness |
| 01:25 | xeqi | seancorfield`: https://gist.github.com/1947746 - looks like there is a sqlite transaction issue |
| 01:25 | MenTaLguY | I'm thinking of records |
| 01:26 | brehaut | sorry, i meant protocols. having a brain failure |
| 01:26 | brehaut | just for the bit about being bound to stuff other than the class |
| 01:26 | MenTaLguY | mm |
| 01:26 | hiredman | records somewhat similar in doing some funkiness with the mapped names in the namespace |
| 01:28 | brehaut | hah macro expanding a defrecord is not for the feint of heart |
| 01:30 | hiredman | certainly not |
| 01:31 | brehaut | huh. so the defrecord does an implicit import of the record class when it is created |
| 01:33 | hiredman | it actually imports a different class with the same name everytime it is run |
| 01:34 | brehaut | hiredman: what is the purpose of the `(let [] …) ? why not a do? |
| 01:34 | MenTaLguY | I imagine that's probably an artifact of macro expansion |
| 01:34 | brehaut | oh sorry, im looking at the macro source here |
| 01:34 | MenTaLguY | maybe there are other cases in the intermediate macros where that let would be populated... ah |
| 01:34 | brehaut | its much less boggling |
| 01:34 | MenTaLguY | so I don't know then |
| 01:36 | choffstein | Anyone use s3-wagon-private? I am trying to deploy to a private repo and all of a sudden I am getting an Authentication Failed error... |
| 01:36 | hiredman | brehaut: I think it is to prevent the code from being evaluated using the rules for top level dos |
| 01:36 | brehaut | hiredman: ah interesting thanks |
| 01:36 | hiredman | "compile this as one chunk, all using the same classloader) |
| 01:36 | hiredman | " |
| 01:36 | hiredman | ah, damn brackets |
| 01:37 | brehaut | thats really intersting |
| 01:38 | hiredman | I think it was actually switched for a do at one time and it broke |
| 01:38 | brehaut | huh |
| 01:40 | brehaut | i wonder if its time to remove 'Alpha – subject to change' from the docstrings |
| 01:42 | hiredman | https://github.com/clojure/clojure/blob/5f090a0925f3dcbd3fa8b7104cd59b6d4c087413/src/clj/clojure/core_deftype.clj#L153 |
| 01:42 | hiredman | huh |
| 01:43 | brehaut | curous |
| 01:43 | hiredman | https://github.com/clojure/clojure/commit/2ac93197 |
| 01:43 | hiredman | thats the one |
| 01:43 | hiredman | oh, right |
| 01:44 | brehaut | the commit message makes it clear |
| 01:44 | hiredman | because the dynamic classloader keeps a weakreference to the class, so it was possible for the class to be create, then flushed before it was used |
| 01:44 | MenTaLguY | that's one of those commits that really wants an explanatory comment at the site |
| 01:44 | hiredman | crazy race condition |
| 01:44 | hiredman | 2 years ago |
| 01:50 | bbloom | i need a little help writing some production quality code with refs and file io |
| 01:51 | MenTaLguY | hm, I guess the first rule of transactions and io is don't cross the streams |
| 01:51 | bbloom | yeaaah, hence why i need help :-) |
| 01:51 | bbloom | 1 sec, my irc is freaking out |
| 01:52 | bbloom | k let me try again :-) |
| 01:52 | bbloom | so basically i want a disk-backed map |
| 01:52 | bbloom | i need the D of the ACID ;-) |
| 01:53 | bbloom | i want to work entirely in memory, but load missing values from disk & write through to disk on changes |
| 01:53 | bbloom | i have much higher read load then write load |
| 01:53 | MenTaLguY | so not a clojure map (in the sense of implementing IMap)? |
| 01:53 | bbloom | it's a normal {} clojure map |
| 01:54 | MenTaLguY | in which case I think "write through to disk on changes" might be your first issue |
| 01:54 | MenTaLguY | since normal clojure maps are immutable |
| 01:54 | bbloom | well changes to the ref :-P |
| 01:55 | MenTaLguY | so how do you envision lazily fetching keys from disk working? |
| 01:55 | bbloom | i want: |
| 01:55 | bbloom | try to get from map |
| 01:55 | bbloom | if it's there, great! |
| 01:55 | bbloom | if it's not there, load it from disk and cache it in the map |
| 01:56 | replaca | technomancy: you there? I've got a couple questions on precate |
| 01:56 | bbloom | when adding a key to the map, write a copy to disk |
| 01:56 | MenTaLguY | I don't think you can get from here to there with normal clojure maps, at least not with that kind of interface |
| 01:56 | bbloom | …really? |
| 01:56 | bbloom | it seems pretty straight forward… i'm just concerned about consistency of things |
| 01:56 | bbloom | it seems like: |
| 01:57 | bbloom | (if-let [foo (get-cached-foo)] foo (if-let [foo (load-foo)] (do (cache-foo) foo) (new-foo))))) |
| 01:57 | bbloom | on get |
| 01:58 | bbloom | as long as i write to /tmp/new-foo-123123213 and then rename atomically the file into place |
| 01:58 | bbloom | in the "write" code path |
| 01:58 | brehaut | bbloom: you'd have to lock all the other transactions though, otherwise you would be risking hitting the disk multiple times concurrently for the same piece of data |
| 01:58 | brehaut | which kind of defeats the point of a transactional memory system |
| 01:58 | hiredman | bbloom: see https://github.com/clojure/core.cache |
| 01:58 | brehaut | s/lock/some non-composable coordination mechanism/ |
| 01:59 | bbloom | hiredman: thanks, will look |
| 01:59 | bbloom | brehaut: it sounds like you're saying clojure's STM is simply incompatible with durability… which doesn't make sense… sooo what am i missing? |
| 01:59 | brehaut | yeah that is what im saying |
| 02:00 | brehaut | not that im an expert |
| 02:00 | brehaut | but if its all in memory, its not going to be durable |
| 02:00 | bbloom | hence why i want to write to disk :-) |
| 02:01 | brehaut | bbloom: but if you add that disk durability what you have is not a transactional memory system, its an on disk database |
| 02:01 | brehaut | that you happen to cache in memory |
| 02:02 | bbloom | yeah, so? |
| 02:02 | brehaut | well then, why try to shoe horn it into STM? |
| 02:02 | brehaut | why not just use a database that does this for you? |
| 02:03 | bbloom | b/c i want to do some complex analysis that is simply not well suited for a relational model |
| 02:04 | brehaut | i never said relational database |
| 02:04 | bbloom | well regardless, i have a lot of small objects that form a complex relationship graph that i want to traverse very quickly in memory |
| 02:04 | bbloom | occasionally, i append data to it |
| 02:05 | bbloom | seems like this shouldn't be a "don't do that" situtation lol |
| 02:05 | brehaut | its more that theres more than one in memory cooridination mechansim in clojure |
| 02:06 | bbloom | and my question is how best to coordinate them to ensure consistency with a single file on disk per key |
| 02:06 | brehaut | thats a better question :) |
| 02:06 | clojurebot | Gabh mo leithscéal? |
| 02:06 | brehaut | and one i dont know the answer to |
| 02:09 | bbloom | well maybe we can work it out :-) |
| 02:10 | seancorfield` | xeqi: yeah, i missed a test in the patch and that's the only thing that highlights the issue |
| 02:10 | bbloom | i'm trying to avoid explicit locking |
| 02:10 | xeqi | seancorfield`: making new patch now for it |
| 02:11 | bbloom | usually, i'd write to /tmp/whatever & then rename(2) it into place atomically |
| 02:11 | bbloom | which clearly i can do here… but i'm not sure how to coordinate that with dotrans or whatnot |
| 02:12 | bbloom | dosync, rather |
| 02:17 | bbloom | core.cache looks really nice tho |
| 02:17 | bbloom | i have to study it a bit more… |
| 02:28 | _ulises | morning all |
| 02:35 | seancorfield | xeqi: ok, java.jdbc 0.1.3 is headed for maven now with that extra test (and the fix) for sqlite |
| 02:38 | xeqi | seancorfield: thanks for all your work on it |
| 02:40 | replaca | b |
| 02:41 | seancorfield` | xeqi: sorry for not picking up all the bits of your original patch... by the time i'd waded thru all the sql server stuff, it was quite out of whack :) |
| 02:42 | seancorfield` | the only db i don't have setup locally now is postgresql |
| 02:43 | xeqi | heh, I remember having fun trying to figure all the mssql on ec2 stuff |
| 02:45 | xeqi | I'm a big fan of vagrant for project setups like dbs |
| 02:48 | bbloom | brehaut: this thread is helping: https://groups.google.com/forum/?fromgroups#!searchin/clojure/agent$20dosync$20file/clojure/N0SYT7soAtU/-d_eH-4P_gMJ |
| 02:48 | bbloom | (and the linked threads) |
| 02:48 | bbloom | it seems like the strategy is to send the file writing to an agent |
| 02:49 | bbloom | and then update the refs from the agent |
| 02:54 | Bahman | Hi all! |
| 02:56 | seancorfield` | xeqi: i have a win xp VM with sql server 2005 express on it :) |
| 02:57 | seancorfield` | and now i have the jtds and ms sql server drivers on the mac so i can run mvn test with suitable env vars and test against sql server running in the VM |
| 02:57 | seancorfield` | hi Bahman |
| 02:57 | Bahman | Hey seancorfield` |
| 03:13 | j0k3r | new to clojure, was trying to solve http://www.4clojure.com/problem/26#prob-title |
| 03:13 | j0k3r | i am trying it on clooj |
| 03:14 | j0k3r | (defn fibo [x n a b] ( (if (> x n) '() ( concat '(+ a b) ( fibo (+ x 1) n b (+ a b) ) ) )) ) |
| 03:15 | AimHere | That takes 3 too many arguments, doesn't it? |
| 03:15 | j0k3r | this returns (fibo 1 2 0 1) it returns (+ a b + a b) |
| 03:15 | j0k3r | can anyone please point me to what is going wrong? |
| 03:15 | raek | j0k3r: you have a quote in there for some reason |
| 03:15 | AimHere | You're quoting a and b |
| 03:16 | raek | j0k3r: better to use (cons element seq) than (concat [element] seq) |
| 03:16 | AimHere | Also you probably meant '(list (+ a b))', but go with the cons instaed |
| 03:16 | AimHere | *cons |
| 03:16 | raek | (concat [element] seq) could also be written as (concat (list element) seq), which is what I think you meant |
| 03:16 | AimHere | *instead |
| 03:19 | raek | I would write it (assuming a non-lazy, stack consuming version here) as: (defn fibo [n] (letfn [(iter [n a b] (when (pos? n) (cons (+ a b) (iter (dec n) b (+ a b)))))] (iter n 1 1)) |
| 03:21 | AimHere | I would cheat. (fn [n] (take n '(1 1 2 3 5 8 13 21 34 55))) |
| 03:21 | j0k3r | I thought '(+ a b) will create a list |
| 03:21 | AimHere | ' is a synonym for 'quote' |
| 03:21 | AimHere | As in, don't evaluate the contents |
| 03:22 | j0k3r | oh ok |
| 03:22 | AimHere | It's confusing you, because when you need to type a list in the repl, you need to quote it |
| 03:22 | AimHere | Otherwise it gets evaluated too soon |
| 03:22 | raek | j0k3r: '(1 2 3) will be a list, because "(1 2 3)" is a list in the source code |
| 03:23 | raek | just like 'foo becomes a symbol |
| 03:23 | raek | it is not intended as a syntax for data structure literals |
| 03:23 | j0k3r | (defn fibo [x n a b] ( (if (> x n) () ( concat (+ a b) ( fibo (+ x 1) n b (+ a b) ) ) )) ) this is w/o the quotes version |
| 03:23 | j0k3r | and calling (fibo 1 1 1 1) |
| 03:24 | j0k3r | throws classcast exception |
| 03:24 | raek | j0k3r: this will not work. lets assume a = b = 1. then (concat (+ a b) ...) becomes (concat 2 ...) |
| 03:24 | AimHere | That's because you're trying to concat (+ a b), which is just a number |
| 03:24 | raek | but 2 is not a sequence! |
| 03:24 | AimHere | cons it instead, or if you're REALLY stuck on concat, make a list out of (+ a b) |
| 03:25 | raek | j0k3r: you want 'cons' here |
| 03:26 | raek | j0k3r: [1 2 3] is short for (vector 1 2 3), {:a 1, :b 2} is short for (hash-map :a 1 :b 2), but there is no short for (list 1 2 3) |
| 03:28 | AimHere | Well (1 2 3) IS a list, but since your interpreter is eating up lists and evaluating them as code it's not the list you want |
| 03:29 | AimHere | Ignore what I just said, though, because it'll confuse you at this stage ;) |
| 03:29 | clojurebot | Pardon? |
| 03:29 | j0k3r | (defn fibo [x n a b] ( (if (> x n) () ( cons (+ a b) ( fibo (+ x 1) n b (+ a b) ) ) )) ) the cons version throws EmptyList cant be cast to clojure.lang.IFn |
| 03:30 | j0k3r | I also tried creating a list out of the fibo call but throws the same error |
| 03:31 | raek | j0k3r: you are calling the result of the (if ...) expression |
| 03:32 | raek | rewrite (defn fibo [x n a b] ((if ...))) into (defn fibo [x n a b] (if ...)) |
| 03:34 | j0k3r | thanks a lot raek and aimhere, that worked! |
| 03:35 | j0k3r | offtopic: whats a good way to copy/paste code from clooj to irc |
| 03:35 | j0k3r | ? |
| 03:36 | raek | j0k3r: people often use https://refheap.com/paste or http://gist.github.com/ unless the code is very short and fits on one line |
| 03:37 | raek | and then post the link to the paste |
| 04:20 | ar_ | for 4clojure problem #26 fibonacci seq I am trying to define a function inside a function : https://refheap.com/paste/898 |
| 04:21 | ar_ | this throws an exception : #<CompilerException java.lang.IllegalArgumentException: let requires an even number of forms in binding vector (NO_SOURCE_FILE:2)> |
| 04:21 | muhoo | what'd be a good jvm to use for clojure on an ARM platform (angstrom/openembedded)? |
| 04:21 | ar_ | when called like : (fibo 2) |
| 04:21 | ar_ | any pointers? |
| 04:21 | accel | I would formally like to file a compliant with the council of clojure wizards. How the &*#! does clojure pick which java function to call when there are multiple java functions of the same name that take the same number of arguments? I'm constantly baffled by which one of java's Graphics.drawImage is being called. Is there a good tutoirla on getting this to work? I tried hinting it via #^ to give type hints on the arguments, but clojure's there like "no d |
| 04:23 | accel | I can't even properly google for this, when I gogole for "clojure pick java function" or "clojure choose java function", all I get are all these posts about how happy peopl are for CHOOSING/PICKING to use CLOJURE, on teh JAVA vm, and do FUNCTIONAL programming --- argh; google-fu fail |
| 04:25 | amalloy | accel: (a) your first rant was so long it didn't fit in an IRC message, and (b) that means you're not type-hinting correctly |
| 04:28 | accel | amalloy: I will look into type hinting; thanks |
| 04:38 | vijaykiran | accel: does this help ? https://gist.github.com/381625 |
| 04:39 | christianberg | ar_: Your code has several problems... First, lose the extra set of parentheses (opening on line 2). |
| 04:39 | clgv | vijaykiran: accel: with (:import 'mypkg.Ugly) you can skip the namespace in the code |
| 04:40 | raek | (import 'mypkg.Ugly) or (ns ... (:import mypkg.Ugly)) |
| 04:40 | raek | no quote in the the latter case |
| 04:40 | vijaykiran | wasn't my code :-) http://stackoverflow.com/questions/2722856/how-do-i-call-overloaded-java-methods-in-clojure |
| 04:40 | christianberg | ar_: Also, you need to quote the lists in your first two cond clauses, or use vectors instead: [1] and [1 1]. |
| 04:41 | clgv | raek: lol right. I thought of both at ones ;) |
| 04:41 | clgv | *once |
| 04:41 | raek | otherwise (:import 'mypkg.Ugly) is treated as (:import (quote mypkg.Ugly)), that is "import the mypkg.Ugly class from the quote package" |
| 04:42 | christianberg | ar_: And then, of course, the function never terminates when n>2. |
| 04:42 | raek | accel: since Clojure 1.2 type hints use ^Class syntax instead of the old #^Class syntax |
| 04:50 | accel | vijaykiran: nice; thanks |
| 04:50 | accel | raek: noted |
| 04:53 | raek | accel: This is (briefly) described here: http://clojure.org/java_interop#Java%20Interop-Type%20Hints |
| 04:58 | bOR_ | '(+ 3 1) |
| 04:59 | vijaykiran | ,(+ 3 1) |
| 04:59 | clojurebot | 4 |
| 04:59 | bOR_ | thanks. |
| 05:13 | vijaykiran | What's the best way to keep the agent state - persisted (as in: to a database) |
| 05:13 | vijaykiran | should I just send-off a function/agent that writes the current to db ? |
| 06:48 | Kototama | hi, what's wrong with this code http://paste.lisp.org/+2QTN it works but when compiled into a WAR the protocol can not be found |
| 06:49 | clgv | Kototama: usually you have to (:import the |
| 06:49 | clgv | args |
| 06:50 | clgv | Kototama: humm. could be an :import issue. |
| 06:52 | Kototama | it don't thing so, defprotocol doc says "defprotocol is dynamic, has no special compile-time |
| 06:52 | Kototama | effect, and defines no new types or classes." |
| 06:53 | clgv | Kototama: defprotocol defines a matching interface |
| 06:53 | Kototama | but why does the code works with SLIME but not compiled? |
| 06:55 | clgv | thats a good question afaik satisfies? works on the protocol and not the interface |
| 06:55 | clgv | is satisfies? really the line which causes the exception? |
| 06:56 | clgv | (defprotocol Bla (blubb [this x])) (.isInterface user.Bla) => true |
| 06:59 | Kototama | hum maybe not |
| 06:59 | Kototama | the error is at carneades.engine.argument_construction__init.<clinit>(Unknown Source) |
| 06:59 | Kototama | so while initialization the namespace |
| 07:00 | Kototama | to i need to (:gen-class) the file defining the defprotocol? |
| 07:02 | clgv | Kototama: no. that should not be necessary |
| 07:02 | clgv | maybe there is an entirely unrelated error in there |
| 07:03 | clgv | you should look at the ensted exceptions which will tell you more |
| 07:03 | clgv | *nested |
| 07:06 | Kototama | i'll paste the stacktrace because i don't see the error |
| 07:09 | Kototama | here the nasty error http://paste.lisp.org/display/128075#1 :-S |
| 07:11 | clgv | can you past carneades.engine.argument_construction.clj as well? |
| 07:12 | clgv | what clojure version do you use? |
| 07:12 | Kototama | 1.3 |
| 07:12 | Kototama | (:import of the protocol does not work |
| 07:13 | clgv | yeah. I guess you use the interface somewhere where you dont :use or :require the namespace it is in |
| 07:13 | Kototama | the file is here: https://github.com/carneades/carneades/blob/port-pm-tool/src/CarneadesEngine/src/carneades/engine/argument_construction.clj |
| 07:13 | clgv | you can verify that by explicitly AOTing the file that defines the protocol. then it will run smoothly |
| 07:14 | raek | Kototama: at the point where you import the class, has the clojure file that defines it been evaluated? |
| 07:14 | raek | (i.e. have you required the namespace before importing the class?) |
| 07:14 | Kototama | yes |
| 07:23 | Kototama | it seems analgous to me here http://stackoverflow.com/questions/6003313/noclassdeffounderror-on-a-protocol-when-requiring-its-namespace |
| 07:31 | clgv | Kototama: did you try to AOT-compile the file defining the protocol yet? |
| 07:31 | clgv | that should fix the problem and indicates that you are currently missing a require or use |
| 07:39 | Kototama | i'm trying now |
| 07:42 | clgv | Kototama: if you are using leiningen you can just add a setting for AOT to project.clj |
| 07:46 | Kototama | yes thanks |
| 07:46 | Kototama | it seems to build nicely |
| 07:46 | Kototama | i need to redploy and test |
| 07:55 | Kototama | still having the problem |
| 07:55 | Kototama | i will take a break |
| 08:03 | clgv | you still have the problem with AOT-compilation? |
| 08:05 | mdeboard | What does aot stand for |
| 08:05 | mdeboard | Approximately on time? |
| 08:06 | ejackson | any old thing |
| 08:08 | mdeboard | Ahead of time, TIL |
| 08:36 | @rhickey__ | I just pushed optional metadata elision during compilation - supply a collection of keywords as clojure.core/*elide-meta* or -Dclojure.elide.meta="[:doc :file]" etc |
| 08:36 | @rhickey__ | no op if not used |
| 08:36 | @rhickey__ | please try it out if it is something you can use |
| 08:36 | @rhickey__ | will be in next beta |
| 08:37 | @rhickey__ | I realize this is technically a new feature, but since 855 will require some review I'd like people to kick the tires on this as well |
| 08:41 | @rhickey__ | one small step for trimming things down on android etc, full tree shaking and dropping ASM will have to wait for future releases |
| 09:04 | Kototama | clgv: it works now. I think I aot the wrong file by mistake previously. Thanks a lot. It was really helpful. It's nasty that the behavior is not the same if one forget to AOT the file. |
| 09:05 | clgv | Kototama: well to get this right. AOT is hiding the symptoms only. somewhere in your code there is a missing require or use |
| 09:06 | Kototama | not sure about that, I checked where the protocol is used, and it's only used in three places |
| 09:06 | Kototama | every place (:use the namespace of the protocol |
| 09:06 | Kototama | the only funky things i do is dynamically loading all this stuff via load + slurp |
| 09:07 | clgv | hmm but somehow in the execution flow the Interface is used before the protocol definition is compile |
| 09:07 | Kototama | I mean if a :use was missing I would get an error in SLIME no? |
| 09:08 | clgv | whats the load+slurp stuff you are talking about? |
| 09:08 | Kototama | instead of having xml data if have a clojure file representing data |
| 09:08 | Kototama | but the data needs this namespace to create |
| 09:09 | Kototama | so I do a (load-string (slurp url)) to get them |
| 09:12 | mdeboard | 09:06 <Kototama> instead of having xml data if have a clojure file representing data |
| 09:12 | mdeboard | What does that mean |
| 09:13 | Kototama | we have a clojure DSL to represent data |
| 09:14 | Kototama | not really a DSL, we just use vector, sexpr etc |
| 09:14 | mdeboard | to represent XML data? |
| 09:14 | Kototama | these data are loaded dynamically |
| 09:15 | Kototama | no no, we don't use XML anymore |
| 09:15 | Kototama | but this used to be a XML file |
| 09:15 | clgv | Kototama: and you can assure that the protocol is created before the load? |
| 09:16 | clgv | what if you skip the 'load - do you still get the exception when not AOTing? |
| 09:16 | Kototama | let me try |
| 09:25 | Kototama | hum nope |
| 09:26 | Kototama | still having the error in this case |
| 09:29 | beffbernard | Question about noir. Is there any way to output prettty printed html? Currently it's outputing everything on one line |
| 09:29 | mdeboard | beffbernard: https://github.com/weavejester/hiccup ? |
| 09:30 | beffbernard | mdeboard: Yes, I'm using hiccup to generate the html |
| 09:33 | mdeboard | beffbernard: I'm not familiar ith hiccup unfortunately :-\ amalloy_ and ibdknox would both be good people to ask |
| 09:38 | beffbernard | mdeboard: okie dokie |
| 09:40 | clgv | beffbernard: as a start you could just replace every ">" by ">\n" |
| 09:41 | Fossi | most browsers can prettyprint the html |
| 09:41 | Fossi | both in sourceview and in the inspector |
| 09:42 | Fossi | and actually newlines are only needed after script and link tags in IE6 and some obscure old safari versions |
| 09:42 | beffbernard | Fossi: That's what I've been doing thus far |
| 09:42 | Fossi | so stripping the newlines saves space :) |
| 09:43 | beffbernard | Fossi: Letting the browser pretty print for me |
| 09:45 | mdeboard | no newlines also kills readability & debugging |
| 09:45 | mdeboard | I like how clojure.data.xml emits nested tags |
| 10:41 | Bronsa | lol |
| 10:41 | TimMc | At work, I'm fighting with Java and Maven and JDBC. But I can get a sample Clojure + Leiningen project to talk to the DB in just a couple minutes. |
| 10:51 | xkb | Didn't emacs clojure mode have tab-completion? |
| 10:52 | cemerick | TimMc: lein 2 is pretty close to being a general-purpose replacement for ant and maven for Java-only builds, too. |
| 10:53 | nachtalp | xkb: M-/ ? |
| 10:53 | xkb | nachtalp: ah yes thanks |
| 10:53 | xkb | tab is only for repl |
| 11:01 | y3di | someone mentioned turning reg ex into a state machine on hn... does anyone know what that means? |
| 11:04 | nachtalp | y3di: maybe this is what you're looking for? http://en.wikipedia.org/wiki/Regular_expression#Implementations_and_running_times |
| 11:08 | y3di | thanks for the link nachtalp |
| 11:08 | nachtalp | y3di: sure |
| 11:14 | TimMc | cemerick: *drool* |
| 11:18 | jimduey | Here's a good link for regex and state machines: http://swtch.com/~rsc/regexp/regexp1.html |
| 11:20 | muhoo | clojure running on beaglebone, yay embedded programming in a sane language |
| 11:22 | RickInGA | jimduey: this is a cool article |
| 11:23 | jimduey | I thought so. He has a couple of follow ons as well. |
| 11:24 | RickInGA | Just the fact that grep and perl use different regex processes was a shock to me. My first impression of Perl was it was grep and sed and awk all mashed together |
| 11:30 | TimMc | haha |
| 12:21 | jaley | Does anyone here use the clj-ssh library? For some reason I get UnknownHostException despite the host I'm connecting to being known *and* turning off strict host checking. Any suggestions? |
| 12:22 | hugod | jaley: clj-ssh doesn't use the standard ~/.ssh/config or ~/.ssh/known-hosts |
| 12:23 | jaley | hugod: ok. but should disabling strict host checking not circumvent this anyway? |
| 12:24 | hugod | jaley: how are you disabling strict host checking? |
| 12:25 | jaley | hugod: passing :strict-host-key-checking :no to scp-from ... ah. that has to be done with the session function? |
| 12:27 | hugod | jaley: yes, the readme has some examples |
| 12:27 | jaley | hugod: ok cool, making some progress. thanks! :-) |
| 12:34 | jaley | hugod: this is very cool. it's almost less work than actually using scp :-) |
| 13:01 | ferd_ | I want my macro to expand into two different "top-evel" def's... Should I wrap the defs in a "(do ...)" ? |
| 13:02 | ferd_ | Does this make sense?: (defmacro gen2 [] '(do (def x 1) (def y 2))) |
| 13:02 | TimMc | ferd_: Yes, a 'do is appropriate. |
| 13:02 | TimMc | The compiler will treat a 'do at top level as two top-level statements. |
| 13:02 | ferd_ | Excellent. Thanks! |
| 13:03 | TimMc | (including nested top-level 'do statements!) |
| 13:14 | lpetit | https://twitter.com/#!/petitlaurent/status/175281929363525632 |
| 13:14 | dnolen | damn V8 is fast - Okasaki stuff would well in CLJS. |
| 13:15 | dnolen | work well |
| 13:15 | technomancy | does the latest metadata patch mean that "more core vars" is the accepted approach going forward in general for dynamicity knobs? |
| 13:16 | stuartsierra | there haven't been any proposals for anything better |
| 13:19 | technomancy | yeah, but usually what happens in those situations is nothing |
| 13:20 | stuartsierra | I think "more core vars" will remain the approach for now. |
| 13:21 | technomancy | works forme |
| 13:21 | stuartsierra | When the time comes for breaking chase, they could all be moved into a separate namespace if needed. |
| 13:21 | technomancy | should they be marked as alpha if that's an option for the future? |
| 13:21 | stuartsierra | s/chase/changes/ |
| 13:21 | stuartsierra | my guess would be yes |
| 13:22 | technomancy | hugod: did you catch that? |
| 13:33 | jaley | I need to run this function over GBs of data. Is there a way to make it fast without mutability? Even using a string builder actually made little difference for me. https://gist.github.com/1951985 |
| 13:33 | ibdknox | jaley, seqs are slow, use an array |
| 13:34 | jaley | ibdknox: a java array? as in, into-array or something? |
| 13:34 | ibdknox | yeah |
| 13:34 | Bronsa | what about a transient? |
| 13:35 | ibdknox | jaley, also is it a bug that you're taking the first of text? |
| 13:35 | ibdknox | that seems wrong |
| 13:36 | jaley | ibdknox: yeah sorry, copy and pasting failure |
| 13:36 | jaley | ibdknox: i'll do some fixing... |
| 13:37 | jaley | ibdknox: yeah, updated and tested. sorry about that |
| 13:39 | rlb | jaley: I believe java also has something like mmap (with limitations iirc) -- don't know if that could help. |
| 13:40 | rlb | ISTR it may have had a 2gb limit, and perhaps problems with reclaiming the resource (no close?) -- dunno. |
| 13:46 | dnolen | jaley: use StringBuilder, you need to be careful about type hints. |
| 13:47 | dnolen | jaley: if it's slow, you're hitting reflection - it should not be slow at all. |
| 13:47 | dnolen | jaley: (set! *warn-on-reflection* true) helps |
| 13:47 | jaley | dnolen: hmm, not getting any warnings |
| 13:49 | jaley | dnolen: I updated it using a string builder now. It's 5ms quicker over 1000 iterations than conjing to the vector |
| 13:49 | jaley | dnolen: https://gist.github.com/1951985 - is that how you meant? |
| 13:50 | hiredman | I'd suggest using an index into the string instead of a seq |
| 13:50 | hiredman | .charAt etc |
| 14:01 | jaley | hiredman: ok, my .chatAt implementation is the slowest yet. I must've done something wrong |
| 14:03 | hiredman | jaley: fuh, that is weird |
| 14:04 | jaley | hiredman: uploaded it to that gist, https://gist.github.com/1951985 - i don't get it either :s |
| 14:08 | jkkramer | jaley: (.length text) instead of (count text) |
| 14:08 | hiredman | jkkramer: wrong! |
| 14:08 | jkkramer | really? |
| 14:08 | hiredman | yes |
| 14:08 | jkkramer | howso? |
| 14:08 | hiredman | count is correct |
| 14:08 | hiredman | why do you think count is incorrect? |
| 14:09 | jkkramer | less indirection |
| 14:09 | jaley | it makes no difference to performance either way |
| 14:09 | hiredman | correct |
| 14:09 | hiredman | because a. it is outisde of the loop b. count is polymorphic and does the right thing for the type you give it |
| 14:10 | hiredman | jaley: I may look this over later, I am curious but no time right now |
| 14:10 | jaley | so this version takes 400ms on my laptop, for 1000 iterations of a pretty short string |
| 14:10 | jaley | hiredman: sure no problem, thanks for your help |
| 14:21 | jkkramer | jaley: type hint here: (= ^Character (.charAt text pos) \{) ... |
| 14:22 | ibdknox | better would be to only call that once |
| 14:22 | jaley | jkkramer: thanks, will give that a go now |
| 14:23 | tborg | I'm kind of noobish, but it seems to me like this might be a good place to work transients in, jaley? |
| 14:23 | jkkramer | quick repl test suggests a 100x speedup with the type hint |
| 14:23 | jkkramer | ibdknox: that too |
| 14:24 | ibdknox | he shouldn't need a transient |
| 14:24 | ibdknox | since he's using a stringbuilder |
| 14:24 | hiredman | depending on what version of clojure you are using there can be issues with the compiler inlining stuff depending on the type hints |
| 14:25 | hiredman | charAt actually returns a primitive char, if the type hint of Character is making it faster it is almost certainly an issue with the compilers intrinsics |
| 14:25 | hiredman | I would try (= (int (.charAt test pos)) (int \{)) |
| 14:26 | dnolen | jaley: what version of Clojure? |
| 14:26 | tborg | @ibdknox oh I see yeah nvm |
| 14:26 | dnolen | jaley: also I would set (set! *unchecked-match* true), you're paying a little for those incs |
| 14:27 | hiredman | dnolen: :( |
| 14:27 | dnolen | jaley: also the result of count is boxed so you paying for that too. |
| 14:27 | jkkramer | hiredman: yup, that speeds it up almost 1000x |
| 14:27 | hiredman | that changes how code is compiled for other libraries you might be using too |
| 14:28 | hiredman | jkkramer: the latest 1.4 betas should have better intrinsics for chars |
| 14:30 | jaley | dnolen: how do I unbox count? ^Integer? |
| 14:31 | dnolen | (long (count s)) |
| 14:31 | dnolen | jaley: I'm assuming you're on 1.3 |
| 14:32 | jaley | dnolen: yeah |
| 14:39 | jaley | dnolen, hiredman : ok, now it's taking about a microsecond. that's good :-) |
| 14:40 | jaley | time to go home, thanks for the help guys |
| 14:41 | robinkraft | Any Cascalog/Hadoop wizards out there? I'd like to defn at the repl on my master node and have that simple function be accessible in my cascalog query, that is, on the slave nodes. As it is I have to upload a new jar file each time I tweak something, which gets old fast ... |
| 14:41 | dnolen | jaley: np |
| 14:41 | robinkraft | Here's what I'm trying to run: defn get-max [my-vec] (apply max (flatten my-vec))) |
| 14:41 | hiredman | https://github.com/clojure/clojure/commit/405d24dd49d649c01b7881f1394fc90924c54ef0 if you use a clojure version after this you shouldn't need the int casts around the characters |
| 14:41 | robinkraft | and the query: (let [src (hfs-seqfile "s3n://formaresults/finaloutput/*")] (??<- [?count] (src ?s-res ?mod-h ?mod-v ?s ?l ?prob-series) (get-max ?prob-series :> ?max) (>= ?max 0.5) (c/count ?count))) |
| 14:43 | dnolen | jaley: you don't need to cast literals to int |
| 14:43 | robinkraft | I get this error: java.lang.IllegalStateException: Attempting to call unbound fn: #'forma.hadoop.jobs.forma/get-max |
| 14:43 | robinkraft | here's the gist: https://gist.github.com/1952544 |
| 14:44 | hiredman | dnolen: in order to get the compiler to do the intrinsic thing properly before the commit I linked you do |
| 14:44 | dnolen | jaley: oops, I'm wrong - the call to charAt. |
| 14:45 | dnolen | hiredman: yeah |
| 14:56 | jfields | I want to call some clojure that's in a .clj that's in a jar. Can I use RT.loadResourceScript("foo.clj") to get the clojure into the runtime? |
| 14:58 | ibdknox | if you just put the jar in your path you can do (ns my-ns (:require the-ns)) |
| 14:58 | osa1 | so it turns out I can use ::map, ::vector and String when dispatching on `class` in multi methods, but what should I do to catch numbers? I've tried ::number but didn't work |
| 14:59 | ibdknox | osa1: you're better off writing your on function that coerces things into the keyword representation that you want |
| 14:59 | ibdknox | own* |
| 15:00 | osa1 | ibdknox: but I'll be still calling (class ..) on that values. or is there another way? |
| 15:00 | osa1 | ibdknox: and why? I saw this approach on clojure docs |
| 15:00 | ibdknox | ,(doc number?) |
| 15:00 | clojurebot | "([x]); Returns true if x is a Number" |
| 15:01 | ibdknox | if you want to treat integer and double and long differently, sure |
| 15:01 | ibdknox | do that |
| 15:01 | hiredman | osa1: have you read the docs on hierarchies at all? |
| 15:01 | osa1 | hiredman: no |
| 15:01 | hiredman | feel free to do so |
| 15:01 | hiredman | ~multimethods |
| 15:01 | clojurebot | multimethods is what separates the boys from the men. |
| 15:01 | hiredman | ~multimethods |
| 15:01 | clojurebot | multimethods is what separates the boys from the men. |
| 15:01 | hiredman | ~multimethods |
| 15:01 | clojurebot | multimethods seperate the 20% from the 80% |
| 15:01 | ibdknox | lol |
| 15:01 | hiredman | clojurebot: stop that |
| 15:01 | clojurebot | Excuse me? |
| 15:02 | ibdknox | ~multimethods |
| 15:02 | clojurebot | multimethods seperate the 20% from the 80% |
| 15:02 | hiredman | clojurebot: multimethods |are| http://clojure.org/multimethods |
| 15:02 | clojurebot | c'est bon! |
| 15:02 | tscheibl | clojurebot: shut up! |
| 15:02 | tscheibl | :) |
| 15:03 | ibdknox | why does clojure.org now have a wikispaces toolbar? |
| 15:04 | tscheibl | indeed |
| 15:05 | llasram | Anyone here use aleph/gloss much? |
| 15:06 | tscheibl | llasram: I use aleph |
| 15:07 | llasram | tscheibl: Do you have any idea how to make gloss work with little-endian values? |
| 15:08 | tscheibl | llasram: I'm sorry, no |
| 15:08 | llasram | Ah, oh well. Thanks anyway :-) |
| 15:13 | jfields | ibdknox, sorry, I wasn't clear enough... |
| 15:13 | jfields | I want to call some clojure from Java (the .clj is in a jar). Can I use RT.loadResourceScript("foo.clj") to get the clojure into the runtime? |
| 15:15 | tscheibl | llasram: looking at that https://github.com/ztellman/gloss/commit/e4b4d4b78b73ec5a2ca2a9478d2ca8dfe57cbdc2 I conclude that there should already be little-endian support in gloss |
| 15:16 | tscheibl | llasram: ... although ... https://github.com/ztellman/gloss/wiki/TODO |
| 15:16 | amalloy | there is little-endian support in java.nio.ByteBuffer, which is the data format gloss uses |
| 15:18 | stuartsierra | jfields: yes |
| 15:19 | jfields | stuartsierra, strange, it's not working for me. I get "could not locate Clojure resource on the classpath" |
| 15:20 | stuartsierra | the JAR containing foo.clj must be on the Java classpath |
| 15:20 | stuartsierra | and you must specify the file name as a full path, relative to the root of the JAR |
| 15:21 | choffstein | technomancy: I upgraded to lein 1.7 and for some reason, my lein deploys with s3-wagon-private aren't authenticating from .lein/init.clj anymore. Any ideas? |
| 15:21 | jfields | stuartsierra, the jar is definitely on the classpath, that much I'm sure of. how can I find the full path relative to the root of the jar? |
| 15:21 | stuartsierra | jfields: in a shell, run `jar -t` on the jar file |
| 15:22 | jfields | stuartsierra, thanks |
| 15:23 | technomancy | choffstein: try running with DEBUG=y; you should get more visibility into repository settings |
| 15:24 | jfields | stuartsierra, works like a charm. thanks. |
| 15:24 | stuartsierra | jfields: 'welcome |
| 15:25 | choffstein | technomancy: Is that a shell variable? |
| 15:26 | technomancy | choffstein: ja |
| 15:26 | choffstein | technomancy: Okay. Ran it. Doesn't seem to be showing my repos... |
| 15:27 | technomancy | choffstein: shoot; I may have added that after the release |
| 15:27 | technomancy | do you have a leiningen checkout where you could try the 1.x branch? |
| 15:27 | choffstein | I'll give it a go. I'm sure I'm just being stupid. |
| 15:28 | choffstein | Oh god, I am an idiot. |
| 15:28 | choffstein | I was just doing `lein deploy` -- I forgot to add which repo to deploy to. |
| 15:29 | choffstein | Sorry for wasting your time. I'm a bit embarrassed about this one... |
| 15:29 | technomancy | heh; happens all the time |
| 15:30 | llasram | amalloy: (time-travelling) does using .order to set the ByteBuffer byte-order not work? |
| 15:31 | amalloy | beats me |
| 15:31 | llasram | amalloy: Ok, seems to. So ByteBuffer *does* support little-endian access, just not on a field-at-a-time basis |
| 15:34 | llasram | tscheibl: Looks like that makes gloss preserve the endianness of buffers it gets to start with. Hmm |
| 15:44 | replaca | technomancy: just FYI, the ring output problem I was seeing yesterday appears to have nothing to do with slime or leiningen |
| 16:02 | Luke | hey guys - i'm trying to get swank/slime set up for clojure but I'm having a hard time understanding what's going on with all these components. What I want to do is have a system-wide swank/slime install which I installed via Ubuntu apt-get. I want my emacs to start that at startup and then connect for all the lisp/clojure buffers. is that reasonable? |
| 16:04 | hiredman | Luke: no |
| 16:06 | Luke | hiredman: why's that? |
| 16:07 | hiredman | because there are many versions of clojure and the version of clojure used by project depends on the project |
| 16:07 | Luke | hiredman: so most people just use an instance of swank per project? |
| 16:08 | weavejester | Luke: There's usually one swank-clojure, installed as a Leiningen plugin |
| 16:09 | hiredman | people use leiningen |
| 16:09 | hiredman | it's in the google |
| 16:09 | weavejester | Luke: So if you have leiningen installed, you can run: lein plugin install swank-clojure 1.4.0 |
| 16:10 | weavejester | Luke: I usually use technomancy's emacs-starter-kit to setup emacs and install the clojure-mode emacs package |
| 16:11 | weavejester | Luke: And then you can run M-x clojure-jack-in from Emacs to start a SLIME session in the current project. |
| 16:17 | uvtc | Hi, #clojure. I'm trying to better understand what leiningen is for and what it does. For one thing, if I create a new project (`lein new foobar`), and then `cd foobar` and run `lein jar`, I see that (1) it downloads clojure-1.3.0.jar for me, but (2), it does *not* include that clojure-1.3.0.jar in the foobar-1.0.0-SNAPSHOT.jar it makes. Why doesn't it include the clojure.jar? |
| 16:18 | ivan | I think lein uberjar does that |
| 16:18 | brehaut | because thats just the projects jar; if you make an uberjar it includes all the dependancies |
| 16:19 | uvtc | Ah, ok. `lein help | grep uberjar`. |
| 16:21 | Luke | hiredman: I have leiningen |
| 16:22 | Luke | weavejester: cool thanks a lot |
| 16:22 | clojurebot | Pardon? |
| 16:26 | uvtc | So, if I want to send a friend a Clojure program for them to run, I send them a jar created by running `lein uberjar` in my project dir, correct? And then they should be able to run it by doing `java -jar foobar.jar`. Is that the case? |
| 16:27 | brehaut | assuming it has a main entry point |
| 16:28 | amalloy | anyone know why IPersistentMap.assocEx exists? i happened to see it in the source, and it looks like it's only used by some commented-out code relating to an old class named PersistentListMap. i'm just sorta curious from a historical perspective what it was good for |
| 16:28 | uvtc | Thanks, brehaut. |
| 16:33 | technomancy | replaca: yeah, thanks for the pull! |
| 16:33 | technomancy | I have a few more loose ends to tie up with lein-precate, but I should have a new version out soon |
| 16:39 | replaca | technomancy: great. Question: does lein 1.x always run under clojure 1.2 (as the doc says)? |
| 16:39 | replaca | technomancy: I'm worried that that code may trip over an old cl-format bug |
| 16:40 | replaca | technomancy: though it worked fine in my environment |
| 16:40 | technomancy | replaca: yeah, it's stuck on 1.2.1 |
| 16:40 | technomancy | what's the bug? |
| 16:41 | replaca | technomancy: hmm, the fix must be in 1.2.1 then though the JIRA page says 1.3. |
| 16:41 | replaca | where ~w wouldn't automatically create a pretty-writer when used outside pprint |
| 16:42 | replaca | CLJ-682 |
| 16:42 | TimMc | uvtc: If you don't need AOT compilation, I recommend the lein-otf plugin </shamelessplug> |
| 16:42 | technomancy | replaca: when I saw that crazy string passed to cl-format I was kinda glad I didn't attempt to tackle that on my own =) |
| 16:42 | TimMc | uvtc: `lein uberjar-otf` is faster than plain uberjar and allows on-the-fly compilation |
| 16:42 | brehaut | TimMc: open type format? |
| 16:43 | TimMc | On The Fly, as opposed to Ahead Of Time |
| 16:43 | brehaut | aha |
| 16:43 | replaca | technomancy: yeah, I found something I didn't implement from the old XP spec that would have made it all cleaner, so now I have another bug. :) |
| 16:43 | TimMc | brehaut: "JIT compilation" is ambiguous |
| 16:43 | brehaut | yes |
| 16:43 | TimMc | (but easier to pronounce...) |
| 16:45 | uvtc | TimMc: I'm still trying to understand in which cases any compilation happens when creating a jar using lein... |
| 16:45 | TimMc | uvtc: At least these times: 1) When :aot is specified, 2) when :main points to something with :gen-class |
| 16:46 | technomancy | actually :main on its own triggers it; no gen-class needed |
| 16:46 | technomancy | though :main ^{:skip-aot true} whatever.main works |
| 16:46 | TimMc | technomancy: Just with uberjar, or also jar? |
| 16:46 | technomancy | TimMc: for compile, which is invoked by both |
| 16:46 | uvtc | TimMc, when you write ":aot" and ":main", are you referring to keys in the project.clj's defproject fn? |
| 16:47 | TimMc | yep |
| 16:47 | TimMc | technomancy: :main is complected |
| 16:47 | technomancy | it's true |
| 16:51 | Luke | slime + clojure is awesome |
| 16:51 | TimMc | technomancy: I use :main to make the REPL end up in the most important namespace during dev. Should I just use that + :skip-aot to avoid AOT'd regular jars? |
| 16:51 | Luke | it seems to keep disconnecting though |
| 16:51 | technomancy | TimMc: :repl-init bro |
| 16:52 | TimMc | lein 1.x? |
| 16:52 | technomancy | maybe? |
| 16:52 | TimMc | heh |
| 16:52 | technomancy | that's more of a swank thing anyway though |
| 16:52 | technomancy | I mean, repl supports it in 1.x; I think swank should too |
| 16:53 | TimMc | Eh, by the tiem I start using Swank, we'll be on Lein 3. |
| 16:59 | uvtc | I'd like to distribute a small command line Clojure program. I created a new project (`lein new count-to`). My `count-to/src/count_to/core.clj` looks like this: http://paste.pocoo.org/show/559456/ . |
| 17:00 | uvtc | I suppose I should be able to test it out using `lein run` or `lein run 3`, but it's telling me "No :main namespace specified in project.clj.". What value of ":main" should I provide? |
| 17:02 | TimMc | uvtc: :main count-to.core |
| 17:02 | technomancy | uvtc: or lein run -m count-to.core |
| 17:03 | uvtc | (Odd that although I created the project using `lein new count-to` (with a hyphen), the lib dir contains "count_to" (with an underscore)). |
| 17:03 | technomancy | uvtc: one of many ways in which the JVM intrudes on our otherwise happy existence |
| 17:04 | technomancy | well, s/many// |
| 17:04 | TimMc | No, there are many. |
| 17:04 | uvtc | technomancy, Ah. So, maybe a good rule to follow is to not use hyphens in project names? |
| 17:04 | technomancy | uvtc: no, there's nothing wrong with that |
| 17:04 | technomancy | |
| 17:05 | TimMc | uvtc: Just a warning... JVM startup time can be a bear. Small CLI programs are honestly best written in Python, unless you know your users will be using a client VM. |
| 17:05 | technomancy | python? pshaw. |
| 17:05 | uvtc | TimMc, noted. |
| 17:05 | TimMc | technomancy: Bash? |
| 17:05 | technomancy | unless you mean clojure-py of course |
| 17:05 | technomancy | TimMc: ocaml! |
| 17:05 | emezeske | TimMc: INTERCAL |
| 17:06 | TimMc | technomancy: :-D |
| 17:06 | technomancy | on le metal |
| 17:06 | uvtc | But I'm looking to write some Clojure and chew gum, and I'm all outta' gum. |
| 17:06 | uvtc | wheee....! |
| 17:06 | TimMc | uvtc: Understood. |
| 17:06 | hiredman | ~python |
| 17:06 | clojurebot | python is "I think dropping filter() and map() is pretty uncontroversial…" — GvR |
| 17:06 | hiredman | ~python |
| 17:06 | clojurebot | python is ugly |
| 17:06 | TimMc | Meh, it gets small jobs done. |
| 17:07 | emezeske | Wait, did filter() and map() get dropped for Python 3? |
| 17:07 | emezeske | Well, I guess list comprehensions kind of do the same thing, but that's a little sad if so... |
| 17:07 | emezeske | Wait, this is #clojure |
| 17:07 | brehaut | emezeske: they are in the functional package |
| 17:08 | TimMc | emezeske: I think they dropped reduce, too. (If they ever had it.) |
| 17:08 | amalloy | emezeske: i think he was harassed into leaving them in, but moved reduce into some package you have to import |
| 17:08 | emezeske | Haha, thanks guys :) |
| 17:08 | uvtc | So, after adding ":main count-to.core", and trying `lein run 3`, I get quite a long stack trace, which starts with "Exception in thread "main" java.lang.NumberFormatException: null |
| 17:08 | uvtc | at java.lang.Integer.parseInt(Integer.java:443) |
| 17:08 | uvtc | at java.lang.Integer.parseInt(Integer.java:514)" |
| 17:08 | technomancy | "Complaining about whitespace in python just shows your ignorance; there are so many other more important things to complain about." |
| 17:08 | brehaut | clojure solves all my python problems; its unsurprinsing that #clojure can solve #python problems too |
| 17:08 | hiredman | I was reading over the blog posts from the clojure-py blog and there is a fundamental misunderstanding of vars in there |
| 17:08 | emezeske | brehaut: burrrrned! |
| 17:09 | hiredman | I haven't looked at the code to see if it carries over there |
| 17:09 | technomancy | I was kind of disappointed to learn that the point of clojure-py is performance =( |
| 17:09 | brehaut | wait what |
| 17:09 | hiredman | the blog posts talks about treating non-dynamic vars as constants |
| 17:09 | ivan | Python whitespace would be less bad if it did not break Python code pasted into the REPL |
| 17:09 | TimMc | ivan: What do you mean? I do that all the time. |
| 17:10 | hiredman | and so copying the values around in the global dictionary or whatever |
| 17:10 | amalloy | hiredman: maybe they've never used a repl before |
| 17:10 | hiredman | sounds like it |
| 17:10 | TimMc | I MEAN, WHEN I USED PYTHON. *cough* |
| 17:10 | clojurebot | Cool story bro. |
| 17:10 | hiredman | ~botsnack |
| 17:10 | clojurebot | thanks; that was delicious. (nom nom nom) |
| 17:10 | ivan | TimMc: it does not work here. maybe it's my settings |
| 17:10 | uvtc | Hm... just running `lein run` by itself without any number yields the same stack trace... |
| 17:10 | TimMc | uvtc: gist the code + stack trace (or... refheap it?) |
| 17:11 | TimMc | Raynes: Verb, please. |
| 17:11 | Raynes | TimMc: We call that pasting, sir. |
| 17:11 | uvtc | TimMc, "refheap"? |
| 17:11 | Raynes | https://refheap.com |
| 17:11 | callen | I'm a big fan of pasties. |
| 17:11 | Raynes | The best pastebin ever. |
| 17:11 | TimMc | callen: heh |
| 17:11 | ivan | TimMc: looks like it was because I was pasting tab-indented code into the Windows Python |
| 17:11 | TimMc | Raynes: Your pastebin needs more tassels. |
| 17:12 | ivan | and also into this host running Ubuntu 10.04 |
| 17:12 | callen | ^^ this guy knows what's up. |
| 17:12 | uvtc | TimMc, http://paste.pocoo.org/show/559461/ |
| 17:12 | callen | uvtc: use refheap :( |
| 17:13 | TimMc | callen: One of my housemates does lighting (and video production?) for a burlesque troupe. |
| 17:13 | uvtc | callen, Ah. Interesting. refheap uses Pygments, just like paste.pocoo (pocoo is where pygments was born). |
| 17:13 | Raynes | Here is a funfact about pocoo: if you paste something that causes the theme they use to have italics or unicode characters and the paste is 100 lines or more, the line height is inconsistent and the line numbers become useless, ending long before the paste does. |
| 17:14 | Raynes | They may have created pygments, but they sure don't know how to use it too well. ;) |
| 17:14 | TimMc | uvtc: count_to.core$eval11.invoke are you doing something naughty? |
| 17:15 | uvtc | TimMc, The only source code file in my brand new "count-to" project is that core.clj file, and it's contents are still what I pasted at http://paste.pocoo.org/show/559456/ . |
| 17:15 | TimMc | uvtc: OK, hadn't seen that paste. |
| 17:16 | TimMc | uvtc: OK, that needs to 1) have an ns declaration and 2) a -main fn |
| 17:16 | uvtc | TimMc, That error message has "count_to" in it, even though my :main is set to "count-to.core". |
| 17:16 | hiredman | and *command-line-args* might not worker properly with lein run |
| 17:16 | TimMc | uvtc: Right, the classname is munged just like the path. |
| 17:16 | hiredman | uvtc: you need a namespace at the top |
| 17:17 | uvtc | Doh, sorry. Yes, the `ns` declaration is there at the top. Sorry --- it didn't make it into the paste. Apologies. |
| 17:17 | uvtc | It's https://refheap.com/paste/905 |
| 17:18 | uvtc | (Hm... I think I prefer paste.pocoo's colorscheme ...) |
| 17:18 | uvtc | ...Trying a new project named "count_to" instead of "count-to"... |
| 17:19 | amalloy | uvtc: no, disaster, don't do that. the munging is not the issue at all |
| 17:19 | uvtc | amalloy, Ok. |
| 17:19 | amalloy | the issue is what TimMc said: you need to declare a main function |
| 17:19 | amalloy | instead, this println is being called at compile time, before main is executed, so there are no command-line args |
| 17:20 | amalloy | (then what hiredman said might also be an issue - i don't know if *command-line-args* works with lein run or not) |
| 17:20 | vijaykiran | hi all .. is there a like (fn a b) which will return b if a is empty or nil ? |
| 17:20 | amalloy | or |
| 17:20 | hiredman | amalloy: there will be *command-line-args* but it will be a big clojure form thing that lein passed to java |
| 17:21 | hiredman | vijaykiran: or? |
| 17:21 | uvtc | Ok. No prob. I don't need to try it out using `lein run`. But I *do* want to package it up and try running the jar. |
| 17:21 | vijaykiran | ,(or '() "123") |
| 17:21 | clojurebot | () |
| 17:21 | hiredman | uvtc: they work the same |
| 17:21 | vijaykiran | I need that function to return 123 |
| 17:21 | hiredman | uvtc: lein run is essentially trying to mimic the experience of running a jar without making a jar |
| 17:22 | vijaykiran | ,(or '(1 2 3) "456") |
| 17:22 | clojurebot | (1 2 3) |
| 17:22 | TimMc | vijaykiran: Perhaps you want a seq. |
| 17:22 | vijaykiran | this case is fine .. |
| 17:22 | TimMc | &(map #(or (seq %) 123) [() [1 2 3]]) |
| 17:22 | lazybot | ⇒ (123 (1 2 3)) |
| 17:23 | TimMc | Ew, that was kind of misleading output, but whatever. |
| 17:23 | vijaykiran | sweet thanks! |
| 17:23 | vijaykiran | seq should be fine |
| 17:23 | TimMc | vijaykiran: For a related problem, see if-let |
| 17:24 | uvtc | hiredman, Hm. Ok. Thank you. Also, running `lein uberjar` failed for me (with a java.lang.NumberFormatException ). |
| 17:24 | TimMc | uvtc: Right, because the error is at compile time. |
| 17:24 | vijaykiran | TimMc: yes, I was just trying that out, thanks a lot. |
| 17:25 | jkkramer | ,(or (not-empty [1 2 3]) :foo) ;to maintain concrete type |
| 17:25 | clojurebot | [1 2 3] |
| 17:25 | hiredman | "compile time" is a misnomer, the code is executed at load time |
| 17:25 | uvtc | So, for command line Clojure programs that take args, perhaps it's best to run them using `java -cp path/to/clojure.jar clojure.main count-to.clj 5`. |
| 17:26 | hiredman | if you AOT compiled it, the code would execute everytime you loaded the compiled code, not just when you compiled |
| 17:26 | hiredman | uvtc: as with everything it is best to read documentation and know what you are doing |
| 17:27 | ndr76 | anybody knows how to run all Clojure *own* tests ? |
| 17:29 | vijaykiran | jkkramer: neat, not-empty seems more readable |
| 17:30 | amalloy | ndr76: ant test |
| 17:30 | shaolynn | Hey guys, I'm having an issue with aleph. How do I prevent http-requests from being "chunked"? |
| 17:30 | shaolynn | Here's my code: |
| 17:30 | shaolynn | https://gist.github.com/1953683 |
| 17:31 | shaolynn | I need the complete result to come back, otherwise I get parsing errors. |
| 17:31 | uvtc | hiredman, yes, I prefer reading the documentation, however, I wasn't able to find anything regarding creating an easily-distributable command line program. |
| 17:32 | uvtc | hiredman, If you could point me to such documentation, I'd appreciate it. |
| 17:32 | uvtc | hiredman, clojure.org/repl_and_main just says to use the "java -cp ..." command, but I'd assumed that it's customary to create and distribute programs using lein. |
| 17:32 | hiredman | uvtc: http://clojure.org/compilation |
| 17:33 | uvtc | hiredman, Will read. Thanks. |
| 17:37 | amalloy | btw TimMc, vijaykiran: seq there looks a little unpleasant. i'd use not-empty instead, to preserve the thing's type, if you really want empty collections to behave like nil |
| 17:39 | TimMc | I never knew about not-empty... |
| 17:39 | TimMc | &(doc not-empty) |
| 17:39 | lazybot | ⇒ "([coll]); If coll is empty, returns nil, else coll" |
| 17:51 | TimMc | &(map (juxt not-empty (comp not empty) (comp not empty?)) [nil [] [1 2 3]]) |
| 17:51 | lazybot | ⇒ ([nil true false] [nil false false] [[1 2 3] false true]) |
| 17:52 | TimMc | That would be a good one for the seqs-and-colls page. |
| 17:59 | arnihermann | I'm having problems reading a file in iso88591 encoding. I think it's java related, not clojure related. I do not have control over the code which reads the file, I give it an input stream or filename (string) and it reads the file as utf8. I cannot for the life of me fix the contents of the file afterwards, I always have '�' or '?' instead of the nonascii-characters (like þæö). |
| 18:00 | arnihermann | If the contents are read as utf8, is there no way to get back to the original contents with iso88591? |
| 18:00 | hiredman | arnihermann: how is the code reading it? |
| 18:00 | arnihermann | it's a third party lib I do not even have source of |
| 18:00 | arnihermann | e.g. I give it an inputstream to the file and it reads it |
| 18:01 | hiredman | can you give it a reader instead? |
| 18:01 | TimMc | arnihermann: Can you give it a Reader instead of an InputStream? |
| 18:01 | arnihermann | no |
| 18:01 | hiredman | inputstreams don't have an encoding |
| 18:01 | Raynes | My tip would be to tell that third party lib's developer to fix his broken software. |
| 18:01 | hiredman | they are raw bytes |
| 18:01 | arnihermann | I think he might be converting them behind the scenes |
| 18:02 | arnihermann | right |
| 18:02 | Raynes | It'd be hilarious if I were the developer of said software. |
| 18:02 | arnihermann | Raynes: you're not :) |
| 18:02 | Raynes | Oh good. |
| 18:03 | arnihermann | I'll try for the 3rd time to explain the situation to the lib developer :) |
| 18:03 | arnihermann | thanks |
| 18:04 | llasram | arnihermann: If you can't sort it out the right way, Apache Commons has a ReaderInputStream, which reads from a Reader, then encodes in the charset of your choice on read |
| 18:04 | clj_newb | Hi, with aleph it is possible to add body to the http request? |
| 18:04 | arnihermann | llasram: ah thanks |
| 18:06 | clj_newb | is it better aleph, or clj-http + agents to keep a connection over http to consume events? |
| 18:06 | clj_newb | aleph does not seems very active, is? |
| 18:06 | dnolen | clj_newb: it's pretty active |
| 18:06 | clj_newb | ah |
| 18:06 | llasram | clj_newb: Lots of activity in the clj-1.3 branch |
| 18:07 | Raynes | Not sure if it's helpful, but https://github.com/neotyk/http.async.client is a maintained async http client. |
| 18:07 | clj_newb | does not clj-http support async connections? |
| 18:07 | Raynes | dakrone: ^ |
| 18:07 | Raynes | Does it? |
| 18:09 | dakrone | no, it's not async, use http.async.client if you need async |
| 18:11 | clj_newb | thank you |
| 18:12 | clj_newb | I'm evaluating aleph also, but last commit is (in the public repo) from months ago |
| 18:12 | clj_newb | I'm a bit afraid it becomes discontinued or something, thou I like its approach (lamina) of channels |
| 18:13 | llasram | clj_newb: Check the clj-1.3 branch on the github repo. That's where all the activity is |
| 18:14 | clj_newb | great, thanks |
| 18:15 | clj_newb | sorry, I closed the terminal |
| 18:15 | clj_newb | I will check it out |
| 18:17 | brehaut | huh. the python library webassets already supports google closure; probably wouldnt be too much work support clojurescript too |
| 18:38 | rogererens | Maybe someone could put that https://refheap.com/paste link in the topic of this group? |
| 18:45 | Raynes | Theoretically, yes. But I doubt anyone will. |
| 18:51 | chris-m-r | hi, is there an easy way to view to documentation/methods for say a jpanel from emacs? |
| 18:52 | technomancy | chris-m-r: sure; use C-c S-i |
| 18:56 | chris-m-r | technomancy: thanks |
| 18:57 | tylergillies | How would i go about embedding a language int clojure, like lua |
| 18:57 | tylergillies | into* |
| 18:57 | technomancy | sure |
| 18:58 | emezeske | tylergillies: That seems like a curious thing to do ^_^ |
| 18:58 | mdeboard | I'm rewriting lua in pure python |
| 18:58 | Raynes | s/curious/nutsy/ |
| 19:02 | tylergillies | emezeske: why? im im making an app that i want to program in clojure, but want it to be scriptable and not force the scipters to learn clojure |
| 19:02 | tylergillies | if i'm* |
| 19:03 | emezeske | tylergillies: Well, I'd reckon that Clojure and Lua are at a pretty similar level of abstraction |
| 19:03 | emezeske | tylergillies: Usually, a more-abstract language is embedded in a less-abstract language |
| 19:03 | emezeske | tylergillies: The host is fast, the embedded is expressive |
| 19:04 | tylergillies | yes, but far more people who write casual scripts for applications know lua than clojure or any lisp for that matter |
| 19:04 | tylergillies | JVM isn't fast? |
| 19:05 | emezeske | Sure, but clojure doesn't sacrifice expressiveness for speed (IMHO) |
| 19:06 | tylergillies | so ther are no clojure apps that have a scripting language that isn't clojure? |
| 19:07 | tylergillies | i would say thats a function of the age of clojure not some intrinsic quality |
| 19:07 | amalloy | you would be investing a tremendous amount of time into embedding here. you'd be like...rewriting all of lua, in clojure |
| 19:07 | emezeske | Could be other apps like that, not written by me though :) |
| 19:07 | tylergillies | is java the same way? |
| 19:07 | amalloy | even if we take for granted that that's a good thing to do, the cost surely exceeds the value |
| 19:08 | technomancy | amalloy: there are a couple JVM-hosted lua implementations IIRC |
| 19:08 | technomancy | not that I think it's a good idea |
| 19:08 | amalloy | even figuring out how to integrate with them would probably not be easy |
| 19:09 | tylergillies | so if i want a scripting language in my app im better off writing it in c++? |
| 19:10 | tylergillies | the app that is |
| 19:11 | cafesofie | tylergillies: why not just use a language with better JVM support? |
| 19:11 | cafesofie | ruby and python come to mind |
| 19:12 | emezeske | tylergillies: I see no reason why you couldn't embed Lua in clojure. I just think it's a very silly thing to do. |
| 19:12 | emezeske | It's like embedding a Ruby interpreter in your Python app, because people like Ruby |
| 19:13 | Raynes | lazybot has a Ruby interpreter. :D |
| 19:13 | tylergillies | ah, so i guess the purpose of putting lua in a c++ app is that the c++ app can't run c++ from within itself |
| 19:13 | mdeboard | I'm jackie chan |
| 19:13 | brehaut | Raynes: all the cool bots have a node.js interpreter |
| 19:13 | tylergillies | but clojure can run clojure from within itself |
| 19:14 | mdeboard | wha-- |
| 19:14 | emezeske | Yeah, C++ would be a bad scripting language anyway |
| 19:14 | technomancy | offering C++ as an extension language would be a great thing to do if you hate your users and want them to suffer |
| 19:14 | tylergillies | lol |
| 19:14 | emezeske | hahaha |
| 19:14 | tylergillies | im writing an irc client called masochism that scripted with c++ |
| 19:14 | tylergillies | ;) |
| 19:14 | emezeske | technomancy: You might enjoy my 2011 april fool's joke then: http://blog.mezeske.com/?p=377 |
| 19:15 | qbg | Scripting in C++ -> PROGRAM IS FINE |
| 19:15 | technomancy | emezeske: I see your april fools and raise you my 2008 april fools: http://technomancy.us/107 |
| 19:15 | tylergillies | emezeske: thats awesome and horrible at the same time |
| 19:16 | technomancy | emezeske: that's pretty hilarious though |
| 19:16 | emezeske | technomancy: LOL @ "What about type safety?" "Always wear a helmet" |
| 19:17 | technomancy | emezeske: looks like about a 50/50 ratio of getting the joke in the comments on yours; nice |
| 19:17 | rplevy | dsantiago: hi, it sounds like from what you're saying in https://github.com/davidsantiago/clojure-hbase/pull/5 that there is some way to direct convert a string-string map to an HBaseConfiguration object? |
| 19:17 | emezeske | Oh, man, I didn't think anyone would beleive it, I was so shocked |
| 19:17 | qbg | C++ programmers can't take a joke; that is why they are programming C++ |
| 19:18 | Raynes | rplevy: I have a mission for you, should you choose to accept it. |
| 19:18 | dsantiago | rplevy: No, I'm saying that that object appears to exist just to be a string-string map, so if that is the case (I'm really not sure, you seem to know this API better than me), the configuration should just be a string/string map, and we convert it to the thing they want at the last second, in set-config. |
| 19:18 | emezeske | qbg: Hey! I can take a joke! Maybe that's because I've been off C++ for a little while though |
| 19:18 | rplevy | dsantiago: I doubt I know it better than you haha |
| 19:18 | rplevy | also: ah I see |
| 19:19 | dsantiago | rplevy: Well, you knew of its existence, so that already is suggestive right there. When I first wrote it, I asked in #hbase and they said XML file was the only way to do it. |
| 19:19 | rplevy | Raynes: yes? |
| 19:19 | qbg | emezeske: These quips write themselves... |
| 19:19 | Raynes | rplevy: Since you know more about Jython and stuff than I do, go take this issue: https://github.com/Raynes/refheap/issues/2 |
| 19:20 | emezeske | :) |
| 19:20 | rplevy | Raynes: sounds fun, I will look into it |
| 19:20 | Raynes | rplevy: It is extremely low priority, but I figured if you ever got bored… ;) |
| 19:20 | rplevy | Raynes: cool |
| 19:21 | dsantiago | rplevy: Typically what I do with these sorts of things is allow strings, keywords, and symbols by calling clojure.core/name on them before using them. |
| 19:23 | rplevy | dsantiago: sounds good like a good approach. btw, this month is my first foray into anything HBase related, so you definitely know it better. I'm jumping in at a time when there is slightly better documentation available. :) |
| 19:49 | rplevy | dsantiago: https://github.com/rplevy-draker/clojure-hbase/commit/9c23bf00dab743551db254b3ba4bb0ad6f9267bd |
| 19:49 | rplevy | clojure IRC log broke this afternoon around 2:30, or did I just never notice that it doesn't update live? |
| 19:50 | zztw | I'm poking around in Storm ( https://github.com/nathanmarz/storm ) in eclipse and when I try to view source for a clojure class like Seqable it tells me the attached source is wrong. Indeed, inspecting the jar ( jar tvf $HOME/.m2/repository/org/clojure/clojure/1.2.0/clojure-1.2.0-sources.jar ) exposes only .clj files, no java. how might I get maven2 to download the java source? |
| 19:50 | dabd | is there a xml-rpc client in clojure-contrib? |
| 19:51 | brehaut | dabd http://github.com/brehaut/necessary-evil/ |
| 19:51 | brehaut | id be horrified if xml-rpc made it into contrib; that might encourage people to build things with it |
| 19:51 | RickInGA | good name for it |
| 19:53 | dabd | brehaut: I read some bad things about it. I have to use a xml-rpc server so I need a client. What's a good alternative? |
| 19:53 | brehaut | to xml-rpc? |
| 19:54 | brehaut | dabd: or do you mean you have read bad things about necessary-evil? |
| 19:54 | dabd | brehaut: I read bad things about xml-rpc |
| 19:55 | brehaut | yeah for good reason |
| 19:55 | dabd | but what is a good alternative? |
| 19:55 | brehaut | json of rest? |
| 19:55 | dabd | json-rpc? |
| 19:55 | brehaut | s/of/over/ |
| 19:55 | brehaut | dabd: ideally not RPC over the web. |
| 19:56 | dabd | haha I see you are the author of necessary-evil |
| 19:56 | brehaut | plain REST services are much better |
| 19:56 | brehaut | yes |
| 19:56 | dabd | Actually I will have the server running locally |
| 19:56 | dabd | but the guy that wrote it chose xml-rpc so i can't do anything about it |
| 19:56 | brehaut | thats why necessary-evil exists |
| 19:57 | brehaut | and why its named what it is named ;) |
| 19:57 | dabd | ok I will get it from clojars |
| 19:57 | dabd | thanks |
| 19:57 | rplevy | brehaut: that's a great name |
| 19:57 | dabd | or should i get it from git instead? |
| 19:57 | brehaut | dadb: clojars |
| 19:57 | dabd | ok |
| 19:58 | brehaut | sorry about the typo |
| 19:58 | rplevy | much better than clj-xmlrpcjure |
| 19:58 | brehaut | rplevy: lol |
| 19:58 | brehaut | that has a certain charm :P |
| 19:58 | rplevy | :) |
| 19:59 | aperiodic | if i want to intern something that conflicts with an existing mapping in a namespace, should i just unset it with ns-unmap beforehand? |
| 20:00 | RickInGA | do you need to use both sides of the conflict? I think you can do :exclude with use |
| 20:01 | aperiodic | RickInGA: the conflicting mapping is in clojure.core |
| 20:01 | RickInGA | so (use 'clojure.set :except difference) ; don't remember if it is exclude or exept |
| 20:03 | RickInGA | ok |
| 20:03 | amalloy | aperiodic: (:refer-clojure :exclude [...]) |
| 20:03 | amalloy | but if you do that, everyone who uses your namespace will need to decide which of those things they want to be able to refer to easily. it's not very friendly most of the time |
| 20:04 | hiredman | amalloy: yet another reason why :require :as is superior |
| 20:05 | amalloy | indeed |
| 20:06 | amalloy | i prefer :use/:only personally most of the time, because then when you look at the code it's not all cluttered up with annotations about where each function comes from. but i realize it's a tradeoff that makes other things less pleasant |
| 20:07 | rplevy | I like this idea http://dev.clojure.org/jira/browse/CLJ-879 |
| 20:07 | rplevy | and get rid of :use |
| 20:07 | aperiodic | amalloy: it's a very simple ns with only get, set, and delete. I'd rather have succintness when using it via require and not really support use, but perhaps i'm too attached to being able to write meta/set rather than meta/set-metadata |
| 20:08 | amalloy | aperiodic: so use that refer-clojure. if you prefer to write meta/set anyway, then there's no downside at all |
| 20:09 | rplevy | oh hey that patch was applied recently, I didn't notice |
| 20:10 | dabd | how do I find which clojure-contrib runs well with clojure 1.3.0? What are the required leiningen keys [org.clojure/clojure "1.3.0"] [org.clojure/clojure-contrib "1.3.0"]? |
| 20:10 | brehaut | ~contrib |
| 20:10 | clojurebot | Monolithic clojure.contrib has been split up in favor of smaller, actually-maintained libs. Transition notes here: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go |
| 20:10 | brehaut | (inc seancorfield) |
| 20:10 | lazybot | ⇒ 3 |
| 20:11 | rplevy | that's ideal, I think it will be most idiomatic to replace all :use clauses with :refer of vars in require clauses |
| 20:11 | brehaut | dabd: short answer: there is no 1.3 contrib |
| 20:11 | brehaut | in the same sense as there was in 1.2.x |
| 20:13 | aperiodic | yeah, I've never been a big fan of use, though that's mainly because it makes it really easy to hide where the variables are actually coming from |
| 20:13 | aperiodic | i kind of like cljs's restriction on it |
| 20:13 | dabd | brehaut so I should use clojure-contrib 1.2 |
| 20:13 | dabd | with clojure 1.3 |
| 20:14 | brehaut | dabd: no, you should usethe individual libs that have been split out of it; see the above link clojurebot spat out |
| 20:19 | aperiodic | hmm, why does :refer-clojure only work as a keyword? |
| 20:20 | aperiodic | every other ns option i've used works as long as the name is the same |
| 20:21 | dabd | brehaut: ok thanks |
| 20:30 | RickInGA | for doing exponents in clojure, there is Math/pow and clojure.math.numberic-tower/expt is one preferred over the other? |
| 20:31 | qbg | RickInGA: For what types of numbers? |
| 20:31 | RickInGA | ints |
| 20:31 | ibdknox | math/pow |
| 20:31 | qbg | Or use BigInteger to deal with overflow |
| 20:32 | RickInGA | ok, thanks |
| 20:32 | brehaut | i want math/pow! |
| 20:32 | brehaut | complete with kirby dots |
| 20:33 | amalloy | aperiodic: if you try to call it as a function, you've already referred clojure.core. what's the point? |
| 20:33 | TimMc | tylergillies: Late to the conversation, but I'll point out that DevilsPie uses a Scheme or something as its scripting language. It was easy to pattern off the examples. |
| 20:34 | TimMc | tylergillies: The real question is... how advanced will the scripts be? (Will your users *have* to know about the scripting language's pitfalls and idioms?) |
| 20:34 | technomancy | it's not scheme |
| 20:34 | RickInGA | ibdknox = Chris Granger? |
| 20:34 | ibdknox | he does :) |
| 20:34 | technomancy | it's a stupid crippled wannabe-lisp |
| 20:34 | aperiodic | amalloy: but this is in the ns macro, so it shouldn't be getting called |
| 20:35 | RickInGA | cool, I'm looking forward to web programming class! |
| 20:35 | ibdknox | RickInGA: yeah, I think we're going to have some fun :) |
| 20:35 | ibdknox | I was surprised there was such interest in data-viz |
| 20:35 | ibdknox | that'll definitely be interesting |
| 20:36 | TimMc | aperiodic: Right, it modifies some ns defaults, so it *has* to be in the ns block. |
| 20:37 | TimMc | Everything else (import, use, require) has an ns equivalent for convenience (and appropriateness or something). |
| 20:39 | aperiodic | TimMc: my confusion is that import, use, require and friends can be used by supplying a symbol, keyword, or string in the ns macro |
| 20:40 | rplevy | I also can't think of any case where it would make sense to use the present refer given the :refer key of require, it's more repetitious in any usage. |
| 20:41 | aperiodic | TimMc: however, (ns (refer-clojure :exclude [get set]])) doesn't work for me, while (ns (:refer-clojure :exclude [get set])) does |
| 20:42 | TimMc | aperiodic: (ns (import ...)) is not valid, it should be a keyword. |
| 20:44 | aperiodic | TimMc: ok, I didn't realize that was unsupported |
| 20:46 | ferd_ | I have a macro dilema: I don't want to use ` because it fully qualifies symbols and that screws my macro... But, I need ~@ to splice a list :-\ |
| 20:46 | technomancy | can't use appli concat? |
| 20:46 | technomancy | apply |
| 20:47 | qbg | Can't use ~'foo where needed? |
| 20:48 | TimMc | aperiodic: Yeah, it'll really screw with beginners. (ns (require foo.core)) will complain that foo.core isn't defined. >_< |
| 20:48 | ferd_ | qbg: would that prevent the namespace qualification? let me try that |
| 20:48 | TimMc | aperiodic: Wait, never mind, that's an incorrect statement. |
| 20:48 | qbg | ,`~'+ |
| 20:48 | clojurebot | + |
| 20:48 | ferd_ | technomancy: using concat would work... but would be a pain |
| 20:49 | qbg | That almost looked like Perl... |
| 20:49 | Iceland_jack | haha |
| 20:49 | rplevy | ferd_: yes this is how you can do anaphoric stuff where you want symbol capture to |
| 20:50 | rplevy | too* |
| 20:51 | TimMc | qbg: This look enough like Perl? https://github.com/baznex/imports/blob/7754d3a565a4db47b68cdf1e86bb6edf6bb8cbbd/src/org/baznex/imports.clj#L169 |
| 20:51 | aperiodic | TimMc: yeah, the whole requiring beginners to understand macros to realize why (require foo.bar) doesn't work at the REPL is unfortunate |
| 20:52 | ibdknox | TimMc: that made me cry a little. |
| 20:52 | qbg | TimMc: I see letters |
| 20:52 | TimMc | ibdknox: Shhh, don't cry. I reverted most of that code. |
| 20:52 | ibdknox | lol |
| 20:52 | ferd_ | thanks! that worked... |
| 20:52 | rplevy | @@#'other-namespace/some-atom looks kind of perlish to me |
| 20:52 | TimMc | It hurt to write, too. |
| 20:53 | ferd_ | Now for another macro issue: I want to generate a metadata... but actually, it's for Java annotations on a deftype |
| 20:53 | TimMc | ibdknox: When you realize what it is doing you will probably cry more. |
| 20:54 | ferd_ | I could find a way to pass the ^{ } syntax from the macro to the results... So I tried generating (with-meta ... but deftype doesn't like with-meta :-( |
| 20:54 | ferd_ | *couldn't |
| 20:55 | TimMc | ferd_: You need to do with-meta in an unquote |
| 20:55 | qbg | Did you do something of the effect `(defn ~(with-meta 'foo {:private true}) ...) |
| 20:57 | ferd_ | I tried `(deftype (with-meta ~foo ~annotations) ... |
| 20:59 | ferd_ | but it complains with "PersistentList cannot be cast to clojure.lang.Symbol" |
| 20:59 | qbg | You need to eval with-meta with unquote |
| 20:59 | qbg | Since you want a symbol there, not a list |
| 21:00 | TimMc | ferd_: Use (binding [*print-meta* true] (macroexpand-1 `...)) to debug your output. |
| 21:00 | TimMc | err |
| 21:01 | TimMc | ferd_: Use (binding [*print-meta* true] (pr-str (macroexpand-1 `(my-macro ...)))) to debug your output. |
| 21:04 | ferd_ | hmmm if I let the "with-meta" to run at macro-exansion time, I get the symbol but without the metadata |
| 21:04 | ferd_ | if a let the (with-meta ...) on the output, then deftype complains |
| 21:05 | TimMc | ferd_: How do you know it doesn't have metadata? |
| 21:05 | ferd_ | I mean the expanded macro does have it... I'll try to put together a smal example to share here |
| 21:07 | ferd_ | (defmacro M [t] (with-meta t {:a "a"})) |
| 21:07 | ferd_ | (macroexpand-1 '(M test)) -> test |
| 21:08 | ferd_ | with the deftype: (defmacro M [t] `(deftype ~(with-meta t {:a "a"}))) |
| 21:09 | ferd_ | same thing: (macroexpand-1 '(M test)) -> (clojure.core/deftype test) |
| 21:10 | ferd_ | now, leaving with-meta quoted chokes deftype :'( |
| 21:10 | TimMc | ferd_: Did you see the binding form I gave you above? |
| 21:10 | qbg | Both of those have the metadata... |
| 21:10 | qbg | => (meta (second (macroexpand-1 '(M foo)))) |
| 21:10 | qbg | {:a "a"} |
| 21:12 | ferd_ | (binding [*print-meta* true] (macroexpand-1 '(M test))) --> (clojure.core/deftype test) |
| 21:12 | qbg | You need the pr-str there |
| 21:12 | qbg | Or do (set! *print-meta* true) and the REPL |
| 21:13 | qbg | So it prints it with the meta data |
| 21:13 | qbg | => (set! *print-meta* true) |
| 21:13 | qbg | true |
| 21:13 | qbg | => (macroexpand-1 '(M foo)) |
| 21:13 | qbg | (clojure.core/deftype ^{:a "a"} foo) |
| 21:13 | ferd_ | genius... (clojure.core/deftype ^{:a "a"} test) |
| 21:14 | ferd_ | thanks a lot! I would've never figured that out |
| 21:15 | ferd_ | now, why doesn't it print it by default? why is there even an option for that ? |
| 21:17 | qbg | Because it isn't important most of the time |
| 21:17 | qbg | But sometimes it is |
| 21:26 | TimMc | This is probably in line with how it doesn't affect equality semantics. |
| 21:30 | ferd_ | after a few minutes, I now realize it does indeed get in the way... there is tons of metadata everywhere :-) |
| 21:31 | napping | Does installing CCW take a while? It's been sitting at "Calculating requirements and dependencies" for a minute or two, without the progress bar moving |
| 21:32 | qbg | napping: Shouldn't |
| 21:32 | TimMc | napping: Any hidden dialog boxes? |
| 21:33 | napping | It's finished now |
| 21:33 | qbg | I really like the CCW beta |
| 22:07 | choffstein | technomancy: You around? Is it alright if I PM you with a clojure / heroku related question? |
| 22:09 | Blackavar | He's sitting on a couch about 6 feet away, but may be preoccupied. |
| 22:12 | choffstein | Which is totally okay :) |
| 22:12 | choffstein | I can just submit a heroku ticket, I s'pose |
| 22:14 | ferd_ | ,(deftype ^{java.lang.SuppressWarnings "unchecked"} Annotated [x]) |
| 22:14 | clojurebot | #<Exception java.lang.Exception: SANBOX DENIED> |
| 22:14 | Blackavar | Is joint Seajure/Bay Area Clojure Group meeting. |
| 22:16 | ferd_ | after that deftype: (-> (Annotated. nil) class .getAnnotations alength) ==> 0 |
| 22:16 | ferd_ | anybody knows what I'm doing wrong? |
| 22:18 | qbg | That annotation is not retained at runtime |
| 22:21 | TimMc | aha |
| 22:21 | ferd_ | duh |
| 22:21 | qbg | I assume you are interested in annotations for interop, correct? |
| 22:22 | qbg | Here's one that is retained at runtime: http://docs.oracle.com/javaee/6/api/javax/inject/Inject.html |
| 22:23 | qbg | Though that one isn't for types |
| 22:24 | ferd_ | my issue: using deftype with annotations worked for me. Now, I wrong a macro that spits the deftype with the annotations... now the code that reads it fails to find it |
| 22:24 | ferd_ | the SuppressWarnings example above was just an attempt to isolate my problem |
| 22:36 | ferd_ | qbg: thanks... I couldn't either. Anyway, I think I can repro my problem in a small example |
| 22:39 | TimMc | qbg: Pretty much any SOAP annotation. |
| 22:40 | TimMc | JUnit annotations. |
| 22:40 | TimMc | Spring. |
| 22:40 | ferd_ | he's my issue: |
| 22:40 | ferd_ | (deftype ^{Goal "goal"} A [x]) |
| 22:40 | ferd_ | (-> (A. nil) class .getAnnotations alength) ;; => 1 |
| 22:41 | ferd_ | ;; OK so far |
| 22:41 | ferd_ | (defmacro deftypeM [T] `(deftype ~(with-meta T {Goal "goal"}) [x#])) |
| 22:41 | ferd_ | (deftypeM M) |
| 22:41 | ferd_ | (-> (M. nil) class .getAnnotations alength);; => 0 (!?) |
| 22:42 | TimMc | &(-> ^{String "foo"} 'hi meta keys first class) |
| 22:42 | lazybot | ⇒ nil |
| 22:43 | TimMc | ugh, I see my mistake |
| 22:44 | accel | is there a way to get visualvm to output clojure file line numbers / function names in it's profiler/sampler report? |
| 22:44 | TimMc | &(-> (with-meta [] {String "foo"}) meta keys first class) |
| 22:44 | lazybot | ⇒ java.lang.Class |
| 22:44 | accel | I keep on getting a bunch of java.* and clojure.* classes, but not my own actual clojure sources |
| 22:48 | TimMc | ferd_: Where is documentation on annotations and deftype? |
| 22:49 | ferd_ | TimMc: you tell me ;-). Here's what I have: http://groups.google.com/group/clojure/browse_thread/thread/d2128e1505c0c117 |
| 22:50 | TimMc | Oooh, @Deprecated |
| 22:51 | TimMc | right now I'm thinking something about symbols vs. classes, give me a moment |
| 22:55 | TimMc | ferd_: Yeah, I got nothing. |
| 22:57 | ferd_ | I run out of ideas. Macroexpand-1 shows exactly what I need... but somehow the annotation is not retained |
| 22:57 | TimMc | ferd_: Try symbols. {Goal "foo"} has a key that is the *class* Goal, and deftype is I think looking for the *symbol* 'Goal |
| 22:57 | TimMc | So, (with-meta T {'Goal "goal"}) |
| 22:58 | TimMc | They print the same. :-/ |
| 22:58 | TimMc | (Verified in own REPL.) |
| 22:59 | ferd_ | holy sh*t, it worked! |
| 22:59 | TimMc | haha, yay! |
| 22:59 | TimMc | That's a nasty thing to debug. I only figured it out because I was building some type hinting macros a couple weeks ago. |
| 22:59 | qbg | Metadata can be weird |
| 23:00 | TimMc | (most of which I had to scrap) |
| 23:00 | ferd_ | TimMc: qbg: many many thanks again |
| 23:01 | qbg | I know when playing with defn, metadata has a tendency to be double evaluated |
| 23:01 | ferd_ | I guess I called for way too many difficulties for my first non-trivial macro |
| 23:01 | TimMc | qbg: Right, the big lesson is that your metadata has to be a map of syntax, not values. :-P |
| 23:05 | qbg | My issue was using lists in :arglists |
| 23:06 | TimMc | huh |
| 23:06 | TimMc | Oh, should be vectors, right. |
| 23:09 | ibdknox | anyone know of a decent text diffing lib for Clojure or Java? |
| 23:14 | brehaut | ibdknox: circulitous answer: bzr's diff3 via jython ;) |
| 23:16 | ibdknox | :p |
| 23:17 | amalloy | ibdknox: what about whatever's used by cake test and lein difftest? |
| 23:17 | amalloy | i haven't looked into it, but i know they do diffs that include text |
| 23:47 | brehaut | is there any way to get cljs to compile off standard input? |
| 23:56 | choffstein | Anyone have any idea why I might be getting this when running my tests? "actual: java.lang.ClassCastException: com.newfoundresearch.ttm09.data.DataPoint cannot be cast to com.newfoundresearch.ttm09.data.DataPoint". I have a record that I am importing into two other namespaces, then type hinting. I pass an instantiation of DataPoint from one of those namespaces to the other and get this cropping up. |
| 23:58 | choffstein | seems ... sort of odd. |