2009-08-06
| 00:00 | hiredman | anyway, read the docs for set! on the special forms page |
| 00:00 | Carkh | binding would require that i go all over the place and establish that binding |
| 00:00 | Carkh | i did |
| 00:00 | Carkh | looks like i first nit to use bindings, then i can set! |
| 00:01 | hiredman | http://clojure.org/vars#set |
| 00:02 | Carkh | ohwell i'll make it an atom and a function to check the value |
| 00:02 | hiredman | :( |
| 00:02 | hiredman | global state |
| 00:02 | Carkh | well the use case it pretty good |
| 00:03 | Carkh | i would use conditional compilation in a static language for this |
| 00:09 | Carkh | AOT compilation is slowwww |
| 00:10 | Carkh | back to the c++ age |
| 00:11 | hiredman | really? |
| 00:11 | Carkh | not _that_ bad ... but yes 1:30 min to build a fairly small web app |
| 00:13 | Carkh | and 3sec to just load the source files and start the application from emacs |
| 00:13 | hiredman | I imagine most of that is jvm start up time |
| 00:14 | Carkh | i first start the jvm, then compile the file that starts the app |
| 00:14 | Carkh | only the second part is 3 secs |
| 00:15 | Carkh | anyways no big deal, that's not like i'm AOT compiling every minute |
| 00:19 | Carkh | i'm within a couple days of deploying my second "commercial" clojure project to a customer |
| 00:19 | Carkh | started quite a while back .. still using pre 1.0 clojure |
| 00:25 | hiredman | lisppaste8: url |
| 00:25 | lisppaste8 | To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste. |
| 01:12 | mebaran151_ | Carkh, have you tried using something like nailgun to keep the jvm live |
| 01:12 | mebaran151_ | I used to use it for dev'ing with Jruby |
| 01:15 | Carkh | no i didn't |
| 01:15 | Carkh | i'm not worried about the start times ... i usually develop with the repl ... |
| 01:30 | mudphone | does anyone know how to give the compiler a type hint for byte[] |
| 01:31 | hiredman | #^bytes |
| 01:31 | mudphone | hiredman:thanks you rock |
| 01:32 | hiredman | so they tell me |
| 02:05 | mudphone | hiredman: who are you that are so wise in the ways of science? |
| 02:06 | hiredman | some dude |
| 02:14 | jwhitlark | so, (org.enclojure.repl.main/run-repl-server 11345) works in the repl, but not as part of a script. I get the error: Caused by: java.lang.IllegalArgumentException: No matching method: run-repl-server |
| 02:15 | jwhitlark | anyone seen something like that before? |
| 02:15 | hiredman | hmmm |
| 02:15 | jwhitlark | I'd have thought it was a classpath problem, but it's finding org.enclojure.repl.main without problems. |
| 02:15 | jwhitlark | java -cp $CLOJURE_DIR/*:$CLOJURE_JAR \ |
| 02:15 | jwhitlark | jline.ConsoleRunner clojure.lang.Repl |
| 02:15 | jwhitlark | That's my bash script for the repl... |
| 02:16 | jwhitlark | scriptname=$1 |
| 02:16 | jwhitlark | java -cp $CLOJURE_DIR/*: clojure.lang.Script $scriptname -- $* |
| 02:16 | Jomyoot | we need an all-inclusive web-framework like rails? |
| 02:16 | Jomyoot | but all written with clojure |
| 02:16 | hiredman | use clojure.main instead of clojure.lang.Repl |
| 02:16 | jwhitlark | and that's mine for running a script. I don't see any difference. |
| 02:16 | jwhitlark | k. just a sec. |
| 02:16 | hiredman | I doubt that it'll fix things |
| 02:16 | hiredman | but clojure.lang.Repl is depricated |
| 02:17 | hiredman | and Script |
| 02:17 | jwhitlark | clojure.main for both? |
| 02:17 | hiredman | yep |
| 02:17 | hiredman | java clojure.main --help will tell you all about it |
| 02:19 | hiredman | do you know what kind of number the method takes |
| 02:19 | hiredman | ? |
| 02:19 | jwhitlark | should be just an int, it's a port # |
| 02:20 | jwhitlark | oh! That's interesting, now it's failing in the repl too. |
| 02:20 | hiredman | maybe try wrapping it in (int …) |
| 02:20 | hiredman | are you sure the method only takes one parameter? |
| 02:22 | jwhitlark | copied it right out of: http://www.enclojure.org/REPLSupport |
| 02:22 | jwhitlark | one page down. |
| 02:22 | jwhitlark | interesting. it worked for me *once* in slime, and that's it. |
| 02:23 | hiredman | are you using enclojure/ |
| 02:23 | hiredman | ? |
| 02:23 | jwhitlark | trying to. |
| 02:23 | jwhitlark | oh, no. not for an ide. |
| 02:24 | jwhitlark | just to embed a repl in an application. I asked earlier today if http://clojure101.blogspot.com/2009/05/creating-clojure-repl-in-your.html was still the way to go and was told it was still good to go. |
| 02:26 | hiredman | I think the problem is the enclojure namespace is gen-classed |
| 02:27 | hiredman | so clojure is treating a reference to it like that as a static method call |
| 02:27 | hiredman | maybe if you (require '[yadda.yadda :as enclojure]) |
| 02:28 | hiredman | and (enclojure/something-something 43242) |
| 02:30 | jwhitlark | java.lang.Exception: lib names inside prefix lists must not contain periods |
| 02:30 | hiredman | http://gist.github.com/163140 makes a repl you can telnet to |
| 02:30 | jwhitlark | oh! |
| 02:31 | jwhitlark | that's what I wanted. |
| 02:31 | jwhitlark | and it works just fine. |
| 02:32 | jwhitlark | thanks for the help. |
| 02:32 | hiredman | sure |
| 02:34 | jwhitlark | I saw somewhere that you could configure slime to connect to an application, but that's a task for another day. |
| 03:27 | Anniepoo | is there a jira for Clojure? |
| 03:32 | LauJensen | From Google definitions: "Jira is a Thai given name. Notable people bearing the name include: * Jira Boonpojanasoontorn, Justice of the Constitutional Court" |
| 03:32 | Anniepoo | LOL |
| 03:32 | LauJensen | So in a sense, yes there is JiraAnniepoo |
| 03:32 | Anniepoo | ok, more to the point, I've found a small bug in clojure.contrib |
| 03:32 | mudphone | these aren't the droids you're looking for |
| 03:32 | Anniepoo | where should I report it |
| 03:32 | LauJensen | these arent the droids? |
| 03:33 | LauJensen | Anyway - I think all project details are handled on Assembla now, you should report there |
| 03:33 | Anniepoo | ok |
| 03:34 | Anniepoo | what and where is an Assembla? |
| 03:34 | LauJensen | ~assembla |
| 03:34 | clojurebot | assembla is http://www.assembla.com/spaces/clojure |
| 03:34 | Anniepoo | Assembla is what system pah-rogramma's use in gah-ga |
| 03:34 | Anniepoo | thanks |
| 03:34 | LauJensen | np |
| 03:37 | Anniepoo | I submit a 'ticket'? |
| 03:38 | jdz | well, are you sure it's a bug? |
| 03:38 | jdz | have you asked here or in the mailing list? |
| 03:38 | Anniepoo | ok, there's a note to say put it on the mailing list first |
| 03:38 | Anniepoo | I'll do that |
| 03:38 | Anniepoo | I'm quite sure it's a bug |
| 03:38 | LauJensen | Anniepoo: Yes, a Support Ticket |
| 03:39 | mebaran151_ | what's the bug? |
| 03:39 | lisppaste8 | Anniepoo pasted "untitled" at http://paste.lisp.org/display/84890 |
| 03:39 | Anniepoo | it's putting Unix newlines in the file in this code |
| 03:40 | Anniepoo | when run on XP Tablet |
| 03:40 | Anniepoo | I'll try to characterize it better before submitting |
| 03:40 | LauJensen | Best to demonstrate by a very simple case :) |
| 03:41 | Anniepoo | that's what I meant |
| 03:41 | LauJensen | Ok |
| 03:45 | jdz | ye, it's right there, the newline function |
| 03:46 | jdz | although i think outputting DOS line endings is a braindamage |
| 03:47 | jdz | and if you want to do it, you just use print and add whatever you want at the end |
| 03:47 | Anniepoo | the newline function puts out a newline |
| 03:47 | Anniepoo | ,(doc newline) |
| 03:47 | clojurebot | "([]); Writes a newline to the output stream that is the current value of *out*" |
| 03:47 | Anniepoo | sorry, that's not enlightening me |
| 03:47 | jdz | ,(int \newline) |
| 03:47 | clojurebot | 10 |
| 03:48 | jdz | newline function outputs this character |
| 03:48 | Anniepoo | and I'm not a huge whoppign fan of DOS line endings either |
| 03:48 | Anniepoo | yah, that's excluding 2/3rds of the world |
| 03:49 | tomoj | most of those people aren't coding in clojure :P |
| 03:49 | Anniepoo | and if you make it difficult for them to do so they will continue to not do so |
| 03:49 | jdz | Anniepoo: your calculations are wrong |
| 03:49 | Anniepoo | ok, if you count by users it's 95% or something |
| 03:49 | jdz | nothing close to 2/3rds of computer users read plain text files |
| 03:49 | jdz | in notepad |
| 03:50 | jdz | all other text editors can deal with single newline character |
| 03:51 | Anniepoo | but 100% of C# input streams are confused by the things |
| 03:51 | mebaran151_ | I think the JVM makes it simple to figure these things out... |
| 03:51 | mebaran151_ | what kind of newline |
| 03:51 | tomoj | I see java uses a system property to decide what the line separator is |
| 03:51 | mebaran151_ | yeah |
| 03:51 | jdz | Anniepoo: using DOS line endings is not gonna fix the problem you know |
| 03:51 | mebaran151_ | exactly |
| 03:51 | Anniepoo | cause I'm writing a file to be interpreted by a program |
| 03:52 | Anniepoo | and at the very least, *I* need to be able to read the thing without manually changing the line endings |
| 03:52 | jdz | Anniepoo: so you should output your file in a format that is expected by the other program |
| 03:52 | Anniepoo | ok, it expects dos line endings |
| 03:53 | jdz | Anniepoo: and you should not expect that some function will figure out what the other program expects magically |
| 03:53 | tomoj | PrintStream.println will use DOS endings, though |
| 03:53 | tomoj | does seem a bit strange that clojure's println isn't consistent with java's |
| 03:53 | Anniepoo | but I do expect it to put out the line endings that system.properties says to use |
| 03:53 | jdz | Anniepoo: what i'm trying to tell you is that if you write your program, and then somebody runs it on, say, OSX, the output will be wrong, anyway |
| 03:54 | tomoj | not if it uses line.separator... |
| 03:54 | tomoj | oh, yes, I see |
| 03:55 | tomoj | so the solution in that case is to specifically ask for dos endings, I suppose |
| 03:55 | jdz | yes |
| 03:55 | mebaran151_ | sigh, the line ending wars |
| 03:55 | tomoj | is rebinding newline a bad way to do that |
| 03:55 | tomoj | just curious |
| 03:56 | jdz | so the real problem is that pr*l?n functions don't respect the system property mentioned above |
| 03:58 | Anniepoo | I'm with tomoj, I think the correct behavior here is to respect line.separator |
| 03:58 | jdz | Anniepoo: that would be the correct behaviour of println function, but you should not use it |
| 03:59 | Anniepoo | so yes, my program will break on OSX only if the C# program it's interacting with doesn't respect the system line separator |
| 03:59 | Anniepoo | and, while I wrote the program it's interacting with, it's the only thing I've ever written in C#, I have no idea |
| 03:59 | jdz | and, btw, i'm pretty sure C# can deal with single-character line endings with no problems |
| 03:59 | Anniepoo | what it does with line endings |
| 04:00 | Anniepoo | yah, I'm actually unit testing, and the test is failing. |
| 04:00 | jdz | relying on magic defaults in cross-platform cross-language communication is a way of asking for big trouble |
| 04:02 | Anniepoo | it's not as bad as 'cross platform means fsck off if you're not a cool linux user' |
| 04:02 | Anniepoo | certainly the different line endings are a stupidity that needn't have happened |
| 04:07 | LauJensen | Its quite amazing that in 1980's we were anticipating flying cars etc in the new millenium, and here we are in 2009 discussing newline formats.. |
| 04:08 | Anniepoo | I referred to EBCDIC the other day 8cD |
| 04:09 | Anniepoo | hey, get on a network hardware forum, you'll hear about mark and space all the time |
| 04:09 | Anniepoo | the terms are from telegraphy |
| 04:09 | Anniepoo | soon after telegraphy was invented, they realized people could send it faster than someone could copy it down |
| 04:10 | Anniepoo | so they made a clockwork gizmo that pulled paper tape through a holder |
| 04:10 | Anniepoo | and attached a goose quill pen to the sounder of a telegraph |
| 04:10 | Anniepoo | down is mark, up is space |
| 04:10 | clojurebot | mark is 1 |
| 04:10 | mebaran151_ | mark is 1? |
| 04:10 | Anniepoo | ah, come on! I bet this is the first time we've discussed mark on this forum! |
| 04:11 | mebaran151_ | no I was just confused about the clojurebot |
| 04:11 | mebaran151_ | I want to know what mark it thinks is 1 |
| 04:11 | Anniepoo | mark wrote a cool clojure program (see if it does it again) |
| 04:11 | Anniepoo | so did marky mark |
| 04:12 | mebaran151_ | I wonder if we still use any of the old telegraph lines, repurposed for digital communication |
| 04:12 | mebaran151_ | esp the the cross the atlantic ones |
| 04:12 | Anniepoo | does it mean Mark Mark, the lead rapper of Marky Mark and the Funky Bunch, or Marky Mark the wrestler |
| 04:13 | mebaran151_ | this beginning to resemble a Markov |
| 04:13 | mebaran151_ | chain |
| 04:13 | Anniepoo | I believe they've all been replaced with more modern stuff |
| 04:13 | mebaran151 | yeah, that's too bad |
| 04:13 | Anniepoo | but the hard part of laying a cable is laying the first one |
| 04:13 | wtetzner | what is mark |
| 04:13 | Anniepoo | so in a sense we still use them |
| 04:13 | wtetzner | mark is |
| 04:13 | wtetzner | hmm |
| 04:14 | Anniepoo | just as there's probably none of the original rails, spikes, or ties from the transcontinental RR still out there |
| 04:14 | Anniepoo | but the track is still there. |
| 04:15 | Anniepoo | many houses in San Francisco were converted to electric light after the quake, |
| 04:15 | Anniepoo | and have the old tube and post wiring still in them |
| 04:16 | mebaran151 | gotta avoid the sea monsters |
| 04:16 | mebaran151 | well the clojurebot has declare mark is 1 |
| 04:17 | Anniepoo | I was dating a guy who was a diver for a while. He had a video of an octopus attacking the ROV he was operating |
| 04:20 | wtetzner | clojurebot: mark |
| 04:20 | clojurebot | mark is 1 |
| 04:20 | wtetzner | clojurebot: XML |
| 04:20 | clojurebot | XML is like violence; if it doesn't solve your problems, you're not using enough of it. |
| 04:21 | Anniepoo | clojurebot: space |
| 04:21 | clojurebot | namespaces are (more or less, Chouser) java packages. they look like foo.bar; and corresponde to a directory foo/ containg a file bar.clj in your classpath. the namespace declaration in bar.clj would like like (ns foo.bar). Do not try to use single segment namespaces. a single segment namespace is a namespace without a period in it |
| 04:22 | Anniepoo | anybody know how clojurebot works? |
| 04:22 | wtetzner | clojurebot: math |
| 04:22 | clojurebot | math is hard. |
| 04:22 | wtetzner | clojurebot: brain dump |
| 04:22 | clojurebot | brain dump is http://clj.thelastcitadel.com/clojurebot |
| 04:23 | wtetzner | Anniepoo: look here ^ |
| 04:23 | Anniepoo | ah, fun |
| 04:31 | Anniepoo | I'm about to write my first loop because I can't find a good map/reduce form for this |
| 04:31 | Anniepoo | I have two seq's a and b. I want to create a modified a by looking through the elements of a |
| 04:32 | LauJensen | ~paste |
| 04:32 | clojurebot | lisppaste8, url |
| 04:32 | lisppaste8 | To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste. |
| 04:38 | lisppaste8 | Anniepoo pasted "untitled" at http://paste.lisp.org/display/84892 |
| 04:42 | mebaran151 | there's usually a better way |
| 04:42 | mebaran151 | are a and b the same length? |
| 04:42 | eevar2 | anniepoo: (defn myfun [pred foo a b] (let [filtered-a (filter pred a)] (map foo a b))))))) .--- or something? |
| 04:43 | Anniepoo | no, a and b are NOT the same length |
| 04:43 | eevar2 | probably can't use map like that, but ;) |
| 04:43 | mebaran151 | there is almost always a map reduce form that is better than a loop recur form |
| 04:43 | mebaran151 | I assume you have something function of b that you want to apply to a |
| 04:43 | Chousuke | (fn f [foo pred [a & as] [b & bs]] (lazy-seq (when a (cons (if (pred a) (foo a b) a) (f as bs))))) |
| 04:43 | Anniepoo | yes |
| 04:44 | Chousuke | somthing like that? |
| 04:44 | Anniepoo | yes mebaran |
| 04:44 | eevar2 | ,(doc map) |
| 04:44 | clojurebot | "([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls]); Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. Function f should accept number-of-colls arguments." |
| 04:44 | mebaran151 | so if pred a is true apply a to b |
| 04:44 | mebaran151 | the way I'd do it |
| 04:44 | mebaran151 | first match up all your a and b's |
| 04:45 | Chousuke | hmm, right |
| 04:45 | mebaran151 | then filter by a |
| 04:45 | mebaran151 | (which will probably be something like (first blah) |
| 04:45 | Anniepoo | yes, but Chousuke, isn't that tail recursion? |
| 04:45 | Chousuke | Anniepoo: it's a lazy seq |
| 04:45 | mebaran151 | then finally with the filtered form apply your foo |
| 04:46 | Chousuke | Anniepoo: they *need* to be done using recursion, and take care not to blow up the stack |
| 04:46 | mebaran151 | then you get all your laziness, which is a huge boon |
| 04:46 | Chousuke | but hmm |
| 04:46 | mebaran151 | so how do you match up a and b |
| 04:46 | mebaran151 | that's a little confusing |
| 04:46 | mebaran151 | does a always go with the next b |
| 04:46 | mebaran151 | so if a is at place 0 you want b to be 1? |
| 04:47 | Anniepoo | suppose you have a class of students who always line up in the same order |
| 04:47 | mebaran151 | or do you want to use b like a stack of operands to be applied to a successive line of a's |
| 04:47 | Anniepoo | what mebaran said |
| 04:47 | mebaran151 | so on your filtered a's, you'd take b0 b1 b2 |
| 04:48 | mebaran151 | oh that's pretty simple |
| 04:48 | mebaran151 | first filter a |
| 04:48 | Anniepoo | sure, but I need to have the unfiltered a's back at the end |
| 04:48 | mebaran151 | what do you mean? |
| 04:48 | Anniepoo | suppose you're working on a farm |
| 04:49 | Anniepoo | the farmer tells you to go paint the fenceposts that aren't currently painted |
| 04:49 | mebaran151 | is this for some job queueing system |
| 04:49 | Anniepoo | (ok, ignroe the farmer) I have a list of objects in my system |
| 04:49 | mebaran151 | yeah |
| 04:50 | mebaran151 | so why do the unfiltered ones need to go to the back |
| 04:50 | mebaran151 | I mean you can get that |
| 04:50 | Anniepoo | no, they're ordered, don't rearrange them |
| 04:50 | mebaran151 | okay |
| 04:50 | Anniepoo | these objects represent objects on another system |
| 04:50 | mebaran151 | so you need to record their position |
| 04:50 | mebaran151 | probably |
| 04:51 | mebaran151 | maybe as a tuple |
| 04:51 | mebaran151 | [a pos-a] |
| 04:51 | Anniepoo | those that are dirty, I add their info to some list |
| 04:52 | Anniepoo | run some external process that does the transfer |
| 04:52 | Anniepoo | and it returns the ID's I use to reference them on the other system |
| 04:52 | mebaran151 | so why can't you filter by a |
| 04:52 | mebaran151 | then map over b |
| 04:53 | Anniepoo | because at the end, I need to preserve the ordering on my end |
| 04:53 | mebaran151 | keep an index with each a |
| 04:53 | mebaran151 | so first map each a to its index |
| 04:53 | mebaran151 | in a vector |
| 04:53 | mebaran151 | then filter that vector by its first element |
| 04:54 | Anniepoo | I need to (assoc ) the ones I updated to get the other system's UUID into their map |
| 04:54 | mebaran151 | then map b to apply to the first element of each of yours a's and remap it back in |
| 04:54 | Anniepoo | then sort |
| 04:54 | mebaran151 | actually, this might be a perfect use for metadata |
| 04:54 | mebaran151 | to maintain your position information |
| 04:55 | mebaran151 | assuming a is some sort of clojure thing |
| 04:55 | mebaran151 | so you have a bunch of a's whose uuid's you need to get |
| 04:55 | Anniepoo | oh, sure, the a's are maps. It's a GUI editor |
| 04:56 | mebaran151 | but some a's come with uuid's already |
| 04:56 | Anniepoo | yes |
| 04:56 | Anniepoo | some already have UUID's |
| 04:57 | Anniepoo | and the spawned process takes some info from the ones that need UUID's |
| 04:57 | Anniepoo | as lines in a file |
| 04:57 | mebaran151 | so why is mainting order so important? |
| 04:57 | Anniepoo | and returns lines in a file with the UUID |
| 04:58 | Anniepoo | because that establishes Z order for the objects in the virtual world that is the other end |
| 04:58 | mebaran151 | it always seems ugly and imperative to rely on absolute ordering |
| 04:58 | Anniepoo | yes, maybe that's my problem |
| 04:58 | Chousuke | http://gist.github.com/163202 |
| 04:58 | mebaran151 | this order attribute sounds like it belong as another attribute in your map |
| 04:58 | Anniepoo | I shouldn't be depending on it |
| 04:59 | mebaran151 | well Chousuke just made the right loop |
| 05:00 | Anniepoo | ,(doc gen) |
| 05:00 | clojurebot | "/;nil; " |
| 05:00 | Anniepoo | what's gen? |
| 05:00 | Chousuke | gen is the name of the fn |
| 05:00 | Anniepoo | ah, I see |
| 05:01 | mebaran151 | I still think we could be a little more functional than rolling our own lazy-seqs |
| 05:01 | mebaran151 | lazy-seqs are always a little more brittle |
| 05:01 | mebaran151 | for this sort of thing, I think you can map and reduce your way out yet |
| 05:01 | Chousuke | hmm |
| 05:01 | mebaran151 | Anniepoo, what do you have recording the position in the map? |
| 05:01 | mebaran151 | *have against |
| 05:02 | mebaran151 | the position seems to be an instrinsic attribute of a: maybe it deserves its own key |
| 05:02 | Anniepoo | yes, I'm beginning to think so |
| 05:02 | mebaran151 | that way you could even uses sets if you wanted and not lose any data, or resort them and always have a way out |
| 05:02 | Chousuke | ,(for [a [1 2 3 4] b [1 2 3 4] :when (even? a)] [a b]) |
| 05:02 | clojurebot | ([2 1] [2 2] [2 3] [2 4] [4 1] [4 2] [4 3] [4 4]) |
| 05:02 | Anniepoo | though it's nice that it stays a compact set |
| 05:02 | mebaran151 | then you have a simple path for filtering map and reducing |
| 05:03 | mebaran151 | compact set? |
| 05:04 | Anniepoo | yes, the objects are 'stacked' in 3D in the virtual world that's at the other end |
| 05:04 | Anniepoo | so a3 is always up a constant amount from a2 |
| 05:04 | Anniepoo | if I delete a2 in the set a3 should move down |
| 05:05 | mebaran151 | that wouldn't be true though in a vector either (they don't automagically compact themselves) |
| 05:06 | Anniepoo | first/rest does |
| 05:06 | mebaran151 | I might be lying :) |
| 05:06 | Anniepoo | the data's really a list, not a set |
| 05:06 | mebaran151 | I see |
| 05:07 | mebaran151 | so essentially for each a that the pred is true |
| 05:07 | mebaran151 | you want to pop a b off the stack |
| 05:07 | Chousuke | hmm |
| 05:07 | Anniepoo | yes |
| 05:08 | Chousuke | ,(merge-with + #{1 2 3 4} #{10 2 30 4}) |
| 05:08 | clojurebot | java.lang.ClassCastException: java.lang.Integer cannot be cast to java.util.Map$Entry |
| 05:08 | Chousuke | damn :) |
| 05:08 | mebaran151 | but you have to remember where a came from at the same time |
| 05:09 | Anniepoo | another way to look at it is that my architectural error is in using the order to map the external process's I/O |
| 05:10 | Anniepoo | that is, I have to give it a list of filenames (that's what I get out of the a's) and I get back a same length list of UUID's |
| 05:11 | Anniepoo | so I should wrap this very imperitive nastiness with making a map |
| 05:11 | Anniepoo | that maps filename to UUID |
| 05:12 | Anniepoo | then look through all of the a's, and if it's got a filename that's in my map, remap it |
| 05:12 | Anniepoo | that's the correct thing, I think |
| 05:12 | Anniepoo | ,(doc merge-with) |
| 05:12 | clojurebot | "([f & maps]); Returns a map that consists of the rest of the maps conj-ed onto the first. If a key occurs in more than one map, the mapping(s) from the latter (left-to-right) will be combined with the mapping in the result by calling (f val-in-result val-in-latter)." |
| 05:13 | Chousuke | (merge old-map (zipmap filenames uuids)) |
| 05:13 | Anniepoo | ,(doc zipmap) |
| 05:13 | clojurebot | "([keys vals]); Returns a map with the keys mapped to the corresponding vals." |
| 05:14 | Chousuke | merge is basically (merge-with (fn [x y] y) ...) |
| 05:14 | Anniepoo | yes, this is the architecturally clean thing |
| 05:14 | Anniepoo | make the structure I need |
| 05:16 | mebaran151 | it's all about datastructures |
| 05:17 | Anniepoo | ok, gimme a minit to try this |
| 05:23 | Anniepoo | is there a way to start with (:foo :bar) (1 2) and get {:foo 1 :bar 2}? |
| 05:23 | Anniepoo | ah, zipmap |
| 05:23 | Anniepoo | sorry, |
| 05:32 | Anniepoo | ok, this looks a lot saner |
| 05:35 | mebaran151 | yeah |
| 06:00 | tomoj | is there a reason ns-reload! needs to be a macro here? http://bc.tech.coop/blog/docs/user.clj |
| 06:35 | Chousuke | tomoj: not as far as I can tell. |
| 06:35 | tomoj | me neither, strange |
| 06:35 | Chousuke | probably just convenience |
| 06:36 | Chousuke | as you can white (ns-reload! your.namespace) instead of (ns-reload! 'your.namespace) |
| 06:36 | Chousuke | write* :P |
| 06:39 | Chousuke | does the repl automatically load user.clj btw? :/ |
| 07:09 | Jomyoot | hi man |
| 07:09 | Jomyoot | yo |
| 07:09 | Jomyoot | is there a better way than clojure.org/api to find the functions in eed |
| 07:09 | Jomyoot | i need? |
| 07:10 | Jomyoot | the good thing about object oriented is that i can always look at the right class to find the right method for what i need |
| 07:10 | Jomyoot | but now all functions are listed alphabetically. i can never find the right ones i need |
| 08:26 | LauJensen | hehe, seriously? |
| 08:26 | rhickey | yes |
| 08:26 | LauJensen | oh... :) |
| 08:28 | LauJensen | I thought proxy was quite good in terms of naming |
| 08:58 | Jomyoot | hi |
| 08:58 | LauJensen | Yo |
| 08:58 | Jomyoot | sup dude |
| 08:58 | Jomyoot | woder if anyone actually has a job that uses clojure |
| 08:59 | LauJensen | Sure they do |
| 08:59 | Jomyoot | like what kind? research? |
| 08:59 | Jomyoot | ai ? |
| 08:59 | LauJensen | Number crunching and data parsing |
| 09:02 | cemerick | Jomyoot: 95% of the new code we write is in clojure |
| 09:02 | Jomyoot | camerick what kind of project? |
| 09:02 | cemerick | when we're hiring next, I'm sure we'll make it well-known here and on the group |
| 09:03 | cemerick | Jomyoot: there's lots of moving pieces. In the first place, v3.0 of PDFTextStream |
| 09:03 | cemerick | http://snowtide.com/PDFTextStream |
| 09:03 | Jomyoot | can't wait to see a web project |
| 09:03 | alinp | hi |
| 09:04 | Jomyoot | replacement of rails but with clojure |
| 09:04 | cemerick | We have a far more ambitious project running in parallel. |
| 09:04 | alinp | is there any "power of" function in clojure ? |
| 09:04 | fffej | alinp: use Math/pow? |
| 09:04 | alinp | beside of that, of course :) |
| 09:05 | alinp | that's why I asked: in clojure |
| 09:05 | alinp | not in java |
| 09:05 | Chousuke | then, no :P |
| 09:05 | fffej | alinp: my bad |
| 09:05 | Chousuke | except maybe in contrib somewhere. |
| 09:05 | alinp | ok, thanks |
| 09:06 | fffej | alinp: clojure.contrib.math has (expt x y) |
| 09:06 | alinp | oh, pretty cool |
| 09:06 | alinp | thanks |
| 09:09 | rhickey | cemerick: I missed you yesterday, but I think reify makes sense as a concrete realization of an (otherwise non-instantiable) interface abstraction |
| 09:16 | cemerick | rhickey: Yeah, I guess that makes sense. |
| 09:17 | rhickey | and it makes sense as a realization both as code and as an object |
| 09:18 | cemerick | naming things is so fuzzy -- so much about 'feel'... |
| 09:20 | cemerick | I'm all for the pedagogical utility of naming it 'reify', but we'll have to be prepared for even more q's about 'how do I implement an interface...' |
| 09:20 | rhickey | cemerick: people found proxy even though it's not a great name |
| 09:21 | cemerick | heh, I thought it made perfect sense because of j.l.r.Proxy |
| 09:22 | rhickey | that's what's fun about this conversation, I think we are thinking about this feature completely differently :) |
| 09:23 | cemerick | yup -- I just don't have the CS chops to think about it outside of its actual utility for too long :-) |
| 09:23 | rhickey | cemerick: I don't think it's a matter of CS chops, I'm just looking out for ClojureScript :) |
| 09:24 | cemerick | rhickey: oh, that. I thought you were referring to your line of thought from yesterday, about how newnew's impl shows that the typical lambda construct is a specialization, etc. |
| 09:24 | Chousuke | What happens if you actually subclass a concrete class with newnew? Will the code look at you in a condescending manner? |
| 09:25 | cemerick | I have moments of clarity when I enter those waters, but that's about it. :-( |
| 09:25 | rhickey | cemerick: there is that, but here I'm just trying not to depend on Javaisms |
| 09:25 | rhickey | Chousuke: definitely |
| 09:26 | cemerick | Chousuke: you'll softly hear, 'tsk, tsk, tsk', but you won't be able to tell where it's coming from. |
| 09:27 | cemerick | rhickey: a good thing, definitely |
| 09:28 | cemerick | On my drive in this morning, I was daydreaming about a couple of macros to implement something like traits using newnew. Surely that's a sign of some kind of illness? |
| 09:29 | rhickey | cemerick: at your suggestion I looked at Scala traits. They really frightened me. |
| 09:30 | cemerick | concept, or implementation? |
| 09:30 | cemerick | (I found them to be pretty pleasant to use, as long as you stayed away from the loftier bits of type mumbo-jumbo.) |
| 09:30 | rhickey | complexity, ordering rules, cascading dependent definitions... seems fraught |
| 09:33 | cemerick | I just want to be able to program to (for example) NetBeans' APIs in clojure in some rational way, which would ideally involve having default implementations of certain interfaces and abstract classes here and there, combining them as desired. |
| 09:34 | cemerick | The general case is surely far more complex. |
| 09:34 | cemerick | Right now, UI / NetBeans dev is our #1 cluster of Java development, thus the attention. |
| 09:35 | rhickey | I think, in my ideal world, nothing would ever be isa some concrete thing from which it inherited, e.g. if you could derive from an abstract superclass but not be instanceof it, only an instance of interfaces it implements |
| 09:37 | rhickey | i.e. we inherit things from our fathers but are not our fathers |
| 09:37 | rhickey | I'm not opposed to mixins in general, but it is so easy to design a mess-making system |
| 09:38 | cemerick | it seems like your ideal world *is* mixins |
| 09:38 | rhickey | how you do mixins matters |
| 09:39 | cemerick | ah -- so your concern with scala traits really are related to implementation complexity? |
| 09:39 | rhickey | cemerick: no, user complexity |
| 09:40 | cemerick | Huh. When I used them, I found them pleasant enough. |
| 09:40 | cemerick | Though, I wasn't trying to dig myself a hole :-) |
| 09:43 | cemerick | yeah, I can see how you could really spin a web with them. |
| 09:43 | rhickey | cemerick: but you could still find yourself in the bottom of one, cursing your shovel |
| 09:45 | cemerick | rhickey: oh, I ended up in a very deep hole, and I cursed scala for it, but it was the type system (or, my application of it, others might say) that got me there. |
| 09:46 | cemerick | I seem to remember having come to the conclusion that I would have had to build a whole new type hierarchy, rooted at Any, with my own datastructures, in order to get things to line up properly. Don't remember the specifics though. |
| 09:48 | rhickey | I smiled also (in recognition) at the lack of ctor args for traits |
| 09:54 | rhickey | (musing here) what if I let you specify multiple ctor-less classes but the resulting object would not be isa any of them, only the interfaces they implement? |
| 09:55 | cemerick | That sounds like the ideal. |
| 09:56 | cemerick | Wouldn't work for libs that have a dependency on an abstract class, but in that case, the interface is semi-worthless anyway. |
| 09:56 | rhickey | that's one of the problems I have with traits, they're the substitute for interfaces, but, then you put in concrete code and have left yourself without an interface |
| 09:56 | cemerick | well, the interface is there, just name-mangled |
| 09:57 | LauJensen | Guys, if its impossible thats ok, but I'd like to understand what youre talking about. Where do I go to read some background info which will let me understand the implications of your propositions? |
| 09:57 | rhickey | cemerick: I'm determined not to try to fix bad Java designs |
| 09:57 | rhickey | cemerick: but not part of the program design |
| 09:59 | cemerick | rhickey: yes, definitely quarantine those vectors |
| 09:59 | cemerick | LauJensen: I generally barely keep up myself :-) |
| 10:00 | LauJensen | Good to know :) |
| 10:00 | rhickey | me too! |
| 10:02 | cemerick | rhickey: you'll understand if we all collectively roll our eyes, right? :-) |
| 10:02 | cemerick | programming is one of those fields where, the more you learn, the more you realize you don't understand a damn thing. |
| 10:02 | rhickey | cemerick: I had to read the Scala book to follow up on your suggestion |
| 10:03 | rhickey | it works both ways |
| 10:03 | cemerick | rhickey: oh, I'm so sorry. |
| 10:03 | rhickey | re-read the traits section I mean |
| 10:04 | cemerick | jeez, back when I started learning scala, all there was were the tutorial PDF and the language spec PDF (with the former consistently being out of date/sync with the latest version). That was brutal. |
| 10:04 | LauJensen | Reminds me of when I picked up Clojure... All I had was Chouser :) |
| 10:05 | cemerick | Yeah, Chouser_'s been here "forever". |
| 10:05 | cemerick | Likely off coding some hairy C++ right now. :-/ |
| 10:06 | LauJensen | Yea he loves that stuff |
| 10:06 | cemerick | Chouser_: come back to the fold, buddy! :-D |
| 10:06 | cp2_ | feels good man |
| 10:07 | LauJensen | rhickey: What happend to that virtual study session you were considering at one point? |
| 10:10 | rhickey | LauJensen: right now we're putting together a NYC Clojure meetup |
| 10:10 | Chousuke | Hm |
| 10:10 | LauJensen | rhickey: How can I benefit from that ? |
| 10:11 | LauJensen | ( I realize Im being very selfish ) |
| 10:11 | Chousuke | I wonder why an exception from my reader got wrapped in ~eleventy billion RuntimeExceptions :/ |
| 10:11 | LauJensen | Chousuke: Sounds like you've gotten into 'state' |
| 10:13 | Chousuke | my reader does not "consume" its source. |
| 10:14 | Chousuke | I can (def source whatever) and then try to read it multiple times. |
| 10:14 | Chousuke | but still, I get this: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.Exception: Expected token, got nothing. (line 10, character 7) |
| 10:14 | Chousuke | (It's just an unimplemented reader macro, but the runtimeexceptions are puzzling) |
| 10:18 | LauJensen | rhickey: I meant it seriously. Will you put out some info from those meetings, videos, docs, etc ? |
| 10:18 | Chousuke | hm, maybe I should do this work in the newnew branch |
| 10:18 | Chousuke | I could use a "/dev/null" right now. |
| 10:18 | rhickey | LauJensen: no plans right now |
| 10:18 | LauJensen | ok |
| 10:18 | Chousuke | something that discards the item if you conj on to it. |
| 10:19 | Chousuke | I suppose proxy would work too |
| 10:22 | cemerick | rhickey: any idea of the schedule yet? I/we would try to make it. |
| 10:23 | rhickey | cemerick: you can sign up here for notices: http://www.meetup.com/Clojure-NYC/ |
| 10:39 | lisppaste8 | cgrand pasted "clojure on par with java?" at http://paste.lisp.org/display/84909 |
| 10:40 | Chousuke | hmm |
| 10:40 | rhickey | cgrand: looks pretty good! |
| 10:41 | Chousuke | I have a println statement in a defmethod accompanied by a flush, but I'm not seeing it anywhere. :/ |
| 10:41 | cgrand | rhickey: I'm really surprised by these results |
| 10:42 | rhickey | in what way? |
| 10:42 | cgrand | they are too good |
| 10:42 | rhickey | :) that's the point, no more need for Java! |
| 10:43 | rhickey | I presume ISetNode is because no non-reflective helpers yet? |
| 10:44 | cgrand | can reify declare new methods? |
| 10:44 | rhickey | yes |
| 10:44 | cemerick | cgrand: those benchmarks are using transients in the reduce? |
| 10:44 | Chousuke | durr |
| 10:44 | rhickey | but right now calls to them are reflective |
| 10:45 | Chousuke | I didn't even have a bug. D: |
| 10:45 | rhickey | self-calls will be non-reflective, will always be reflective from outside the class |
| 10:45 | Chousuke | I just had mismatching parentheses in a *comment* |
| 10:45 | LauJensen | rhickey: is 'reify' the decided name? Am I the only one to whom it really sticks out in a bad way? |
| 10:45 | cgrand | cemerick: no transients on sets yet plus I'm in the "new" branch |
| 10:46 | rhickey | LauJensen: you are the only public complainant at the moment, maybe everyone else is just cringing in private :) |
| 10:46 | cemerick | well, goodness, lots of potential yet :-) |
| 10:46 | LauJensen | hehe, I just earned a bad title then |
| 10:47 | rhickey | cgrand: I love how few #^s |
| 10:47 | rhickey | although it begs for #^objects akin to #^doubles etc |
| 10:48 | cemerick | rhickey: LauJensen may find some friends on the group. It's not a bad name, but it's certainly unusual and uncommon. |
| 10:48 | rhickey | cemerick: not bad traits for a new special op, in terms of conflicts |
| 10:48 | clojurebot | for is not used often enough. |
| 10:49 | cemerick | oh, I don't disagree. There will definitely be some groaning and muttering, though. |
| 10:49 | rhickey | cgrand: so, with high-perf helper methods, ISetNodes/Utils could go away and I SetNode could be defined with gen-interface? |
| 10:49 | cgrand | yup |
| 10:50 | rhickey | cool |
| 10:50 | rhickey | cgrand: this is a terrific validation, thanks for tackling it |
| 10:52 | AWizzArd | rhickey: btw, do you expect this InvokeDynamic bytecode instruction from Java 7 to speed up Clojure here and there even more? |
| 10:53 | cgrand | rhickey: I'm not sure to understand how non-reflective self-calls will help to remove the need for an explicit interface |
| 10:53 | rhickey | AWizzArd: perhaps, but it would mean bifurcating the code to deal with older VMs. One of the design constraints for Clojure was to work well on the JVMs people are using right now |
| 10:54 | rhickey | cgrand: they don't remove the need for ISetNode, but for ISetNode/Utils, and the former we can write with gen-interface |
| 10:55 | rhickey | in order to make your solution Java-free |
| 10:57 | cgrand | but this benchmark is unfair: no dummy map and slightly different algorithms (half-full bitmap nodes become array-nodes, no leaf-node) |
| 10:59 | AWizzArd | rhickey: will I be able to build my own abstraction over newnew which can give me something like defstruct, but with faster instantiation (under the hood I would build a simple Java class, to which I can't add k/v pairs of course) |
| 10:59 | rhickey | AWizzArd: you have to stop asking me about that |
| 11:00 | rhickey | cgrand: true, but still shows an (almost) all-clojure data structure with speed akin to the Java-written ones |
| 11:04 | cgrand | rhickey: can't we have non-reflective method calls to a reified object (a "reclausa"? :-) ) in the whole lexical scope? Is this impossible or hard? |
| 11:04 | AWizzArd | i see |
| 11:05 | rhickey | cgrand: oh yes, by self-calls I meant only from within any of the methods, on a target of "this" |
| 11:07 | rhickey | cgrand: or do you mean on another instance of the same anonymous class? |
| 11:07 | rhickey | (of course your helpers don't use "this") |
| 11:10 | cgrand | I was thinking about something like that: (let [o (new [] (foo [x] (str "bar" x)))] (.foo o "baz")) |
| 11:12 | rhickey | cgrand: ah, I'm not there yet, I need to think about it, my inclination is no, I'm trying to encourage programming to interfaces |
| 11:12 | cemerick | all such calls would always be reflective though, right? |
| 11:13 | rhickey | also, if they move that body into a helper, they'll get reflection warnings they can't remove |
| 11:13 | rhickey | cemerick: if I let them be public at all, that style of programming is really icky |
| 11:13 | tomoj | damn. this site uses multiple cookie headers, spelled "Set-cookie" instead of "Set-Cookie". clojure-http-client supports neither |
| 11:14 | rhickey | right now the intended use for additional methods is private high-perf helpers |
| 11:14 | cemerick | is that even necessary? You can just close over some 'bare' helper fns, right? |
| 11:15 | cemerick | (that's totally aside from convenience, clarity, etc) |
| 11:15 | rhickey | cemerick: methods can have fully primitive args/returns |
| 11:15 | rhickey | fns can't |
| 11:15 | cemerick | ah-ha, right |
| 11:15 | rhickey | plus fns need to be allocated |
| 11:15 | rhickey | everything in a reify is one allocation |
| 11:16 | rhickey | only non-closing helper fns could be one-time allocated |
| 11:16 | rhickey | and fns don't have access to the other members except through a public interfaces |
| 11:17 | rhickey | so there's a good argument for additional helper methods, and no really good ones for leaking them out |
| 11:18 | cgrand | ok |
| 11:18 | cemerick | rhickey: I'll just keep asking naive questions so you can fully examine your reasoning :-P |
| 11:25 | cgrand | rhickey: btw, on thie "new" branch, lazy-primes3 (see here http://clj-me.blogspot.com/2009/07/everybody-loves-sieve-of-eratosthenes.html ) throws an IllegalAccessError when called |
| 11:43 | cemerick | gawd, trying to get NetBeans folks to understand that there is a world outside of big-J Java is proving nigh-impossible. |
| 11:43 | cemerick | odd, since they've got the best JRuby IDE impl out there. |
| 11:58 | AWizzArd | cemerick: so currently they don't see enough critical mass behind Clojure to provide more support in NetBeans? |
| 11:58 | tomoj | do dan larkin or phil hagelberg ever come around here? |
| 11:59 | cemerick | tomoj: danlarkin is over there :-) |
| 11:59 | cemerick | AWizzArd: not a matter of support or critical mass -- they just don't seem to recognize that there's a universe outside of Java |
| 12:00 | tomoj | danlarkin: hey, got some issues with clojure-http-client. I'll try to figure out the patch needed. should I put them in github's issue tracker? |
| 12:00 | cemerick | There are a couple of things they could do that would simplify things for other jvm language users, and introduce zero breakage for Java devs, but they don't see the point. |
| 12:01 | AWizzArd | hmm |
| 12:01 | cemerick | we'll see, I'm swinging for it :-) |
| 12:02 | danlarkin | tomoj: sure! You might also check out contrib's http library. It was added after we started clojure-http-client, and I haven't used it yet. Not sure how much parallel functionality there is between the two |
| 12:03 | tomoj | danlarkin: ah, will check that out. just ran into a few problems with cookies (two of which are probably my university's fault for not strictly following HTTP) |
| 12:06 | tomoj | looks like clojure-http-client has more of the features I need. currently fixed it with an ugly hack. I'll try to figure out a proper patch soon |
| 12:06 | danlarkin | tomoj: cool :) |
| 12:08 | Chousuke | ooh, progress! reader.clj is able to read itself without exceptions now. (though the results of the read are not usable, due to missing support for complex character escapes and such... ) |
| 12:09 | Chousuke | \newline gets read as ewline :p |
| 12:35 | Chousuke | I still wonder why I get so many RuntimeException wrappers :/ |
| 12:36 | mebaran151 | yeah, I've always wondered that too |
| 12:43 | tomoj | what's like reduce but operates on one element at a time, rather than two? |
| 12:44 | Chousuke | that doesn't make sense? |
| 12:44 | Chousuke | or do you mean map? :P |
| 12:44 | tomoj | hrmm |
| 12:44 | tomoj | OH |
| 12:44 | tomoj | I was confused |
| 12:44 | tomoj | reduce is exactly what I want |
| 12:47 | angerman | can I split a large clojure file into many smaller ones using (use and (in-ns ? |
| 12:47 | Chousuke | use load-file |
| 12:47 | Chousuke | or subnamespaces |
| 12:49 | tomoj | hmm |
| 12:50 | tomoj | I have a function which takes a pred and a seq, and returns a map where the keys are the seq elements for which pred is true, and each value is a vector of the elements after that and up to the next element for which pred returns true |
| 12:50 | tomoj | I wonder what to call it |
| 12:51 | angerman | filter? |
| 12:52 | Chousuke | "group" :P |
| 12:52 | angerman | group-filter or filter-to-group? |
| 12:52 | tomoj | like (my-function number? '(5 a b 7 c d e)) returns {5 [a b], 7 [c d e]} |
| 12:52 | angerman | grouped-filter, maybe |
| 12:53 | Chousuke | there's a similar function "group-by" in contrib I think |
| 12:53 | Chousuke | (doc group-by) |
| 12:53 | clojurebot | "([f coll]); Returns a sorted map of the elements of coll keyed by the result of f on each element. The value at each key will be a vector of the corresponding elements, in the order they appeared in coll." |
| 12:53 | Chousuke | hmm, not quite. |
| 12:54 | Chousuke | group-by-delimiter |
| 12:54 | tomoj | that's exactly what it does! |
| 12:54 | tomoj | :) |
| 13:00 | cemerick | argh, just got caught by the fact that clojure in the same ns as a class with a package-private method can't invoke that method. |
| 13:03 | gko | Is there some macro for such destructuring: instead of (defn f [{a :a b :b c :c ...}] ...) => (defn f [XXX] ...) and the XXX would magically becomes {a: a b: b ...} etc? |
| 13:04 | Chousuke | gko: {:keys [a b c]} |
| 13:04 | Chousuke | or hm |
| 13:05 | Chousuke | something like that works in let anyway. I always forget the exact syntax :P |
| 13:07 | gko | Chousuke: oh... right, I must still explicitely say a, b, c, etc... otherwise I'll have compiler error... |
| 13:08 | gko | Chousuke: OK, working. Thanks. |
| 13:10 | rhickey | cgrand: thanks, fixed letfn on new branch |
| 13:14 | gko | do you use different faces (in SLIME) for (), [], {}, #{}, @..., ^..., ^#'..., #', etc.? |
| 13:19 | LauJensen | Btw - For those interested in Github: I contacted their support to ask about the slowness of their site. They said that they have been working on a solution since april (sounds like a c++ thing), and that things will be changing very soon |
| 13:21 | Chousuke | ooh. good news. |
| 13:21 | Chousuke | because github is *slow* |
| 13:22 | gko | When is it slow? Always? Morning? Evening? |
| 13:23 | Chousuke | every time I use it : |
| 13:25 | rhickey | is there a way to get a link to a particular source line on github, like we used to be able to do with gcode? |
| 13:26 | Chousuke | hmm |
| 13:27 | Chousuke | I think clojurebot does it somehow |
| 13:27 | rhickey | ah, looks like #LCnnn |
| 13:27 | LauJensen | There is |
| 13:27 | LauJensen | I think you just prepend #150 to get line 150, but lemme check |
| 13:28 | rhickey | LauJensen: #LCnnn works |
| 13:28 | LauJensen | k |
| 13:29 | Chousuke | rhickey: btw, do you have any idea what could cause my exceptions to get wrapped in multiple RuntimeExceptions? I'm writing a recursive reader for clojure and all exceptions it throws are rather well "packaged" :P |
| 13:31 | lpetit | Chousuke: a beginning of explanation in the "recursive" nature of your reader ? |
| 13:31 | Chousuke | I suppose it could be just slime being weird. |
| 13:32 | Chousuke | lpetit: what do you mean? :P |
| 13:34 | lpetit | Chousuke: maybe a totally idiotic idea of mine, but could exceptions be catched an rethrow (wrapped in a fresh one) at each level of the recursion ? |
| 13:34 | Chousuke | that's possible, but it didn't happen with a regular recursive function |
| 13:34 | Chousuke | hmm |
| 13:34 | lpetit | Chousuke: I'm interesting in knowing what you're pursuing by writing a recursive clojure reader. Is it as an exercise, or with other goal in mind |
| 13:35 | lpetit | Chousuke: %s/interesting/interested/g |
| 13:35 | Chousuke | lpetit: well, if it turns out good enough I'm all for including it in Clojure. But if not, then at least it's been fun to write |
| 13:36 | Chousuke | as it is now, it's not as resistant to stack overflows as the java reader, and is a fair bit slower too I guess |
| 13:36 | Chousuke | but at least it doesn't contain mutable state |
| 13:37 | lpetit | Chousuke: oh yes, less java, more clojure. I see :-). If you came up with a reader that could have a "working mode" that would not throw anything that it reads (including comments, raw textual representation of the element, spaces) that would be great too ! |
| 13:39 | tomoj | possible to get a map sorted by insertion order? |
| 13:40 | Chousuke | tomoj: not without having the information in the key. |
| 13:40 | tomoj | ah |
| 13:40 | tomoj | just thought up a way around needing it anyway |
| 13:41 | Chousuke | lpetit: it's not quite that flexible at the moment, but... it might not be impossible. |
| 13:43 | Chousuke | first, I need to get in a state that produces eval'able code :P |
| 13:45 | Chousuke | syntax-quote is going to be interesting to implement in Clojure. |
| 13:46 | Chousuke | Currently I just call the java method that syntax-quotes a form. :P |
| 13:46 | lpetit | Chousuke: do you do this all by hand, or a helper library such as fn-parse ? |
| 13:46 | Chousuke | lpetit: pure clojure.core |
| 13:46 | Chousuke | fnparse would make it much easier I suppose. |
| 13:47 | Chousuke | but it would make it impossible to use my reader with clojure :) |
| 13:49 | tomoj | there has to be a better way to do this: https://gist.github.com/a625a6edd5824bfc4c81 |
| 13:51 | Chousuke | tomoj: curious: why are you using lists instead of vectors? :/ |
| 13:51 | tomoj | random choice |
| 13:51 | tomoj | I dunno when one or the other is better yet |
| 13:51 | Chousuke | well vectors are easier to type. :) |
| 13:51 | tomoj | will switch to vectors, but still seems ugly |
| 13:51 | tomoj | ah, and easier to read too I suppose |
| 13:53 | tomoj | updated gist |
| 13:53 | Chousuke | take-while could help you I suppose. |
| 13:54 | Chousuke | or hm. |
| 13:54 | tomoj | ah, then I wouldn't have to pass around the current delimiter, I suppose |
| 13:54 | tomoj | since I could just grab the delimiter's group all in one |
| 13:55 | tomoj | oh, except I'm reducing |
| 13:55 | Chousuke | your current implementation is probably better. |
| 13:55 | tomoj | maybe it just seems ugly to me because I'm not used to functional programming yet |
| 13:59 | tomoj | destructuring is fucking awesome |
| 14:00 | cemerick | that's a pretty good tshirt slogan :-P |
| 14:01 | tomoj | the clojure logo looks good for tshirts |
| 14:01 | cemerick | I think they're already on cafepress? |
| 14:01 | cemerick | ~tshirts |
| 14:01 | clojurebot | Huh? |
| 14:01 | cemerick | hrm |
| 14:01 | cemerick | ~shirts |
| 14:01 | clojurebot | Titim gan éirí ort. |
| 14:01 | tomoj | found a few on zazzle |
| 14:01 | cemerick | ah, zazzle |
| 14:02 | tomoj | http://www.zazzle.com/clojure+tshirts |
| 14:02 | cemerick | clojurebot: tshirts is <reply>Check 'em out: http://www.zazzle.com/clojure+tshirts |
| 14:02 | clojurebot | In Ordnung |
| 14:02 | cemerick | ~tshirts |
| 14:02 | clojurebot | Check 'em out: http://www.zazzle.com/clojure+tshirts |
| 14:02 | tomoj | nice |
| 14:04 | tomoj | logo buttons are only $1.45 |
| 14:20 | lisppaste8 | cemerick pasted "group-by-pred alternatives" at http://paste.lisp.org/display/84926 |
| 14:20 | cemerick | tomoj: ^^ |
| 14:21 | cemerick | the second one is (perhaps) a clearer way of doing what you did, but some will not like reducing of a vector for this purpose |
| 14:22 | tomoj | I was just about to update my gist |
| 14:22 | cemerick | split-groups-with is more general, and returns a seq of vectors that can be turned into map with (into {} (split-groups-with number? ...)) |
| 14:22 | tomoj | I also need to transform the keys and values of the final map with different functions |
| 14:23 | tomoj | ended up rolling it into my previous function like this: https://gist.github.com/a625a6edd5824bfc4c81 |
| 14:23 | tomoj | which I don't like at all |
| 14:24 | cemerick | yeah...you should definitely break things up there a little bit |
| 14:25 | cemerick | lots of stuff going on in the * fn |
| 14:25 | tomoj | the problem is, after the map functions are applied, there's no way to distinguish delimiters from values |
| 14:25 | tomoj | (in my case) |
| 14:25 | cemerick | aren't the delimiters always the keys? |
| 14:26 | tomoj | yeah, I just mean I can't transform the elements of the seq before grouping them |
| 14:26 | tomoj | perhaps I could group, then transform the keys and values of the resulting map |
| 14:26 | cemerick | that's a far better approach |
| 14:27 | tomoj | actually, now that I think about it a bit more, I don't even want a map at all |
| 14:27 | cemerick | heh |
| 14:27 | tomoj | I want each element of the result to be a map with one pair for the delim and another pair for the grouped elements |
| 14:28 | tomoj | and doing that I can transform after grouping easily |
| 14:29 | cemerick | tomoj: I'm a little confused, but mostly because there are no pairs in clojure :-) |
| 14:29 | cemerick | you mean two-element seq / vector? |
| 14:29 | tomoj | I meant one key-value pair |
| 14:29 | cemerick | ah |
| 14:29 | tomoj | like each element will look like {:name <delimeter transformed> :children <group, each element transformed>} |
| 14:30 | cemerick | I thought you meant a dotted pair, which I don't even remember well from CL |
| 14:30 | tomoj | no dotted pairs in clojure? |
| 14:30 | tomoj | oh, no conses really, I guess |
| 14:31 | tomoj | even though we have "cons" :) |
| 14:31 | rhickey | ,(class (cons 1 nil)) |
| 14:31 | clojurebot | clojure.lang.PersistentList |
| 14:31 | tomoj | I'm too noob to understand your examples quickly, but thanks, I'll step through them |
| 14:32 | cemerick | There is a cons (clojure.lang.Cons) data structure, but the cdr is always a seq. |
| 14:32 | rhickey | ,(class (cons 1 [2 3])) |
| 14:32 | clojurebot | clojure.lang.Cons |
| 14:33 | tomoj | empty seq for the last element? |
| 14:34 | cemerick | empty seq for rest |
| 14:34 | cemerick | ,(cons 1 2) |
| 14:34 | clojurebot | java.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer |
| 14:34 | cemerick | ,(cons 1 [2]) |
| 14:34 | clojurebot | (1 2) |
| 14:34 | cemerick | ,(rest (cons 1 [2])) |
| 14:34 | clojurebot | (2) |
| 14:35 | tomoj | ,(cons 1 nil) |
| 14:35 | clojurebot | (1) |
| 14:35 | cemerick | contrast with: |
| 14:35 | cemerick | ,(list 1 2) |
| 14:35 | clojurebot | (1 2) |
| 14:35 | cemerick | ,(list 1 nil) |
| 14:35 | clojurebot | (1 nil) |
| 14:36 | tomoj | those two behave just like CL |
| 14:36 | rhickey | Clojure cons cells are not arbitrary pairs |
| 14:36 | tomoj | the ones with nils i mean |
| 14:37 | tomoj | but (cons 1 2) is different |
| 14:37 | cemerick | yeah. You can't do (1 . 2) |
| 14:37 | rhickey | and most ops prefer PersistentList |
| 14:37 | rhickey | ,(counted? (cons 1 nil)) |
| 14:37 | clojurebot | true |
| 14:38 | rhickey | ,(counted? (cons 1 [2 3])) |
| 14:38 | clojurebot | false |
| 14:38 | rhickey | so the cons function has polymorphic return values, it is not a constructor for a particular structure |
| 14:47 | angerman | how would I translate something like "sha.new(str(random.random())).hexdigest()[:5]" from python to clojure? |
| 14:49 | cgrand | rhickey: ok now I think it's worthy to rework PersistentHashMap (and TransientHashMap), do I get your green light? |
| 14:49 | tomoj | angerman: probably mostly with java I'd think |
| 14:50 | rhickey | cgrand: rework how, the leaf-less and not-packed ideas |
| 14:50 | rhickey | ? |
| 14:50 | cgrand | yup |
| 14:50 | rhickey | you think that due to the set work? |
| 14:50 | clojurebot | that is not what I wanted |
| 14:51 | cgrand | yup (btw I forgot two or three #^"[Object" this makes things slightly faster) |
| 14:51 | rhickey | cgrand: this reworking in the Java version? |
| 14:53 | cgrand | rhickey: rewriting collections in clojure is a short term goal? |
| 14:54 | rhickey | cgrand: there is a problem with using them before cinc in that there are bootstrapping issues, e.g. the implementation of Clojure uses maps |
| 14:54 | rhickey | but we might be able to bootstrap what we've got and swap in Clojure versions as we go |
| 14:55 | cgrand | so yes, I was talking abour reworking the java versions, I think TransientHashMap ca be way faster |
| 14:55 | rhickey | go for it then |
| 14:55 | cgrand | must run |
| 14:55 | cgrand | ok |
| 15:02 | angerman | tomoj thanks |
| 15:04 | tomoj | angerman: i.e. java.security.MessageDigest |
| 15:07 | angerman | hmm another question, how would I loop over something that I want to stop once it's done |
| 15:08 | angerman | e.g. I want to try to create something it might fail... |
| 15:08 | angerman | so I'll retry for x times |
| 15:08 | wtetzner_ | is there a way to check if something is named? |
| 15:09 | wtetzner_ | like with symbols and keywords, you can do (name :keyword) or (name 'symbol) |
| 15:11 | tomoj | (or (symbol? x) (keyword? x)) ? |
| 15:12 | wtetzner_ | hmm |
| 15:12 | wtetzner_ | ok |
| 15:16 | tomoj | angerman: I suppose you could recur in a catch, passing along a counter counting up to the max number of tries |
| 15:16 | tomoj | there's probably a better way |
| 15:17 | tomoj | better to count down from max tries |
| 15:19 | Chousuke | hm |
| 15:20 | tomoj | eshell? or what? |
| 15:20 | Chousuke | At least I found a third terminal emulator for OS X. |
| 15:20 | Chousuke | just terminal, running bash |
| 15:20 | Chousuke | inside emacs... |
| 15:20 | angerman | how about my faculty implementation? (defn fac [n] (loop [x n acc 1] (if (> x 1) (recur (- x 1) (* x acc)) acc))) |
| 15:21 | tomoj | there are no loops in clojure |
| 15:21 | clojurebot | clojure is the best way to learn java |
| 15:21 | Chousuke | tomoj: loop is there :p |
| 15:21 | tomoj | not like you'd think, anyway |
| 15:21 | Chousuke | but it's a functional loop. |
| 15:21 | tomoj | loop is misleadingly named for noobs |
| 15:22 | Chousuke | yeah, it's basically just a shortcut for ((fn [foo bar] (dostuff foo bar) (recur something else)) init vals) |
| 15:23 | Chousuke | though I don't know if it *really* is that. |
| 15:23 | tomoj | oh, but I forgot about loop-recur |
| 15:25 | tomoj | how about (defn fac [n] (reduce * (take n (iterate inc 1)))) |
| 15:27 | tomoj | angerman: yours is faster |
| 15:31 | tomoj | why in the world isn't there a time which returns the msecs |
| 15:32 | tomoj | but mine doesn't even do any recursion anyway :( |
| 15:32 | Chousuke | the laziness overhead matters some. |
| 15:34 | tomoj | how do you run bash inside emacs anyway? |
| 15:34 | Chousuke | M-x shell or M-x term |
| 15:34 | Chousuke | I'm not just running bash inside emacs. I'm running ssh inside that bash, and screen, and finally irssi |
| 15:34 | Chousuke | and it works just fine |
| 15:35 | Chousuke | I bet I could run emacs inside emacs. |
| 15:35 | tomoj | haha |
| 15:35 | tomoj | I've got irssi and emacs in a screen through ssh |
| 15:35 | tomoj | but not nested in emacs :) |
| 15:36 | Chousuke | hm |
| 15:36 | Chousuke | I ran emacs in emacs :P |
| 15:36 | Chousuke | it works too |
| 15:36 | tomoj | I can even get screen up |
| 15:36 | tomoj | "clear screen capability required" |
| 15:36 | Chousuke | you probably need M-x term for that |
| 15:36 | Chousuke | M-x shell is just for shell interaction |
| 15:37 | Chousuke | but I think if I ran a terminal inside emacs inside emacs then the keybindings would conflict. |
| 15:37 | tomoj | wow this is nice |
| 15:37 | tomoj | (irssi in emacs) |
| 15:38 | Chousuke | you can switch buffers with C-c b (C-c is the "escape" from terminal mode into emacs) |
| 15:39 | tomoj | can't get other minor modes in here? |
| 15:39 | tomoj | e.g. paredit for typing to #clojure :) |
| 15:40 | tomoj | dunno how to get something like M-x starting with C-c = C-x |
| 15:41 | tomoj | oh, easy. but paredit doesn't like this buffer |
| 15:42 | fridim_ | tomoj, do you have a screenshot ? :) |
| 15:42 | fridim_ | emacs is Lisp enabled, so I guess you guys use it. |
| 15:43 | fridim_ | would be logical. So if some of you use vim, that prooves the superiority of it. |
| 15:43 | fridim_ | :-O |
| 15:43 | tomoj | not a very interesting sshot |
| 15:44 | fridim_ | I know |
| 15:44 | tomoj | hmm |
| 15:44 | fridim_ | ah I thought you mean my attempt. |
| 15:44 | tomoj | http://skitch.com/tomoj/b4ptn/terminal |
| 15:44 | Chousuke | tomoj: maybe you need to enable line mode for the terminal hmm |
| 15:44 | tomoj | for some reason I can't send that url in irssi-in-screen-in-ssh-in-term-in-emacs |
| 15:44 | Chousuke | wooh |
| 15:45 | Chousuke | okay |
| 15:45 | Chousuke | screen does not like line mode :P |
| 15:45 | tomoj | had to switch back to Terminal.app to send that url |
| 15:46 | Chousuke | hmm |
| 15:46 | Chousuke | I wonder how to get back to character mode |
| 15:46 | Chousuke | line mode is a lot faster though. |
| 15:46 | tomoj | here's my clojure http://skitch.com/tomoj/b4ptw/users-thomasjack-code-clojure-utscheduler-src-com-tomojack-utscheduler.clj |
| 15:47 | tomoj | C-c C-k and the repl has the updated code |
| 15:47 | tomoj | vim probably has something similar |
| 15:48 | Chousuke | Gorilla, but it's not as good as slime. :p |
| 15:48 | tomoj | slime <3 |
| 15:48 | tomoj | I still have not achieved paredit zen |
| 15:48 | Chousuke | vim simply sucks at interacting with things that are not vim |
| 15:50 | Chousuke | which is one of the reasons I consider emacs superior. though I like vim's modal interface. |
| 15:50 | Chousuke | but for that, there's viper.el |
| 15:50 | tomoj | for some reason phil hagelberg's starter kit forces paredit 20 to load even though it bundles 21 |
| 15:50 | tomoj | and 20 sucks at clojure |
| 15:54 | fridim_ | Chouser_, I totally agree |
| 15:55 | fridim_ | Chouser_, I'm definetly a vim person, and I want this kind of feature available in Emacs. I tried the VIPER mode but it sucks compared to the original vim ;( |
| 15:55 | Chousuke | I wish I could make emacs somehow able to differentiate between left and right apple key. |
| 15:55 | Chousuke | but I don't think OS X does that, so little hope for emacs being able to do it... |
| 15:56 | Chousuke | if it could, I could keep one as cmd and the other as meta |
| 15:56 | tomoj | looks like ukelele can't do it either |
| 15:57 | tomoj | agreed, though, I sortof got used to cmd-as-meta while x forwarding to arch linux |
| 15:57 | angerman | is there any tutorial on project file layout? |
| 15:58 | tomoj | now i'm on aquamacs and alt is such a small key |
| 15:58 | tomoj | angerman: technomancy mentions it in http://technomancy.us/126 |
| 15:58 | tomoj | briefly |
| 15:58 | tomoj | and specifically in relation to clojure-mode's clojure-project (emacs) |
| 15:59 | technomancy | tomoj: sorry; didn't notice that (paredit problem) since I'm running from trunk. |
| 15:59 | technomancy | will try to get that fixed |
| 15:59 | technomancy | but the version of 20 that is bundled is patched to support clojure IIRC |
| 16:00 | tomoj | I was able to just remove paredit from the list of elpa projects to force download |
| 16:00 | tomoj | technomancy: what's "trunk" ? |
| 16:00 | tomoj | the problem i had was clojure-mode does special fixes for paredit, but only if 21 is loaded |
| 16:00 | technomancy | tomoj: upstream paredit; I think it's in darcs |
| 16:01 | tomoj | and deleting paredit in elpa didn't help since it would just be reloaded next time emacs starts. |
| 16:01 | technomancy | also, you should try rcirc instead of irissi-in-emacs |
| 16:01 | tomoj | so didn't you have to take paredit out of the list of elpa projects to download? |
| 16:01 | technomancy | anyway, thanks for the heads-up |
| 16:01 | technomancy | tomoj: I manually load-file'd it after ELPA had loaded |
| 16:01 | tomoj | ah, I see |
| 16:02 | tomoj | rcirc looks interesting, I'll give it a shot |
| 16:03 | tomoj | technomancy: thanks, by the way. starter kit and http://technomancy.us/126 have helped me a lot |
| 16:03 | technomancy | great! |
| 16:03 | tomoj | greatly speeding up my weaning myself off textmate :) |
| 16:04 | duncanm | it's possible to run irssi in emacs? in term-mode? |
| 16:04 | tomoj | wasn't pretty for me, but yeah |
| 16:04 | Neronus | you can even run mutt if you don't like gnus |
| 16:04 | Neronus | or rmail |
| 16:04 | Neronus | or whatever |
| 16:04 | tomoj | +termtter |
| 16:04 | duncanm | i use rcirc, it's pretty good |
| 16:05 | tomoj | it makes me happy there are more than a few emacsers here |
| 16:05 | tomoj | I'm vastly outnumbered by vim people in the other channels I frequent |
| 16:06 | Neronus | That's because the world is full of people who don't have a good taste. There are even people who don't like lisp |
| 16:07 | tomoj | yup |
| 16:07 | tomoj | mostly rubyists who haven't seen the light yet |
| 16:08 | tomoj | technomancy: looks like the fix is to just delete line 12 of starter-kit-elpa.el |
| 16:09 | technomancy | tomoj: temporary fix, anyway. go for it. |
| 16:09 | tomoj | is the real fix to get 21 into elpa? |
| 16:10 | technomancy | 22, if we're lucky |
| 16:10 | technomancy | I've been talking with the author, it seems it's right around the corner. |
| 16:10 | technomancy | 22 allows you to use paredit with nonlisps too. |
| 16:11 | tomoj | huh. |
| 16:21 | wwmorgan | If a class has a public field foo and a nullary function foo, how do I access the field from clojure? |
| 16:26 | gko | What's the most effective way to remove a map from a set in an alter? |
| 16:32 | tomoj | disj? |
| 16:32 | tomoj | what other way is there? |
| 16:33 | Chousuke | wwmorgan: good question. :P |
| 16:34 | duncanm | heh, interesting |
| 16:34 | duncanm | what's the lookup order, it gets the method before the field? |
| 16:42 | cemerick | wwmorgan: in a pinch, there's always Reflector.getInstanceField |
| 16:42 | gko | tomoj: yes, disj is what I wanted. Thanks! |
| 17:02 | Chousuke | hmm |
| 17:02 | Chousuke | egg makes using git a lot more pleasant once you get used to it. |
| 17:03 | Chousuke | now if I only had the skills and patience to provide viper-y bindings for it... |
| 17:04 | Chousuke | n/p for going up/down the hunks is not bad, but I am used to j/k |
| 17:04 | clojurebot | for is not used often enough. |
| 17:04 | duncanm | what's viper? |
| 17:04 | Chousuke | modal editing for emacs |
| 17:04 | duncanm | oh |
| 17:04 | duncanm | you like using that? |
| 17:04 | Chousuke | yeah |
| 17:05 | Chousuke | It's what I like about vim the most |
| 17:05 | Chousuke | the editor itself is clearly inferior to emacs. |
| 17:09 | duncanm | but you like modal editing |
| 17:09 | Chousuke | I also did what I never could figure out how to do in vim and made C-ö equal "exit insert mode" (ö being to the left of l and right under my pinky on this keyboard layout |
| 17:10 | Chousuke | left... right! |
| 17:10 | Chousuke | and yeah, I like modal editing |
| 17:10 | Chousuke | I also like modal browsing, with vimperator. ;p |
| 17:11 | triddell1 | technomancy: question: when you use clojure-install from the starter kit, what versions of clojure and contrib are installed? and how are these typically updated/changed... using git commands in the src directories? |
| 17:12 | LauJensen | triddell1: As I recall it pulls all the latests using Git, updating is manually done by Git pull. I could be wrong |
| 17:13 | Chousuke | I think it takes 1.0 by default |
| 17:13 | Chousuke | and the compat branch in contrib |
| 17:13 | triddell1 | LauJensen: that's what it looks like but I didn't see any mention, thx |
| 17:17 | triddell1 | Chousuke: ok, I'll pull new versions if necessary |
| 17:25 | triddell1 | I usually use egg for git in emacs but I only see magit in the package-list-packages list... what do some of you use? |
| 17:26 | technomancy | triddell1: it should use clojure 1.0 and the 1.0-compatible branch of contrib |
| 17:27 | technomancy | I've got a plan to make it optional to use the master branch of git, but haven't gotten around to that since I only use 1.0 myself |
| 17:28 | technomancy | see the clojure-last-known-good-revisions var |
| 17:28 | triddell1 | technomancy: ok, thanks... so do you use magit then... which in in the list of installable applications |
| 17:29 | technomancy | definitely; magit is one of my favourite tools. |
| 17:30 | triddell1 | I'll have to give it a try |
| 17:30 | technomancy | triddell1: check out the screencast; it's really helpful: http://alexvollmer.com/index.php/2009/01/18/meet-magit/ |
| 17:31 | triddell1 | technomancy: cool, starting it now |
| 17:32 | Chousuke | technomancy: are you aware of egg? |
| 17:32 | Chousuke | it's like magit, except user-friendly. |
| 17:32 | Chousuke | (it uses *colour*) |
| 17:33 | technomancy | magit is pretty colourful |
| 17:33 | Chousuke | not mine :P |
| 17:33 | triddell1 | technomancy: so if I want to use something like egg I just make those changes in my local username.el file then? |
| 17:33 | technomancy | triddell1: sure |
| 17:33 | Chousuke | suppose I never saw the colourful screens :) |
| 17:40 | Chousuke | technomancy: hm, how do I stage individual chunks with magit? :/ |
| 17:41 | technomancy | Chousuke: it's just "s" |
| 17:41 | technomancy | you need to expand the file first with tab then put the point on the chunk |
| 17:42 | drewr | kotarak: is there an idiomatic way to provide lexicals inside of an execute-sql macro call? |
| 17:42 | Chousuke | technomancy: hm, and how do you narrow down the hunk? :/ |
| 17:43 | kotarak | drewr: do you have example, what you want to do? |
| 17:43 | technomancy | Chousuke: you mean splitting an existing chunk into smaller pieces? not sure. |
| 17:44 | Chousuke | hmm, it only shows me one chunk in the first place. |
| 17:44 | kotarak | drewr: you mean something like (let [x 5] (query some-table [foo bar baz] (>= foo ~x))) |
| 17:46 | lisppaste8 | drewr pasted "variable in execute-sql expansion" at http://paste.lisp.org/display/84943 |
| 17:48 | drewr | ah, an unquote, of course |
| 17:48 | kotarak | drewr: unquote work normally. You can also use query*, but be sure to quote all symbols then or use strings. keywords are broken at the moment. *coughcough* |
| 17:49 | kotarak | Chousuke: be ripping of the syntax-quote algorithm from core and remove all the resolution stuff. It becomes what is known as "quasiquote" eg. in Scheme. |
| 17:50 | kotarak | I posted that to the google group if you are interested. |
| 17:50 | drewr | the expansion looks right though, doesn't it? |
| 17:50 | drewr | why wouldn't that work? |
| 17:50 | Chousuke | kotarak: I'm looking at it |
| 17:50 | drewr | ahh, I didn't expand execute-sql |
| 17:51 | kotarak | exactly. |
| 17:51 | Chousuke | kotarak: I might end up implementing syntax-quote outside the reader |
| 17:52 | drewr | actually it was insert-into that hid the quasiquote |
| 17:53 | kotarak | Chousuke: http://www.mail-archive.com/clojure@googlegroups.com/msg04500.html <--- here's the original thread, but don't ask me how to find that on google groups.... |
| 17:53 | Chousuke | kotarak: does your quasi-quote handle nesting though? |
| 17:54 | kotarak | Chousuke: not sure, never tried. |
| 17:54 | kotarak | It also doesn't handle ~@ at the moment, which is sort of annoying. |
| 17:57 | Chousuke | I suppose checking for a (quasi-quote ...) and then just returning the list completely quoted would handle nesting. |
| 17:57 | Chousuke | the clojure reader is pretty weird about it. |
| 17:58 | Chousuke | ,(let [x 5] `(do ~x `(foo bar ~x))) |
| 17:58 | clojurebot | (do 5 (clojure.core/seq (clojure.core/concat (clojure.core/list (quote sandbox/foo)) (clojure.core/list (quote sandbox/bar)) (clojure.core/list sandbox/x)))) |
| 17:59 | kotarak | Yes. I wonder whether this is really necessary. It looks at least scary. |
| 17:59 | Chousuke | it's because syntax-quote is completely read time |
| 17:59 | Chousuke | and the inner ones are expanded first |
| 18:01 | Chousuke | but I think returning '(do 5 (c.c/syntax-quote (foo bar (unquote x)))) should suffice |
| 18:01 | Chousuke | assuming syntax-quote as a macro |
| 18:03 | JAS415 | you can seperate it out into two parts |
| 18:09 | kotarak | Chousuke: Hmmm.. Dunno. I found nesting to be very rare and when I needed it, it didn't solve my problem... ;p |
| 18:12 | JAS415 | clojure bot is being weird |
| 18:12 | JAS415 | ah i'm mistaken |
| 18:13 | JAS415 | ,(let [x 5 inner `(foo bar ~x)] (list 'do x inner)) |
| 18:13 | clojurebot | (do 5 (sandbox/foo sandbox/bar 5)) |
| 18:14 | JAS415 | ,(let [x 5 inner `(foo bar ~x)] `(do ~x ~inner)) |
| 18:14 | clojurebot | (do 5 (sandbox/foo sandbox/bar 5)) |
| 18:15 | JAS415 | (let [x 5 inner `(~'foo ~'bar ~x)] `(do ~x ~inner)) |
| 18:15 | JAS415 | ,(let [x 5 inner `(~'foo ~'bar ~x)] `(do ~x ~inner)) |
| 18:15 | clojurebot | (do 5 (foo bar 5)) |
| 18:27 | drewr | kotarak: I didn't see any support for LIMIT/OFFSET; any plans for that? |
| 18:27 | alrex021 | if I have a list of maps, what is an easiest way to find a map that case a specific value for a given key? |
| 18:27 | clojurebot | maps are functions |
| 18:27 | alrex021 | *case = has |
| 18:28 | kotarak | drewr: yes. there was a patch already a while back, but we noticed, that it somehow got lost. I will check to see whether it still applies. |
| 18:29 | kotarak | alrex021: (first (filter #(= (:key %) value) list-of-maps)) |
| 18:31 | Chousuke | hm |
| 18:32 | Chousuke | surprisingly easy. |
| 18:32 | kotarak | :) |
| 18:32 | Chousuke | I just had to wrap stuff in lists, add a concat and then NOT wrap the spliced stuff in an extra list) |
| 19:05 | hiredman | http://clj-me.blogspot.com/2009/08/what-warn-on-reflection-didnt-tell-you.html |
| 19:45 | wavister | it seems like when one has a function with a variable argument list, and a collection which could serve as those arguments, there should be a way to use the collection as the argument list. I've looked around for it, and I'm not finding. Is it right under my nose? |
| 19:45 | dreish | apply |
| 19:45 | wavister | in ruby it's called splatting |
| 19:45 | dreish | ,(doc apply) |
| 19:45 | clojurebot | "([f args* argseq]); Applies fn f to the argument list formed by prepending args to argseq." |
| 19:45 | dreish | ,(apply + [1 2 3 4]) |
| 19:45 | clojurebot | 10 |
| 19:46 | wavister | okay thanks! i'll work with that |
| 20:43 | tomoj | hmm.. how come I can't barf out the body of a defn? |
| 20:43 | durka42 | say again? |
| 20:43 | tomoj | oh, kill/yank works fine for that |
| 20:43 | dreish | Referring to paredit mode? |
| 20:43 | tomoj | yeah |
| 20:43 | durka42 | oh :) |
| 20:43 | dreish | Or expecting to vomit Lisp? |
| 20:43 | tomoj | hehe |
| 20:44 | dreish | paredit-forward-barf-sexp works for me, with the cursor right before the body of the defn. |
| 20:47 | Makoryu | Is it possible to interactively define functions on the console, and then dump them to a file? |
| 20:48 | dreish | You could if you coded your own repl that did that. |
| 20:50 | dreish | Or you could redefine defn to add the source code as metadata on the var. |
| 20:50 | cemerick | is there a shortcut to ensure that a dispatch value should always have some lowest priority? |
| 20:50 | cemerick | basically, another level of default? |
| 20:51 | cemerick | (I suppose I could just have a :default dispatch, and go from there) |
| 20:52 | tomoj | dreish: what version of paredit? |
| 20:52 | dreish | tomoj: 22 |
| 20:52 | tomoj | forward-barf-sexp just moves to after the defn for me on 21 |
| 20:52 | tomoj | aha |
| 20:53 | tomoj | guess I should figure out how to upgrade |
| 20:59 | tomoj | hmm, actually I can't barf anything |
| 20:59 | tomoj | this is odd |
| 21:08 | tomoj | ./facepalm. I was using M-{ etc instead of C-{ etc |
| 21:17 | ataggart | what is the effect of adding :refer-clojure to the ns? |
| 22:19 | cemerick | ,(doc ns) |
| 22:19 | clojurebot | "([name & references]); Sets *ns* to the namespace named by name (unevaluated), creating it if needed. references can be zero or more of: (:refer-clojure ...) (:require ...) (:use ...) (:import ...) (:load ...) (:gen-class) with the syntax of refer-clojure/require/use/import/load/gen-class respectively, except the arguments are unevaluated and need not be quoted. (:gen-class ...), when supplied, defaults to :name correspo |
| 22:19 | cemerick | eh, not enough |
| 22:19 | cemerick | ataggart: see http://clojure.org/api#ns |
| 22:19 | cemerick | :refer-clojure is only used when you need to exclude or rename some vars in clojure.core |
| 22:20 | cemerick | same options as http://clojure.org/api#refer |
| 22:20 | JAS415 | ,(doc refer) |
| 22:20 | clojurebot | "([ns-sym & filters]); refers to all public vars of ns, subject to filters. filters can include at most one each of: :exclude list-of-symbols :only list-of-symbols :rename map-of-fromsymbol-tosymbol For each public interned var in the namespace named by the symbol, adds a mapping from the name of the var to the var to the current namespace. Throws an exception if name is already mapped to something else in the current nam |
| 22:20 | JAS415 | woowoo |
| 22:34 | ataggart | cemerik: thanks |
| 22:34 | ataggart | cemerick |
| 22:35 | ataggart | bah, I forot about the BAC tonight |
| 22:36 | mebaran151 | the BAC? |
| 23:41 | JAS415 | is there a place to announce clojure libraries? |
| 23:41 | cark | there is a thread on the mailing list |
| 23:42 | cark | http://groups.google.com/group/clojure/browse_thread/thread/affb08d66c048c7f |
| 23:42 | JAS415 | cool |
| 23:42 | JAS415 | i made this: http://github.com/JonathanSmith/CRIB/tree/89a3f4d9c797ef6f4e4f456001ff6a4c5c050064 |
| 23:43 | tomoj | do clojure people use mocks/stubs? |
| 23:43 | tomoj | not sure how those would fit into clojure's paradigm |
| 23:43 | JAS415 | http://github.com/JonathanSmith/CRIB/tree/master |
| 23:43 | JAS415 | this rather |
| 23:43 | JAS415 | what are mocks/stubs? |
| 23:43 | tomoj | well.. mock objects for testing. the objects part doesn't really make sense |
| 23:44 | tomoj | but say I'm testing a function that makes an http request |
| 23:44 | hiredman | you can use binding to alter function behaviour |
| 23:44 | tomoj | I suppose I could just rebind the function to return a fake http response |
| 23:45 | hiredman | ,(binding [+ *] (+ 2 3)) |
| 23:45 | clojurebot | 5 |
| 23:45 | hiredman | grr |
| 23:46 | hiredman | oh |
| 23:46 | hiredman | of course, inlined math op |
| 23:46 | hiredman | ,(binding [+ *] (+ 2 3 4)) |
| 23:46 | clojurebot | 24 |
| 23:46 | hiredman | ,(* 2 3 4) |
| 23:46 | clojurebot | 24 |
| 23:46 | JAS415 | weird |
| 23:47 | JAS415 | probably because + gets inlined |
| 23:47 | JAS415 | ? |
| 23:47 | cark | mhh |
| 23:47 | cark | that's a bug isn't it ? |
| 23:47 | tomoj | from my ruby perspective I would want to rebind the http request function to make sure it was passed the right args |
| 23:47 | JAS415 | depends on your perspective i guess |
| 23:47 | tomoj | and fail the test if not (or if it's not called) |
| 23:47 | cark | mock functions =) |
| 23:48 | JAS415 | really need in-lining levels like in CL |
| 23:48 | tomoj | but I get the feeling that's not the right idea for clojure |
| 23:48 | JAS415 | well tom |
| 23:48 | tomoj | I mean, rhickey doesn't do any testing at all, right? |
| 23:48 | cark | tomoj: when doing pure functional, you know what goes in and check what goes out |
| 23:48 | JAS415 | ideally it would be decomposed so that the http-function and the function calling it are composable |
| 23:49 | JAS415 | if that is the really important part |
| 23:49 | tomoj | oh, I see. so does binding the http request method to return a fake http request sound reasonable? |
| 23:50 | tomoj | problematic there because http request = not pure functional |
| 23:50 | JAS415 | well clojure isn't pure functional because its running on java :-P |
| 23:50 | JAS415 | but you can write code purely functional? |
| 23:51 | tomoj | sure, but not code that does http requests |
| 23:51 | JAS415 | but anyway, i think that sounds reasonable |
| 23:57 | tomoj | I think I'm just hoping TDD will magically make my code pretty |
| 23:58 | tomoj | I'm just going to delete it all and start over :) |