2009-08-05
| 00:47 | JAS415 | If I create anonymous functions, do I eventually get the memory back from them, or is it lost forever to the Java GC Gods? |
| 00:52 | JAS415 | looks like its ok |
| 00:58 | prospero_ | is there a difference between (int-array 1) and (make-array Integer/TYPE 1)? |
| 00:58 | prospero_ | is one unboxed and the other boxed? |
| 00:58 | hiredman | ~def int-array |
| 01:00 | hiredman | ,(class (int-array 1)) |
| 01:00 | clojurebot | [I |
| 01:01 | hiredman | ,(class (make-array Interger/Type 1)) |
| 01:01 | clojurebot | java.lang.Exception: No such namespace: Interger |
| 01:01 | hiredman | ,(class (make-array Integer/Type 1)) |
| 01:01 | clojurebot | java.lang.Exception: Unable to find static field: Type in class java.lang.Integer |
| 01:01 | mebaran151 | why is there int array and long array but no byte array |
| 01:01 | hiredman | ,(class (make-array Integer/TYPE 1)) |
| 01:01 | clojurebot | [I |
| 01:01 | prospero_ | hiredman: isn't there an implicit boxing when you ask for the class? |
| 01:02 | mebaran151 | as in int-array and long-array |
| 01:02 | hiredman | ugh, github is murder on netbook |
| 01:02 | hiredman | prospero_: arrays are not boxed |
| 01:03 | prospero_ | hiredman: ok, thanks |
| 01:04 | konj | Guys, can I easily create a program that allows me to draw points in a loaded image using clojure? Is there a widget for something like this in some GUI toolkit? |
| 01:27 | cark | KONJ DID YOU HAVE A LOOK AT THE JAVA API , |
| 01:27 | cark | hum oops |
| 01:27 | cark | didn't mean to shout |
| 01:28 | konr | yes, I'm reading about Swing |
| 01:28 | cark | anyways had good success doing nice stuff with it |
| 01:28 | konr | apparently, I can draw in a canvas |
| 01:28 | cark | right |
| 01:28 | konr | will I be able to do it with Clojure? |
| 01:28 | cark | yep |
| 01:29 | konr | sounds great, then! |
| 01:29 | konr | easily creating a GUI application in a Lisp Dialect still sounds like a dream, though |
| 01:30 | cark | with clojure it's not a dream anymore |
| 01:30 | cark | you have plenty opions within the java world |
| 01:30 | cark | options* |
| 01:31 | cark | you might do everything programmatically, or use a java IDE for design and use the result from clojure |
| 01:55 | JAS415 | I'm using hash tables to hold window description and proxy/anonymous functions to add listeners to things |
| 01:56 | JAS415 | is actually very clean |
| 01:56 | JAS415 | get a nice MVC separation and easy access/modification to stuff inside your windows |
| 01:59 | tomoj | clojure.test says "you can use nested tests to set up a context shared by several tests". does that mean via binding? |
| 02:49 | tomoj | I take back what I said about preferring css selector strings to enlive's syntax |
| 02:49 | tomoj | enlive's syntax rocks |
| 03:01 | tomoj | what's the function that composes two functions? |
| 03:01 | tomoj | oh, comp |
| 03:03 | cgrand | tomoj: what makes you prefer enlive's selectors syntax over css syntax? |
| 03:05 | tomoj | cgrand: [:tr #{:.tbon :.tboff :.tb}] |
| 03:06 | tomoj | vs. tr.tbon, tr.tboff, tr.tb |
| 03:06 | tomoj | and I imagine it goes deeper |
| 03:18 | lisppaste8 | cgrand annotated #84716 "lazy-union" at http://paste.lisp.org/display/84716#1 |
| 03:32 | mebaran151 | distinct is lazy? |
| 03:33 | mebaran151 | whoa |
| 03:34 | mebaran151 | that's ... insane: to think hiredman had said it couldn't be done |
| 03:34 | mebaran151 | ha |
| 03:41 | mebaran151 | in the end it became a trivial one liner |
| 03:55 | tomoj | say you have a map with a :content key, the value of which is a vector. each element in the vector can either be another map with a :content key and similar value or a string |
| 03:55 | tomoj | how would you recur through and just concat all the strings, depth-first? |
| 03:59 | mebaran151 | recursive map it with a function that takes either a hash or a string, return output at string, or mapping itself when presented a collection |
| 04:00 | tomoj | the "recursive map" is my problem I think |
| 04:00 | tomoj | well all the attempts I have tried using map ended up returning results that were still nested |
| 04:00 | tomoj | but no map will really work as far as I can tell, since recur needs to be in tail position |
| 04:02 | mebaran151 | to unnest, try apply concat |
| 04:02 | mebaran151 | (that's how flatteners work underhood) |
| 04:02 | mebaran151 | you probably want some clever combination of apply concat to specific output and recursively mapping |
| 04:03 | tomoj | but what does "recursively mapping" mean? |
| 04:07 | tomoj | (apply str (map my-function arg)) works, but that's evil |
| 04:12 | tomoj | i.e. the call-stack could blow if there is a bunch of nesting |
| 04:12 | tomoj | in my case there won't ever be a bunch of nesting, so I guess I'll settle for this for now.. |
| 04:13 | hiredman | tomoj: there is always reduce |
| 04:14 | hiredman | ,(reduce str (map char (range 90 100))) |
| 04:14 | clojurebot | "Z[\\]^_`abc" |
| 04:14 | tomoj | but doesn't that still leave no place for `recur` ? |
| 04:15 | tomoj | I imagine the problem is that I'm not thinking functionally |
| 04:15 | hiredman | sorry, I haven't really read up |
| 04:16 | hiredman | ,(reduce str [(map char (range 90 100)) (map char (range 80 90))]) |
| 04:16 | clojurebot | "clojure.lang.LazySeq@5d68f306clojure.lang.LazySeq@d6720cc6" |
| 04:16 | hiredman | whoops |
| 04:18 | tomoj | this is what I have http://gist.github.com/162589 |
| 04:18 | tomoj | ignore the '*' |
| 04:18 | tomoj | it works, but no TCO |
| 04:19 | hiredman | so you want a flattened sequence of strings that you can turn into one string |
| 04:19 | tomoj | that would be fine |
| 04:19 | tomoj | that code just returns one string |
| 04:20 | hiredman | ,x |
| 04:20 | clojurebot | {:content ["foo " {:content ["bar " "baz "]} "biz"]} |
| 04:21 | tomoj | wut |
| 04:21 | hiredman | sshhh |
| 04:21 | tomoj | hax? |
| 04:21 | hiredman | don't worry about it |
| 04:21 | hiredman | wait |
| 04:21 | hiredman | hold the phone |
| 04:22 | hiredman | ,(doc tree-seq) |
| 04:22 | clojurebot | "([branch? children root]); Returns a lazy sequence of the nodes in a tree, via a depth-first walk. branch? must be a fn of one arg that returns true if passed a node that can have children (but may not). children must be a fn of one arg that returns a sequence of the children. Will only be called on nodes for which branch? returns true. Root is the root node of the tree." |
| 04:22 | tomoj | ah, nice |
| 04:22 | hiredman | ,(tree-seq map? :content x) |
| 04:22 | clojurebot | ({:content ["foo " {:content ["bar " "baz "]} "biz"]} "foo " {:content ["bar " "baz "]} "bar " "baz " "biz") |
| 04:22 | hiredman | ,(remove map? (tree-seq map? :content x)) |
| 04:22 | clojurebot | ("foo " "bar " "baz " "biz") |
| 04:22 | hiredman | ,(apply str (remove map? (tree-seq map? :content x))) |
| 04:22 | clojurebot | "foo bar baz biz" |
| 04:23 | tomoj | ok, now I will go try to figure out what the heck that's doing :) |
| 04:23 | tomoj | thanks |
| 04:23 | tomoj | I suspected there would be a nice one-liner |
| 04:23 | hiredman | my pleasure |
| 04:24 | tomoj | oh, I see. tree-seq gives you all the nodes, but I only want leaves |
| 04:34 | gko | ` |
| 04:35 | gko | ? |
| 04:35 | hiredman | ¿ |
| 04:35 | gko | sorry, wrong window... |
| 04:47 | gko | How do you protect concurrent access to a socket in clojure? |
| 04:47 | jdz | what concurrent access? |
| 04:48 | gko | one socket, three threads use it to send requests. |
| 04:49 | jdz | why? |
| 04:49 | jdz | you can't send 3 requests at once, can you? |
| 04:49 | gko | that's why I ask: how do you protect? |
| 04:50 | jdz | no, that's a wrong question, really |
| 04:50 | cgrand | you can use an agent (whose value is the socket) to serialize access to it |
| 04:50 | cgrand | but I agree it seems wrong to share a socket between threads |
| 04:50 | jdz | gko: you want only one thread to do the socket interaction |
| 04:51 | jdz | gko: and as cgrand suggested, agents is one way to do it |
| 04:52 | gko | OK... I'll try with the agent. |
| 04:55 | gko | Thanks. |
| 06:46 | ennui | Slime: Does slime-edit-definition (M-.) work for you on functions compiled by slime's interactive compile commands (like C-c C-k)? |
| 07:10 | jdz | ennui: source location information is recorded only when loading/compiling whole files |
| 07:38 | ennui | jdz, thanks, but doesn't slime-compile-and-load-file (C-c C-k) exactly do that? |
| 07:39 | jdz | ennui: that i cannot tell. my feeling is that it should. |
| 08:06 | cemerick | hopefully clojure-in-clojure will make the path to userland reader macros more clear. Putting together an xpath-esque query language without them is not pretty. |
| 08:30 | tomoj | I thought the clojure dude didn't want reader macros |
| 08:30 | tomoj | cemerick: ^ |
| 08:44 | cemerick | tomoj: I'm not sure that rhickey ever said he "doesn't want" reader macros -- I think he's (rightly) more concerned with various issues associated with them (namespacing, for one, IIRC) |
| 08:44 | cemerick | that said, they're an incredibly useful (in some cases, invaluable) tool, so I'm rooting for them. |
| 08:45 | cgrand | rhickey: https://www.assembla.com/spaces/clojure/tickets/166-TransientHashMap first cut, rather crude |
| 08:48 | tomoj | github is just slow today |
| 08:49 | cgrand | thanks |
| 08:49 | rhickey | cgrand: have you got a repo I can pull to try it out rather than deal with patches yet? |
| 08:50 | cemerick | seems like a chronic problem lately |
| 08:50 | cgrand | should be in master here: git://github.com/cgrand/clojure.git |
| 09:14 | Chousuke | cemerick: I'm working on a simple (rather ad-hoc) clojure reader at the moment. It's not yet usable though. |
| 09:17 | Chousuke | I suspect it would blow up if you had a *really* deeply nested list :) |
| 09:18 | cemerick | Chousuke: it's definitely worthwhile. |
| 09:18 | cemerick | IIRC, it's not the impl of reader macros that was blocking things -- it's how they're integrated into the environment |
| 09:22 | Chousuke | hmm, blows up with a list 10000 levels deep :/ |
| 09:22 | Chousuke | can handle 1000 though. |
| 09:22 | alinp | hi |
| 09:22 | alinp | (defn sum-list [list acc] |
| 09:22 | alinp | (if (zero? (.size list)) |
| 09:22 | alinp | acc |
| 09:22 | alinp | (recur (rest list) (+ (first list) acc)))) |
| 09:23 | alinp | cam this be considered tail call optimized ? |
| 09:23 | Chousuke | if it works, it is tail recursive |
| 09:23 | alinp | as far as I know, clojure doesn't have TCO |
| 09:23 | Chousuke | recur throws an exception if it's not in tail position |
| 09:23 | alinp | that's why I asked |
| 09:23 | alinp | oh |
| 09:23 | Chousuke | that's why recur exists :) |
| 09:23 | alinp | pretty smark :D |
| 09:23 | alinp | *smart |
| 09:23 | alinp | :) |
| 09:23 | alinp | thanks |
| 09:23 | Chousuke | anyway, (apply + yourlist) :P |
| 09:24 | alinp | yeah ... but is just a proof of concept you know |
| 09:24 | Chousuke | (and use (count list) instead of .size) |
| 09:24 | alinp | oh, count :) |
| 09:24 | alinp | forgot about that |
| 09:24 | Chousuke | though even more idiomatic would be (if-not (seq list) |
| 09:24 | alinp | beside of (apply) we have reduce |
| 09:24 | alinp | afaik |
| 09:24 | alinp | I could use that |
| 09:25 | Chousuke | they're almost identical in this case. |
| 09:25 | Chousuke | + uses reduce internally for more than 2 args |
| 09:25 | alinp | user=> (reduce (fn [x y] (+ x y)) (list 1 2 3)) |
| 09:25 | alinp | yeah |
| 09:25 | Chousuke | alinp: (reduce + [1 2 3]) works |
| 09:25 | alinp | yeah, true |
| 09:26 | Chousuke | it's so easy to make those unnecessary lambdas :P |
| 09:26 | Chousuke | another common one is (map #(foo %) ...) |
| 09:26 | Chousuke | when (map foo ...) is equivalent and probably faster |
| 09:30 | cemerick | I stumbled across some of my first clojure (from ~14 months ago) a few weeks ago, where I did exactly that: (map #(foo %) ...) :-/ |
| 09:31 | konr | Is clojure fast for webservices? I'll have to migrate my PHP system because it is running too slow, but I'm not sure to what. |
| 09:32 | konr | The main task is querying a MySQL database and creating a bunch of .html pages. |
| 09:34 | eevar2 | konr: profile your existing app before you start rewriting |
| 09:34 | cemerick | konr: roughly as fast as Java (which is pretty darn fast), especially for web stuff (since I/O is the prime bottleneck there) |
| 09:35 | eevar2 | if you don't know your bottlenecks, optimization is just wasted effordt |
| 09:35 | eevar2 | butterfingers++ |
| 09:37 | rhickey | cgrand: got any test code at hand you can paste? |
| 09:38 | Chousuke | hm |
| 09:38 | Chousuke | I wonder if people will ever need to read a single datastructure that's over a thousand levels deep :P |
| 09:39 | cemerick | Chousuke: should probably count on it *shrug* Just think of stuff emitted by prn or print-dup |
| 09:42 | Chousuke | looks like the limit is around 2000 for nested empty lists. |
| 09:42 | eevar2 | Chousuke: preallocated array? or running out of stack space? |
| 09:42 | Chousuke | stack space |
| 09:42 | Chousuke | my reader is recursive. (recursion makes things so simple...) |
| 09:42 | eevar2 | bleh, that's what -Xss is for ;) |
| 09:43 | Chousuke | I guess I'll just write this thing so it's half way usable first |
| 09:45 | Chousuke | regular clojure programs would have no problem I guess. at most ten to twenty levels of nesting. |
| 09:45 | eevar2 | konr: otoh, clojure+postgres is vastly better to work with, which might warrant a rewrite for no other reason ;) |
| 10:04 | Fossi | this goddamn lazyness |
| 10:04 | AWizzArd | It's good, isn't it? |
| 10:04 | Fossi | one day i'll get it. or become it? ;) |
| 10:05 | lisppaste8 | cgrand pasted "some tests" at http://paste.lisp.org/display/84818 |
| 10:05 | Fossi | i always fall for map (fn-for-sidefx) something |
| 10:05 | Fossi | i even go and ty it on the repl |
| 10:06 | Fossi | and mystically, it works |
| 10:06 | jdz | i use doseq when i want sideffects |
| 10:07 | rhickey | cgrand: thanks, although I think your proxy hashcode dominates and blurs the true speed diff |
| 10:08 | Fossi | jdz: good idea |
| 10:09 | cemerick | Fossi: map is *always* lazy. There's doall and dorun, but that's hacky (IMO) |
| 10:09 | cgrand | rhickey: I just noticed a gross bug and pushed the fix |
| 10:09 | lisppaste8 | rhickey annotated #84818 "transient map string keys test" at http://paste.lisp.org/display/84818#1 |
| 10:10 | Fossi | yeah, doseq is a vey good idea |
| 10:11 | rhickey | cgrand: got it, thanks |
| 10:11 | rhickey | cgrand: so it looks good - thanks very much! I had a bit of trouble tracking the ensureEditable responsibility |
| 10:14 | rhickey | cgrand: surprisingly a 3-5x boost, I didn't think it would do that well with compressed inner nodes, since there is still a lot of new allocation |
| 10:15 | cgrand | for inner nodes, we can suppress the allocation for the Node itself and assign nodes to the new array |
| 10:16 | rhickey | cgrand: yes, but if arrays of 32 we wouldn't need new arrays, although as with the vector there is lots of logic using the array lengths :( |
| 10:17 | rhickey | I also got rid of the box when I revisited vector, not sure if we could with hashmap |
| 10:17 | rhickey | so many vector ops do no alloc at all once on writable nodes |
| 10:17 | rhickey | but you did the right thing to preserve existing functionality - too easy to break |
| 10:18 | cgrand | my question about amortized O(1) for persistent! was about performing some cleanup (eg trimming inner nodes) when perssitent! is called. The clean-up cost can be amortized on updates |
| 10:19 | rhickey | cgrand: I don't think that's worth it. I'd rather have a heuristic on using bitmapped indexed node. Chances are good once > 50% full would pay to use full-sized arrays and get rid of the bitcount call |
| 10:21 | rhickey | this both for transient use and not |
| 10:23 | cgrand | yesterday you mentioned ideas about getting rid of LeafNode, could you elaborate? |
| 10:25 | rhickey | cgrand: yes, I'd like to avoid allocating a holder object for the leaves and instead hold the key and val in the next level higher. the array would then be a mix of INode ptrs and keys, and there would be a second array for vals |
| 10:26 | rhickey | if INode, you need to traverse down, else is key and same index in vals is value |
| 10:26 | rhickey | Overall I think this would use less memory and many fewer objects |
| 10:27 | cgrand | two arrays or a single interleaved array? |
| 10:27 | rhickey | cgrand: dunno, would try both |
| 10:28 | rhickey | if you are interested, what I was going to do was explore all of these ideas with a new hashed set based on newnew, one not based on a dummy map. It wouldn't need the second array/interleaving since only keys, but a place to explore a simpler node model |
| 10:28 | rhickey | so, hashed set written entirely in Clojure |
| 10:30 | cgrand | I haven't touched to newnew yet, it could be interesting. Have you written some code so far? |
| 10:31 | rhickey | cgrand: just swapped out some proxies, but it is quite simple, as it would be to define in terms of proxy, just proxy could never be fast enough. new new is |
| 10:33 | rhickey | the only thing missing from new new is non-reflective self calls, which would make helper methods slower, but self-call method resolution is coming |
| 10:33 | rhickey | volatile (a la mutable fields) is there |
| 10:33 | rhickey | although mostly the collection mutate arrays |
| 10:36 | rhickey | you can derive from supers with no arg ctors, so can use j.u.Abstract* |
| 10:37 | Jomyoot | how would I collect results of (with-query-results) into a non-lazy seq? |
| 10:38 | rhickey | Jomyoot: (vec lazy-thing) -> non-lazy vector |
| 10:38 | Jomyoot | hmm |
| 10:38 | Jomyoot | thanks |
| 10:39 | Jomyoot | is there benchmark of transient yet? |
| 10:40 | cemerick | Jomyoot: vectors are here: http://clojure.org/transients |
| 10:40 | cemerick | maps appear to be en route |
| 10:41 | cemerick | rhickey: ssssshhh! We're trying to do some marketing over here ;-) |
| 10:41 | rhickey | transients rock! |
| 10:41 | rhickey | that's marketing |
| 10:41 | cemerick | there ya go :-D |
| 10:42 | rhickey | cgrand: so, how do you feel about the transient map patch? |
| 10:43 | cemerick | rhickey: you'll know clojure's "made it" when you see articles like "Improve your POJOs' performance with clojure transients" |
| 10:44 | rhickey | scary |
| 10:44 | cemerick | yup |
| 10:44 | cgrand | rhickey: rather confident (I didn't rework existing functionality) but not happy with all the allocation that is still going on |
| 10:46 | rhickey | cgrand: that allocation is just what was happening before though, right? so just a future opportunity we need not pursue now (in an effort to preserve integrity of existing logic). I think the current 3-5x speedup is tangible and worth it |
| 10:47 | rhickey | does your patch on assembla have your latest fix? |
| 10:47 | Jomyoot | what is similiar to for-each in clojure |
| 10:47 | cgrand | not yet -- git guys: is there a way to bundle all my commits into one? |
| 10:48 | Jomyoot | where you need side effecs |
| 10:48 | Chousuke | Jomyoot: doseq |
| 10:48 | cemerick | cgrand: interactive rebase, with squashing |
| 10:48 | rhickey | I guess I could just merge here... |
| 10:48 | Chousuke | cemerick: git rebase --interactive branch-to-rebase-on |
| 10:49 | cemerick | indeed, although -i is a lot shorter than --interactive |
| 10:49 | rhickey | cgrand: I don't like squashing |
| 10:50 | Chousuke | you don't have to squash everything though. :) |
| 10:50 | rhickey | what's wrong with the truth? |
| 10:50 | Chousuke | rhickey: well, if you happen to have a silly mistake in your history that breaks the build, it'll make bisecting real problems more difficult. |
| 10:51 | cemerick | I often commit in bits and pieces, each step of which may or may not work, then I squash into a functional chunk. |
| 10:51 | Jomyoot | will error reporting get improved? |
| 10:51 | Jomyoot | it's hard to find where error is |
| 10:51 | cemerick | (may not work on its own, that is) |
| 10:51 | rhickey | Chousuke: otoh, if at the end you discover that some intermediate step broke something it won't be there to bisect |
| 10:52 | Chousuke | well, yeah, if you squash too much that can happen |
| 10:52 | rhickey | no one can help you see where you went wrong |
| 10:52 | rhickey | can't go back to an old idea that proved better |
| 10:52 | Chousuke | I tend to use --patch to *split* things in addition to squashing silly commits :) |
| 10:52 | rhickey | it's not like people are going to be randomly pulling down one of your interim commits just for fun |
| 10:54 | cgrand | rhickey: I uploaded another patch but if you chosse to merge you'll get the patch for #165 |
| 10:54 | Chousuke | but sometimes you might end up committing something that's very clearly not working, just to get it into version control (if you have to work on something else for example) |
| 10:54 | cemerick | rhickey: people won't, but hudson, etc., will...so if any particular changeset isn't kosher, you're going to get false negatives |
| 10:54 | cemerick | not an issue with clojure (atm!), but anyway... |
| 10:55 | rhickey | tracking systems that force things that don't work to be out of the system are... not very useful |
| 10:55 | Jomyoot | clojure is like RPN calculator |
| 10:56 | Chousuke | btw, can someone write me syntax-quote as a macro? I tried to do it yesterday myself but it is not easy :> |
| 10:57 | Chousuke | I had some success using the syntaxQuote method from SyntaxQuoteReader but that's cheating :P |
| 10:57 | Jomyoot | what's cool about clojure is i can make a lot of guesses . most of the time i am right |
| 10:57 | cemerick | rhickey: well, something that trips hudson will trip a real person too (e.g. anyone closely tracking HEAD) *shrug* |
| 10:58 | rhickey | cemerick: I disagree, if I just pulled 26 commits from cgrand, I don't care if #17 didn't build |
| 10:58 | rhickey | it has to do with the granularity of transfers, not of commits |
| 10:58 | cemerick | it's a race condition -- if you happened to pull when HEAD was #17... |
| 11:00 | rhickey | cemerick: in a single-repo/branch situation, yes, but in a "I'm at a good spot, try it" situation no |
| 11:00 | cemerick | oh, sure. Coordination definitely helps just about everything. |
| 11:00 | rhickey | push/pulls have coarser granularity than commits |
| 11:01 | rhickey | if they happen at stable points the interim commits shouldn't matter |
| 11:05 | rhickey | what's this about from git am? "warning: 2 lines add whitespace errors." |
| 11:06 | Chousuke | trailing whitespace somewhere. |
| 11:06 | Chousuke | git can be configured not to complain, but I can't recall how :P |
| 11:07 | cemerick | Chousuke: http://www.nabble.com/git-warning-about-whitespace--td19730533.html |
| 11:08 | cemerick | core.whitespace looks to be the most relevant config variable |
| 11:08 | Jomyoot | rhickey: are you going to come up with web framework for clojure as well? |
| 11:08 | Chousuke | hm. I need to replace magit with egg ;/ |
| 11:08 | Jomyoot | rhickey: i think we can do very well if we have something like rails writtein with clojure |
| 11:08 | Chousuke | magit is ... spartan. |
| 11:09 | fffej | jomyoot: have you seen Compojure? |
| 11:09 | Jomyoot | it does not have database and backend stuff |
| 11:09 | Jomyoot | i thought compojure is for frontend |
| 11:09 | cemerick | Jomyoot: clojure can be used with just about any of the 100's of java web frameworks |
| 11:10 | gko | Or use Clojure for creating applications on Eclipse. |
| 11:10 | gko | Clojure for Eclipse = Emacs Lisp for Emacs ? |
| 11:11 | Jomyoot | yep |
| 11:11 | Jomyoot | but rather have something in pure clojure |
| 11:11 | Jomyoot | rather than having to do the interop thing |
| 11:11 | Jomyoot | it's not lispy |
| 11:11 | gko | yep |
| 11:19 | rhickey | while not showing up in github UI, transient support for persistent hash maps is up in master - thanks to cgrand! |
| 11:21 | cemerick | cgrand: I raise my tea to you, sir! :-) |
| 11:24 | cemerick | 11sies? onesies? hrm. |
| 11:24 | rhickey | I don't suppose 'Clojure is for tea drinkers' is much of a slogan |
| 11:25 | cemerick | rhickey: yeah. No more marketing for you. ;-) |
| 11:25 | rhickey | :( |
| 11:25 | cemerick | I'm not an *actual* tea-drinker, though. Diet raspberry snapple. |
| 11:26 | Chousuke | rhickey: sets to go. I suppose they're rather similar to maps? |
| 11:26 | rhickey | cemerick: that truly qualifies as "not actual" |
| 11:27 | cemerick | but it says it's tea! *right on the bottle*! :-P |
| 11:27 | cemerick | I've been hooked on the stuff since college. |
| 11:29 | cgrand | Chousuke: right now sets are far easier since they delagate everything to a map |
| 11:39 | arohner | I have a recursive function that it's not convenient to recurse in the tail position. What is a good rule of thumb for how many times I can recurse in a non-tail position before blowing the stack? |
| 11:41 | Chousuke | granted, it just calls java... |
| 11:41 | Chousuke | but it works! |
| 11:43 | Chousuke | I wonder how much of Clojure expects the reader to work with a PushbackReader |
| 11:45 | Chousuke | My reader just expects a sequence of lines, though wrapped in a map so I can number them |
| 11:53 | danlarkin | could you use metadata for that instead of a map? |
| 12:00 | Chousuke | danlarkin: Can't stick metadata on strings :/ |
| 12:00 | danlarkin | Chousuke: *doh*! that always gets me |
| 12:07 | gko | how to create a sequence of X items in a list by calling X times the same function which has no argument? Add arity 1 parameter to call the arity 0 function, so one could (take X (iterate my-function (my-function))) ? |
| 12:08 | Chousuke | I think I need to figure out a saner way to skip whitespace. |
| 12:08 | stuartsierra | ,(doc repeatedly) |
| 12:08 | clojurebot | "([f]); Takes a function of no args, presumably with side effects, and returns an infinite lazy sequence of calls to it" |
| 12:08 | Chousuke | currently, the reader returns a *skip* object and I filter them out :P |
| 12:09 | gko | stuartsierra: thanks! |
| 12:20 | stuartsierra | welcome |
| 12:21 | Chousuke | hmm. |
| 12:21 | Chousuke | I pushed my WIP on github but github's apparently slow to update :P |
| 12:31 | LauJensen | Good evening gents |
| 12:38 | mebaran151 | how would one encode a data in a lexograhically sortable format? |
| 12:42 | fffej | mebaran: do you mean encode a date? if so, ISO 8601 |
| 12:46 | mebaran151 | new to the Java libs, so what's the easiest way to make one of these, say for the current Time |
| 12:47 | fffej | Joda time is my favourite, check out http://joda-time.sourceforge.net/ |
| 12:47 | cemerick | you can very easily emit ISO 8601 with the standard DateFormat |
| 12:57 | jwhitlark | stuartsierra: is that your post on blog.law.cornell.edu? |
| 13:04 | jwhitlark | hiredman: what's clojurebot's command to see when someone was last online? I've seen it used, but can't find it in the docs... |
| 13:08 | cemerick | ~seen Chouser |
| 13:08 | clojurebot | Chouser was last seen quiting IRC, 1732 minutes ago |
| 13:08 | cemerick | jwhitlark: ^^ |
| 13:08 | jwhitlark | thanks! |
| 13:09 | jwhitlark | ah, that would explain it, seen isn't in http://clj.thelastcitadel.com/clojurebot, and I didn't want to clutter the channel with experiments. (that aren't about clojure :-) |
| 13:09 | jwhitlark | ~seen stuartsierra |
| 13:09 | clojurebot | stuartsierra was last seen in #clojure, 49 minutes ago saying: welcome |
| 13:11 | leafw | jcip |
| 13:11 | leafw | ~jcip |
| 13:11 | clojurebot | jcip is Java Concurrency in Practice |
| 13:14 | stuartsierra | jwhitlark: yes, that's my article on VoxPopuLII: http://blog.law.cornell.edu/voxpop/2009/08/05/tidying-up-the-law/ |
| 13:17 | jwhitlark | it's interesting. As an ex-accountant, I strongly agree. |
| 13:17 | stuartsierra | thanks |
| 13:18 | jwhitlark | I'd have much rather read tax law as code, then what it is now ;-) |
| 13:18 | rhickey | stuartsierra: nice read |
| 13:19 | stuartsierra | thanks |
| 13:19 | stuartsierra | Clojure is helping to further the goals of democracy! |
| 13:20 | jwhitlark | democracy can certainly use all the help it can get. |
| 13:23 | rhickey | stuartsierra: I love that about Clojure! |
| 13:25 | jwhitlark | I'll tell you, I'm attempting projects in clojure I wouldn't have dreamed of trying in another language. My favorite to date is python, and I get lots done with it, but clojure just seems to open new horizons. |
| 13:48 | LauJensen | stuartsierra: Did you read James Reeves reply to my Long Live HTTP connections post? |
| 13:49 | stuartsierra | no |
| 13:49 | LauJensen | You'll find backing for your argument last night, and a solution :) |
| 13:51 | stuartsierra | cool, where was this? |
| 13:52 | Chousuke | hmm |
| 13:55 | LauJensen | sec |
| 13:55 | LauJensen | stuartsierra: http://groups.google.com/group/compojure/browse_thread/thread/1f0df9d6656fa069 |
| 13:56 | stuartsierra | nice, thanks |
| 13:56 | LauJensen | np |
| 13:56 | stuartsierra | I didn't realize Java could handle "a few thousand threads" |
| 13:57 | Chousuke | gah. |
| 13:57 | Chousuke | Why does my emacs insist on using tabs |
| 13:57 | LauJensen | James never seizes to amaze me with the answers he gives on the group |
| 13:57 | Chousuke | I'm pretty sure I have told it not to. |
| 13:57 | LauJensen | Hmm, I think I meant 'ceases' |
| 13:58 | cemerick | jeez, $60 for a mass-market programming paperback? |
| 13:58 | cemerick | sorry, wrong chan |
| 13:59 | LauJensen | cemerick: Yea, looks like it belongs in #grumpyoldmen |
| 14:00 | cemerick | huh, I figured that sentiment would be widespread. Most paperbacks I see top out at ~$40 |
| 14:00 | jwhitlark | Is http://clojure101.blogspot.com/2009/05/creating-clojure-repl-in-your.html still the best way to go about embedding a repl in an application to be connected to over the network? |
| 14:00 | cemerick | LauJensen: but :-) anyway |
| 14:00 | rsynnott | stuartsierra: modern operating systems can manage quite a few threads without getting bogged down |
| 14:01 | rsynnott | cemerick: could be worse. Medical textbooks are often _hundreds_ of euro |
| 14:01 | cemerick | jwhitlark: yes, we use the enclojure REPL library...though our wrapper for it is a lot smaller than the one on that page.... |
| 14:01 | rsynnott | (even while being mass-market paperbacks) |
| 14:03 | cemerick | rsynnott: I just wish there was some sanity to it all. $30 for the terracotta paperback (or any random "popular" programming topic, e.g. spring, whatever), but $60 for this other title (a Netbeans book). |
| 14:13 | Neronus | since commit b75cdb8b61e0fd4e83934e29d5ddaf78296ba7a7 clojure doesn't build for me. Sorry if this has already been mentioned |
| 14:14 | rhickey | Neronus: doesn't build and does what? |
| 14:15 | Chousuke | fails to build for me too |
| 14:15 | rhickey | fails how? |
| 14:15 | Chousuke | fails to find symbol; symbol : method copyOf(java.lang.Object[],int) |
| 14:15 | Chousuke | on line 333 of PersistentArrayMap.java |
| 14:16 | Neronus | http://paste.lisp.org/display/84843 |
| 14:16 | Neronus | What Chousuke says :) |
| 14:17 | rhickey | ah, cgrand used a Java 6 API |
| 14:17 | Neronus | java -version |
| 14:17 | Neronus | java version "1.6.0_14" |
| 14:17 | Chousuke | Neronus: the buildfile specifies a 1.5 target |
| 14:17 | Neronus | ahh |
| 14:17 | Chousuke | it's still a bug though, Clojure targets 1.5 :) |
| 14:19 | LauJensen | Why are we targeting 1.5 ? |
| 14:19 | stuartsierra | Lots of big deployments are still on 1.5 |
| 14:19 | Chousuke | probably because rhickey has a mac :P |
| 14:19 | stuartsierra | that too |
| 14:20 | LauJensen | Chousuke: I'm on a Mac too, with 1.6 :) |
| 14:20 | stuartsierra | big Java deployments, that is |
| 14:20 | Chousuke | LauJensen: yeah, but 1.6 is 64-bit only, and fairly recent. |
| 14:20 | Chousuke | on OS X that is. |
| 14:20 | LauJensen | Chousuke: Sure, but ofc Im not using OSX :) |
| 14:20 | Chousuke | :P |
| 14:21 | Chousuke | Coding Clojure is too much fun sometimes. |
| 14:21 | Chousuke | I want to continue working on my reader, but I'm getting tired so I think I won't. |
| 14:21 | rsynnott | no doubt all part of Steve Jobs' evil plot to keep Java down :P |
| 14:21 | Chousuke | I'm still on the easy part of reader-writing though. |
| 14:22 | Chousuke | just many defmethods |
| 14:23 | LauJensen | Which reader? |
| 14:23 | Chousuke | Clojure :P |
| 14:23 | LauJensen | Something which reads Clojure code? |
| 14:24 | Chousuke | something which reads strings and produces clojure code ;) |
| 14:24 | LauJensen | Whats the use case? |
| 14:24 | Chousuke | replacing the java thing in clojure, if it turns out good enough. |
| 14:24 | Chousuke | if not, well, it's educational! |
| 14:25 | LauJensen | Ok, looking forward to seeing the result |
| 14:26 | Chousuke | My design for now is to keep things as simple as possible. |
| 14:26 | Chousuke | Even if it needs to be rewritten I hope some of the functions can be salvaged :P |
| 14:26 | Neronus | What about the bug? Will someone contact cgrand, or will we expect that he reads this? |
| 14:27 | LauJensen | Neronus: I expect rhickey is already on it ? |
| 14:28 | Chousuke | This is what it looks like right now http://github.com/Chousuke/clojure/blob/240ab60e56cf031aea1300135a9610fa8833f1ae/src/clj/clojure/lang/reader.clj |
| 14:29 | Chousuke | it can read simple stuff, but no support for numbers yet :P |
| 14:29 | Chousuke | and I cheated with syntax-quote :D |
| 14:29 | LauJensen | Interesting. Have you checked out SICP before doing this? I think one of their final lectures is on the topic |
| 14:30 | rhickey | fixed |
| 14:30 | Chousuke | maybe I should. |
| 14:30 | rhickey | Neronus: fixed |
| 14:30 | Neronus | rhickey: Okay, thanks |
| 14:30 | rhickey | thanks for the report |
| 14:30 | Chousuke | the biggest problem with that design for now is that it's recursive. |
| 14:31 | Chousuke | it blows up if you have over 2000 levels of nesting :P |
| 14:31 | rhickey | I was still set up for java 6 here, for work on ForkJoin stuff |
| 14:31 | drewr | I'd like to do something like (size (range 1000)) where size returns the amount of memory used by the resulting seq; has anyone done that yet? is it possible apart from a profiler? |
| 14:31 | Neronus | rhickey: You're welcome |
| 15:23 | grosours | Hi |
| 15:26 | LauJensen | yo |
| 15:33 | cgrand | Neronus, rhickey & al: drat, sorry |
| 15:33 | rhickey | cgrand: np, quick fix |
| 15:33 | rhickey | I was in Java 6 mode here too and missed it |
| 15:34 | kotarak | rhickey and contrib contributors: Is it ok to include a notice "Copyright © Rich Hickey et al. All rights reserved." and the EPL when using contrib? There is still some CPL.txt in the root of contrib. Is that obsolete? Must be done something else to not get into legal trouble? |
| 15:47 | rhickey | kotarak: yes, copyright and epl, can copy those from any of the Clojure .clj files |
| 15:47 | kotarak | k |
| 15:49 | lisppaste8 | stuartsierra pasted "Lazy map with New new" at http://paste.lisp.org/display/84852 |
| 15:50 | rhickey | stuartsierra: did you need the ~'s? new new should ignore any namespace on the methods names |
| 15:51 | stuartsierra | ok, wasn't sure if I needed them |
| 15:51 | rhickey | ~'s always trouble me |
| 15:51 | clojurebot | excusez-moi |
| 15:56 | stuartsierra | trying to figure out how to implement lazy-assoc |
| 15:58 | Chousuke | hmm |
| 16:01 | lisppaste8 | stuartsierra annotated #84852 "Lazy map with New new, take 2" at http://paste.lisp.org/display/84852#1 |
| 16:02 | Chousuke | does find use entryAt? |
| 16:02 | stuartsierra | yes |
| 16:03 | Chousuke | just wondering if you'd get a lazy seq of delays |
| 16:03 | Chousuke | That would be rather pointless :P |
| 16:03 | stuartsierra | no, consuming the sequence forces all the delays |
| 16:05 | kotarak | stuartsierra: you can also new new the MapEntry to a LazyMapEntry to be as lazy as possible. |
| 16:05 | stuartsierra | ah, yes |
| 16:06 | stuartsierra | kotarak: nothing personal; I like the idea of lazymap, wanted to see if I could do it with newnew |
| 16:06 | stuartsierra | haven't gotten assoc working yet, though |
| 16:06 | kotarak | stuartsierra: if it would work out that would be cool. would remove quite a bit of code, from a first glance at your paste. |
| 16:07 | Chousuke | stuartsierra: maybe you need (make-lazy-map (assoc base-map k v)) |
| 16:08 | stuartsierra | I think that's redundant with lazy-assoc. It throws an AbstractMethodError on assoc |
| 16:09 | mebaran151 | why don't atoms and refs support metadata? |
| 16:09 | mebaran151 | is there a good reason |
| 16:09 | stuartsierra | they do |
| 16:09 | Chousuke | maybe you need to type hint it? :/ |
| 16:10 | mebaran151 | ,(with-meta (atom 2) {:a 1}) |
| 16:10 | clojurebot | java.lang.ClassCastException: clojure.lang.Atom cannot be cast to clojure.lang.IObj |
| 16:10 | Chousuke | :/ |
| 16:10 | Chousuke | stuartsierra: APersistentMap has two assocs |
| 16:10 | kotarak | ,(meta (atom 2 :meta {:foo :bar})) |
| 16:10 | clojurebot | {:foo :bar} |
| 16:10 | Chousuke | something is wrong with that... |
| 16:12 | mebaran151 | can symbols have meta-data |
| 16:12 | Chousuke | yes |
| 16:13 | hiredman | there are two meta data interfaces |
| 16:13 | mebaran151 | so what is the with-meta macro good for? |
| 16:13 | hiredman | one uses with-meta |
| 16:14 | mebaran151 | sorry, I meant keywords |
| 16:14 | Chousuke | IIRC no. |
| 16:16 | kotarak | I think there is really only one Keyword with the same name, but there might be many Symbols with the same name. That's why Keywords don't have metadata. |
| 16:16 | kotarak | IIRC, that is. |
| 16:16 | lisppaste8 | stuartsierra annotated #84852 "Lazy map with New new, take 3" at http://paste.lisp.org/display/84852#2 |
| 16:18 | mebaran151 | ah |
| 16:19 | mebaran151 | I was also wondering why for things that didn't support meta-data (that come from Java land), why clojure couldn't maintain a built in hash-map indexed by hashcode deep in the bowels of its runtimes |
| 16:19 | mebaran151 | so that you could add metadata to strngs (which would be pretty useful) |
| 16:19 | _hrrld` | Is there the opposite of xml/parse? Something that will take a nested struct and give the xml text stream? |
| 16:20 | kotarak | mebaran151: I think this was discussed before and the hashmap would a perf bottleneck. Search clojure-log.n01se.net and the google group. You should find rhickey rationale on that one. |
| 16:20 | stuartsierra | mebaran151: it's been discussed, basic answer is it's impossible to do efficiently |
| 16:20 | mebaran151 | ah I see |
| 16:20 | kotarak | _hrrld`: clojure.xml/emit |
| 16:21 | mebaran151 | but it can't be any worse than rolling my own right? |
| 16:21 | mebaran151 | keeping the hashmap in memory seems like it could only hurt when I actally need the metadata |
| 16:22 | _hrrld` | kotarak: thanks, might be good to include the docs for xml/emit on http://clojure.org/api at some point. |
| 16:22 | hiredman | make sure to use a weakhashmap |
| 16:23 | hiredman | and weakhashmap isn't synchronized |
| 16:32 | LauJensen | drewr: Thanks for your report for ClojureQL, I'm working on it right now and hope to have something done within 1 hour, I'll keep you posted |
| 16:39 | stuartsierra | Still getting AbstractMethodError on assoc -- could this have something to do with the duplicate definitions of assoc in clojure.lang.Associative and clojure.lang.IPersistentMap? |
| 16:40 | Chousuke | Try adding #^c.l.IPersistentMap in front of (assoc ...) |
| 16:41 | hiredman | it goes inside in the paren I believe |
| 16:41 | stuartsierra | ok |
| 16:41 | cemerick | ...commenting on a topic from 2 hours ago: java 1.5 compatibility for clojure is *critical* in order to ensure that clojure libraries, etc., are widely usable. I don't know if there's hard figures, but we currently see a 20/60/20 split between 1.4/1.5/1.6. |
| 16:41 | hiredman | (#^c.l.IPersistentMap assoc …) |
| 16:42 | Chousuke | it goes there? I thought it was before the list. |
| 16:42 | stuartsierra | still getting AbstractMethodError |
| 16:42 | cemerick | Besides, 1.6 didn't add anything compelling that impacts the clojure impl, I don't think (although the VM is obviously much improved under the covers). |
| 16:42 | Chousuke | cemerick: You're probably right. :) |
| 16:42 | kotarak | cemerick: +1 (have only 1.4 as standard and 1.5 by some extra installation by the IT at work) |
| 16:43 | Chousuke | cemerick: I think 1.7 and 1.8 will be more interesting for Clojure. |
| 16:44 | cemerick | Chousuke: definitely -- but 1.5 compat will be needed for a *long* time. I know Rich has some ideas for feature-based reader stuff (e.g. basically ifdefs, which a couple other lisps have in various forms) |
| 16:44 | cemerick | We're only just now planning on dropping 1.4 compat (mostly because we're using clojure :-) ) |
| 16:44 | cemerick | (for our products, that is) |
| 16:45 | Chousuke | cemerick: Common lisp has the #+bool (expr) think I think |
| 16:45 | Chousuke | thing* |
| 16:45 | cemerick | yeah, something like that |
| 16:45 | cemerick | having something like that that is also extensible would be super-handy (e.g. "if the user's license allows X, do this, otherwise do that") |
| 16:46 | Chousuke | I might implement that for my reader, just for fun. :P |
| 16:49 | stuartsierra | Compile-time conditionals create a lot of headaches. |
| 16:51 | stuartsierra | re assoc: I think the problem is that clojure.core/assoc calls clojure.lang.RT.assoc(), which casts the collection argument to clojure.lang.Associative instead of clojure.lang.IPersistentMap |
| 16:51 | Chousuke | does APersistentMap implement Associative? |
| 16:51 | stuartsierra | yes |
| 16:52 | stuartsierra | indirectly, because IPersistentMap extends Associative |
| 16:52 | cemerick | stuartsierra: it simply has to be available for stuff like jvm versions, though, right? The alternative runtime checks would be impractical in a lot of contexts. |
| 16:53 | stuartsierra | Yeah, but portable Common Lisp libraries become so full of +this and -that they're nearly unreadable |
| 16:55 | drewr | LauJensen: cool, thanks! |
| 16:55 | Chousuke | anyone know of a emacs extension writing primer that is not the emacs manual? |
| 16:56 | Chousuke | the manual seems a bit daunting, I'm wondering if there's a more compact option to get started with. |
| 16:56 | jwhitlark | http://www.emacs.uniyar.ac.ru/doc/O%27Reilly_Emacs/Writing%20GNU%20Emacs%20Extensions.PDF |
| 16:57 | jwhitlark | should be this book: http://oreilly.com/catalog/9781565922617/ |
| 16:57 | Chousuke | oh, cool |
| 16:57 | jwhitlark | it's pretty good. |
| 16:57 | Chousuke | I need to extend gist.el so that I can specify syntax colouring for gists |
| 16:58 | jwhitlark | it's from '97, so a little has changed, but the old code usually still works, there just might be a better way. |
| 16:58 | Chousuke | not a big thing I imagine, but I do not know anything about emacs lisp best practices :) |
| 16:58 | LauJensen | drewr: HEAD now runs the entire demo with PostgreSQL also |
| 16:59 | jwhitlark | other than not using vi, I think you can get away with a lot. :-) |
| 16:59 | Chousuke | jwhitlark: I use viper :P |
| 16:59 | jwhitlark | :-[ |
| 16:59 | jwhitlark | I used to also, though. |
| 16:59 | Chousuke | I prefer vi motions to ctrl-stuff still. |
| 17:00 | lisppaste8 | stuartsierra annotated #84852 "Lazy map with New new, take 4" at http://paste.lisp.org/display/84852#3 |
| 17:00 | jwhitlark | yea, I just found I was causing myself more trouble when I had to use regular vi. It's easier to keep them straight when they're really different. |
| 17:00 | stuartsierra | Now assoc works. |
| 17:01 | Chousuke | I'd like my gist thing to be major-mode sensitive: it would be nice if I could specify the colour coding for diffs to be different from say, clojure-mode buffer gists :) |
| 17:02 | kotarak | stuartsierra: hmmm... I would prefer inheriting from APersistentMap..... It's a pity of that doesn't work. :/ |
| 17:02 | drewr | LauJensen: great, I'll try it |
| 17:03 | drewr | wow, getting c.c.sql to use multiple db connections is a pain |
| 17:04 | drewr | that's what I was hoping clojureql would make easier (among other things) |
| 17:04 | stuartsierra | kotarak: I think the problem is the duplicate definition of assoc in Associative and IPersistentMap. |
| 17:04 | stuartsierra | This might be a newnew bug, it might be a bug in way the interfaces are defined. |
| 17:06 | kotarak | drewr: it should be possible to go for the low-level (with-connection [conn1 *info1*] (with-connection [conn2 *info2*] (execute-sql query1 conn1) (execute-sql query2 conn2))). |
| 17:06 | kotarak | Will work on with-connection to allow multiple connections. |
| 17:06 | kotarak | Similar to with-open. |
| 17:07 | LauJensen | Great point to bring up drewr, thanks |
| 17:09 | drewr | kotarak: I don't see how with-connection can take a vector for its first arg |
| 17:09 | LauJensen | (sql/with-connection [c *conn-info*] |
| 17:09 | LauJensen | (sql/compile-sql stmt c)) |
| 17:13 | drewr | LauJensen: wait, is that c.c.sql or cql? |
| 17:13 | LauJensen | Mr. Drewr: Its all CQL :) |
| 17:14 | drewr | excellent |
| 17:14 | drewr | you're going to get much more pgsql usage :-) |
| 17:15 | LauJensen | You're very very welcome to contribute psql extensions if you feel the urge coming on :) I focus mostly on mysql and kotarak mostly on Derby these days |
| 17:16 | drewr | will-do |
| 17:22 | kotarak | drewr: cql HEAD: multiple connections with with-connection |
| 17:24 | wtetzner_ | is there a way to get the "this" pointer? |
| 17:25 | lisppaste8 | stuartsierra annotated #84852 "Lazy map with New new, finished" at http://paste.lisp.org/display/84852#4 |
| 17:25 | hiredman | wtetzner_: in what context? |
| 17:25 | kotarak | wtetzner_: of what? There is no "this pointer" in clojure. |
| 17:25 | arbscht | there is in newnew, right? |
| 17:25 | wtetzner_ | i'm extending HttpServlet, and i need to be able to reference the servlet |
| 17:26 | hiredman | wtetzner_: using gen-class? |
| 17:26 | wtetzner_ | yeah |
| 17:26 | hiredman | the first arg to all the fn backing methods is this |
| 17:26 | LauJensen | kotarak: Man that was quickly you extended ClojureQL to handle multiple-connections so elegantly! Good job |
| 17:27 | wtetzner_ | hiredman: so i would do (defn -init [this config] ..do stuff) instead of (defn -init [config] ..do stff) |
| 17:27 | LauJensen | Hope you put it to good use drewr :) |
| 17:27 | wtetzner_ | ? |
| 17:28 | stuartsierra | wtetzner_: yes |
| 17:28 | wtetzner_ | thanks |
| 17:32 | hiredman | ,(* 85 2) |
| 17:32 | clojurebot | 170 |
| 17:39 | drewr | kotarak: thanks! |
| 17:45 | drewr | LauJensen, kotarak: what's an example of, say, create-table with a connection arg? |
| 17:46 | drewr | the one I see doesn't take a conn |
| 17:46 | LauJensen | I actually pasted one a little while ago. |
| 17:46 | drewr | or I'm misunderstanding the interface |
| 17:46 | kotarak | (execute-sql (create-table ...) conn) |
| 17:46 | LauJensen | You dont give your query-forming statements a connection arg, they just return a cql-statement which yuo then pass to something like execute-sql |
| 17:46 | drewr | kotarak: you're right; I glossed over that |
| 17:47 | kotarak | ... or combine them to other queries. |
| 17:51 | wtetzner_ | when using gen-class, how would you call a method from the super class? |
| 17:52 | wtetzner_ | in java you just do super.method() |
| 17:52 | cemerick | that newnew usage looks fantastic. So incredibly concise compared to gen-class... |
| 17:53 | Chousuke | it doesn't generate a new class for each call, does it? :P |
| 17:54 | cemerick | No, it behaves like proxy in that way IIUC |
| 17:55 | rhickey | cemerick: right |
| 17:56 | rhickey | but missing bridge method generation as stuartsierra discovered :( - will come |
| 17:56 | rhickey | then he could have derived from APersistentMap like he wanted to |
| 17:57 | cemerick | hrm...bridge methods? |
| 17:57 | rhickey | when you have covariant returns you need to gen a method for one that calls the other |
| 17:57 | cemerick | ah |
| 17:58 | rhickey | Associative assoc(...) and IPersistentMap assoc(...) |
| 17:58 | rhickey | proxy does this, but new new not yet |
| 18:00 | cemerick | rhickey: just how much more complicated would things get if arg-ful super ctors were added into the mix? (Just curious, the barbarians aren't at the gate yet ;-) ) |
| 18:02 | rhickey | cemerick: right now, I can describe newnew without talking about constructors at all |
| 18:02 | kotarak | wtetzner_: you have to a do (gen-class .... :exposes-methods {someMethod superSomeMethod}) Then you can do (.superSomeMethod foo) to get the method of the super class |
| 18:02 | wtetzner_ | kotarak: thanks |
| 18:03 | rhickey | and, if I let you name your new new classes when AOT, you can use them to write what would be "abstract supers" by simply not closing over anything |
| 18:04 | rhickey | if I let you call supers with ctors args, you'll want to write classes with ctor args, you'll need ctors, there will have to be a relationaship between ctors and closed overs and you'll probably need fields explicitly |
| 18:04 | rhickey | eventually all of java leaks in |
| 18:05 | cemerick | we better find a strong door. |
| 18:06 | rhickey | right now new new is sort of an expansion of fn/closures, where the 'code' part of lambda can have multiple named parts (methods). That's it, no fields, no ctors etc |
| 18:06 | cemerick | I'm sure some enterprising fellow will come up with a gen-class newnew frankenstein that will satisfy those who happen to need to call ctors with args... |
| 18:06 | cemerick | (and all of the rest of the java morass) |
| 18:07 | rhickey | so, I'm emphasizing what is Clojure the language's capabilities directly. That's not to say at some point calling super ctors with arg might be an interop feature not part of the semantics of Clojure |
| 18:08 | rhickey | but what I want is a recipe for people to write high-performance data structures like CLojure's in Clojure, and what I've defined in new new (+ def/gen-interface) is all you need |
| 18:08 | hiredman | will it continued to be called new new |
| 18:09 | Chousuke | it's "new". it's called "new new" because it's new :P |
| 18:09 | rhickey | hiredman: I don't know, when I think about its use as a Clojure feature for new code I think maybe overloading new, which is otherwise a host-interop thing, might be a bad idea |
| 18:10 | jwhitlark | new**2? new^2? new v2? last sounds like a car... ;-) |
| 18:10 | cemerick | it's nice to have another special form, or reserved short name |
| 18:10 | rhickey | so, renaming new new to something else is still an open question |
| 18:10 | rhickey | obj |
| 18:10 | cemerick | nice to NOT have another special form, I mean |
| 18:10 | Chousuke | multi-lambda :> |
| 18:10 | rhickey | cemerick: yeah, but overloading when not appropriate is no bargain |
| 18:10 | hiredman | we could really cheese the old lisps by calling it lambda :P |
| 18:11 | Chousuke | or pick another greek letter. |
| 18:11 | rhickey | it's a really interesting thing to think about what new new does, and what lambda does, and the true nature of closure |
| 18:12 | rhickey | when written in terms of new new, it seems obvious lambdas aren't primitive but a special case |
| 18:12 | hiredman | α is nice if you think of it as first thing |
| 18:13 | rhickey | they certainly have composite behavior - creating code, capturing environment, instantiating a callable 'thing' |
| 18:13 | cemerick | if it were possible, I'd much rather have new new become "new" and old new become "jnew" or something, especially since no one uses the old new (Foo. has been idiomatic for some time now). |
| 18:14 | rhickey | cemerick: in any case, another special form is likely. renaming old new to jnew is breaking |
| 18:14 | rhickey | so, candidate welcome |
| 18:14 | rhickey | cadidates |
| 18:14 | rhickey | candidates |
| 18:15 | hiredman | α |
| 18:15 | rhickey | hiredman: bzzzt |
| 18:15 | cemerick | is breaking (likely old) source that uses (new Foo arg1 arg2) a problem at this point? |
| 18:15 | hiredman | :/ |
| 18:15 | rhickey | ascii please |
| 18:15 | rhickey | cemerick: I think there are people that prefer to write (new classname ...) and still do |
| 18:15 | cemerick | that's interesting |
| 18:16 | cemerick | I'd still vote for breaking. newnew is going to be far more "core" to clojure than oldnew, especially as it becomes multiplatform. |
| 18:16 | hiredman | I still see alot of using . directly |
| 18:16 | rhickey | anyway, breaking changes are a last resort moving forward |
| 18:17 | Chousuke | provide? too plain? :P |
| 18:17 | rhickey | cemerick: but new doesn't describe newnew particularly well either |
| 18:17 | rhickey | not any better than lambda |
| 18:17 | cemerick | ho-ho, that'd rile some people |
| 18:17 | cemerick | I'm not sure we'll find anything that does better than new. |
| 18:18 | cemerick | zen? ;-) |
| 18:21 | fsodomka | prototype? |
| 18:22 | fsodomka | template |
| 18:23 | hiredman | it generates a a thing when you call it, and the the thing it generates isn't a thing used to create other things |
| 18:24 | cemerick | kappa (as in, preceding lambda?) |
| 18:24 | cemerick | no one would ever get it |
| 18:25 | fsodomka | instance - sample - representative :-) |
| 18:25 | Chousuke | it makes me think of the japanese folk tale goblin thing :P |
| 18:25 | rhickey | it does three things: captures bindings, defines named bits of code, and instantiates an object through which you can get to that code |
| 18:25 | cemerick | box? |
| 18:25 | rhickey | cemerick: what's after lambda? |
| 18:25 | cemerick | mu |
| 18:25 | clojurebot | defmulti doc is ugly |
| 18:25 | rhickey | reify |
| 18:25 | cemerick | which isn't bad |
| 18:26 | dreish | Sounds like something you do to a checkers piece after it reaches the other side of the board. |
| 18:27 | fsodomka | make ? |
| 18:27 | rhickey | dreish: that's rexify |
| 18:28 | dreish | rhickey: Ah, thanks. I was close. |
| 18:28 | hiredman | ,(reify [] (toString [] "foo")) |
| 18:28 | clojurebot | #<sandbox$eval$obj__3333 foo> |
| 18:29 | hiredman | ,(reify [IDeref] (deref [] "foo")) |
| 18:29 | clojurebot | #<sandbox$eval$obj__3339@1d6fad7: "foo"> |
| 18:29 | fsodomka | create, incarnate, manifest |
| 18:29 | fsodomka | objectify :-) |
| 18:29 | hiredman | reify makes sense, but I had to pull up a wikipedia page for it did |
| 18:29 | fsodomka | entify :-) |
| 18:29 | fsodomka | cool words in thesaurus :-) |
| 18:30 | hiredman | before |
| 18:30 | Chousuke | hiredman: that's just a good thing. |
| 18:30 | hiredman | man, I've leaving words and syllables while typing all day |
| 18:30 | hiredman | I've been |
| 18:31 | hiredman | out |
| 18:31 | hiredman | goodness |
| 18:31 | Chousuke | hiredman: if you have no clue what it does, that leaves little room for misunderstanding :) |
| 18:31 | Chousuke | worse than ignorance is thinking you know what you're doing :P |
| 18:31 | Chousuke | (when you don't) |
| 18:32 | cemerick | mu, make, and reify all seem decent |
| 18:33 | cemerick | nothing super-inspiring, though |
| 18:35 | fsodomka | if obj as object |
| 18:35 | fsodomka | what other words for object? |
| 18:35 | fsodomka | item? entity? |
| 18:36 | fsodomka | should it be noun or a verb? |
| 18:36 | fsodomka | instantiate? |
| 18:36 | hiredman | I think a verb is good |
| 18:37 | Chousuke | fsodomka: instantiate is overloaded |
| 18:37 | Chousuke | and smells of OOP |
| 18:41 | fsodomka | construct? |
| 18:41 | fsodomka | originate? |
| 18:42 | fsodomka | initiate? |
| 18:42 | ataggart | forge |
| 18:43 | ataggart | ooh, no: spawn |
| 18:43 | cemerick | that's thread-related |
| 18:44 | ataggart | bah |
| 18:45 | fsodomka | draft, establish, form |
| 18:47 | ataggart | summon |
| 18:47 | fsodomka | init and make are my favorite so far |
| 18:48 | hiredman | http://en.wikipedia.org/wiki/Reification_(computer_science) |
| 18:49 | hiredman | if a) rhickey likes reify b) and he intends to construct to be used for reification of interfaces then reify seems good |
| 18:49 | hiredman | ugh |
| 18:49 | hiredman | and he intends the construct |
| 18:50 | cemerick | well, that's hard to argue with: "The etymology of the term reification is from Latin res (thing) + facere (to make)" |
| 18:54 | cemerick | it isn't actually reification, though, is it? newnew doesn't make anything newly available that was previously an implementation detail or otherwise abstracted away... |
| 18:55 | cemerick | (I'm comparing to reification of stack frames and reified types vs. erasure, FWIW) |
| 18:57 | hiredman | it depends on how you look at new new |
| 18:58 | hiredman | if you look at it as the cornerstone of cinc then it is reifying, allowing the implementation of things that where implemented in java in clojure |
| 18:59 | hiredman | pulling stuff up from java into clojure |
| 18:59 | ataggart | plus it's a cool word |
| 19:00 | hiredman | also if you look at new new as implementing fn teh code generation and closing over of fn become accessable |
| 19:00 | hiredman | on the other hand if you look at it as just a replacement for proxy, then I guess not |
| 19:02 | cemerick | but it's not making the code generation accessible, it's just abstracting it in a different way... |
| 19:04 | hiredman | I have not looked at the implementation of new new, but my understanding is new new methods are not backed by fns |
| 20:03 | rhickey | cemerick: it reifies an interface, which isn't directly instantiable |
| 20:54 | wtetzner | datum? |
| 20:54 | wtetzner | (datum [] (toString [] "hello")) |
| 21:23 | MarkVolkmann | Is there a reason why RetryEx in LockingTransaction.java extends Error instead of Exception? |
| 21:34 | cemerick | MarkVolkmann: probably so that retries cut through typical (catch Exception e ...) forms. |
| 21:38 | MarkVolkmann | It just struck me as unusual since the javadoc for Error says "indicates serious problems that a reasonable application should not try to catch". |
| 21:53 | ataggart | Yeah, and Exceptions need to be explicitly handled, except when the child of Exception happens to be RuntimeException. |
| 22:01 | rhickey | if you catch retsy exceptions in your application code you will mess up the STM |
| 22:13 | ataggart | My comment was meant to be tongue-in-cheek |
| 22:14 | adm | need help |
| 22:34 | bpattison | what's the name of the function to list out all of the member functions of a java class? |
| 22:36 | wtetzner | ,(seq (.getDeclaredMethods (class :item))) |
| 22:36 | clojurebot | (#<Method public java.lang.Object clojure.lang.Keyword.applyTo(clojure.lang.ISeq) throws java.lang.Exception> #<Method public java.lang.String clojure.lang.Keyword.getNamespace()> #<Method public java.lang.Object clojure.lang.Keyword.call() throws java.lang.Exception> #<Method public java.lang.Object clojure.lang.Keyword.throwArity()> #<Method public java.lang.Object clojure.lang.Keyword.invoke() throws java.lang.Exceptio |
| 22:36 | wtetzner | ,(map #(str %) (.getDeclaredMethods (class :item))) |
| 22:36 | clojurebot | ("public java.lang.Object clojure.lang.Keyword.applyTo(clojure.lang.ISeq) throws java.lang.Exception" "public java.lang.String clojure.lang.Keyword.getNamespace()" "public java.lang.Object clojure.lang.Keyword.call() throws java.lang.Exception" "public java.lang.Object clojure.lang.Keyword.throwArity()" "public java.lang.Object clojure.lang.Keyword.invoke() throws java.lang.Exception" "public java.lang.Object clojure.lang |
| 22:38 | wtetzner | ,(take 2 (map #(.getName %) (.getDeclaredMethods (class :item)))) |
| 22:38 | clojurebot | ("applyTo" "getNamespace") |
| 22:39 | adm | I plan to develope a web app prob with some framework(with providing minial support, since apart from web server plan to write other things like dispatch, html generation etc) in which I need to talk to a process talking on socket |
| 22:39 | adm | how do I do that> |
| 22:39 | adm | ? |
| 22:40 | wtetzner | adm: you could try compojure |
| 22:40 | wtetzner | http://github.com/weavejester/compojure/tree/master |
| 22:40 | wtetzner | and the wiki is here: http://en.wikibooks.org/wiki/Compojure |
| 22:42 | wtetzner | adm: for sockets, just use the java socket stuff |
| 22:42 | wtetzner | http://www.javaworld.com/jw-12-1996/jw-12-sockets.html |
| 22:42 | adm | what about the other thing? |
| 22:43 | adm | oh, ok |
| 22:43 | adm | wtetzner: thanks |
| 23:24 | Jomyoot | is there guide to writing unit tests with clojure? |
| 23:24 | Jomyoot | for ex. i want to unit test my rails app with clojure |
| 23:27 | drewolson | ssh #ubuntu |
| 23:28 | drewolson | whoops, sorry :) |
| 23:32 | Jomyoot | ooh |
| 23:33 | Jomyoot | it would be cool if I could tap into a long-running clojure process and start querying its internal states |
| 23:36 | hiredman | it should be pretty easy |
| 23:54 | Carkh | ~def *warn-on-reflection* |
| 23:54 | clojurebot | excusez-moi |
| 23:54 | Carkh | hum how did that work again hiredman ? |
| 23:57 | hiredman | ,(doc *warn-on-reflection*) |
| 23:57 | clojurebot | "; When set to true, the compiler will emit warnings when reflection is needed to resolve Java method calls or field accesses. Defaults to false." |
| 23:57 | Carkh | right, but i was looking for the source code |
| 23:58 | Carkh | though i won't find it it seems |
| 23:58 | Carkh | anyways i'm trying to set a *deployed* global var |
| 23:58 | Carkh | the software will act differently if it is true or not |
| 23:59 | Carkh | so i wanted to be able to (set! *deployed* false) |
| 23:59 | Carkh | like warn-on-reflection |
| 23:59 | Carkh | but it does not work =/ |
| 23:59 | hiredman | ,(doc binding) |
| 23:59 | clojurebot | "([bindings & body]); binding => var-symbol init-expr Creates new bindings for the (already-existing) vars, with the supplied initial values, executes the exprs in an implicit do, then re-establishes the bindings that existed before." |
| 23:59 | hiredman | ,(doc set!) |
| 23:59 | clojurebot | "/;nil; " |
| 23:59 | hiredman | bah |