2009-08-18
| 00:10 | cable_ | potentially dumb map/reduce question |
| 00:10 | cable_ | are map operations automatically made concurrent? |
| 00:11 | rlb | cable_: no -- see pmap |
| 00:11 | cable_ | ah thx |
| 00:56 | lowlycoder | i have this really difficult task; I'm not sure if I can do it in clojure -- how do I open a file & read it in? |
| 00:57 | rlb | ? |
| 00:57 | lowlycoder | i'm kidding; how do I read in a file in clojure though? |
| 00:57 | rlb | lowlycoder: text? |
| 00:57 | rlb | (i.e. plain text lines, or other?) |
| 00:58 | lowlycoder | plain text |
| 00:58 | lowlycoder | (doto (java.io.FileReader. filename) ... ) ? |
| 00:58 | lowlycoder | what in ... |
| 00:58 | rlb | (line-seq java-buffered-reader) |
| 00:59 | rlb | Then you have a seq of lines you can do whatever you want with. |
| 00:59 | rlb | (i.e. lazy seq of lines) |
| 00:59 | arbscht | ,(doc slurp) |
| 00:59 | clojurebot | "([f] [f enc]); Reads the file named by f using the encoding enc into a string and returns it." |
| 01:00 | rlb | (line-seq (BufferedReader. (FileReader. file))) |
| 01:00 | rlb | or similar |
| 01:02 | lowlycoder | k#<CompilerException java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol (test.clj:0)> |
| 01:04 | lowlycoder | (import '(api.java.io 'BufferedReader 'FileReader)) |
| 01:04 | lowlycoder | (line-seq (BufferedReader. (FileReader. "test.clj"))) |
| 01:04 | lowlycoder | results in: #<CompilerException java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol (test.clj:0)> |
| 01:04 | rlb | lowlycoder: your import command is wrong. |
| 01:05 | lowlycoder | it's just java.io |
| 01:05 | rlb | (import '(java.io BufferedReader FileReader)) |
| 01:05 | lowlycoder | wonderful; thanks |
| 01:08 | lowlycoder | how do I convert a string to a interger? |
| 01:09 | lowlycoder | rather, a number, it may be either an integer or a floating point |
| 01:10 | lowlycoder | clojure's # ... % notation for lambdas is prettty cool |
| 01:10 | arbscht | ,(class (read-string "99.9")) |
| 01:10 | clojurebot | java.lang.Double |
| 01:11 | arbscht | read-string may be too general (unsafe with untrusted input) |
| 01:12 | arbscht | ,(Integer/parseInt "9") |
| 01:12 | clojurebot | 9 |
| 01:12 | lowlycoder | why unsafe? does it execute it too? |
| 01:13 | lowlycoder | does #(... ) notation nest? i.e. the % match only the innermost # |
| 01:14 | lowlycoder | ack, nested #() are not allowed :-( |
| 01:18 | replaca | lowlycoder: but nested (fn [x y z] ...) lambdas are allowed |
| 01:20 | lowlycoder | why can't I (cons 1 2) but can (cons 1 '(2 3)) ? |
| 01:20 | clojurebot | http://clojure.org/rationale |
| 01:20 | lowlycoder | does cons must return a list? |
| 01:21 | rlb | I'm not sure clojure handles cons the same way as scheme/lisp. |
| 01:21 | arbscht | cons returns a seq |
| 01:23 | replaca | ,(class (cons 1 '(1 2))) |
| 01:23 | clojurebot | clojure.lang.Cons |
| 01:24 | replaca | lowlycoder: a clojure cons-cell can only have a seq in the cdr, I believe |
| 01:24 | tomoj | ,(class (cons 1 nil)) |
| 01:25 | clojurebot | clojure.lang.PersistentList |
| 01:25 | replaca | lowlycoder: part of the challenge for lispers coming to clojure is to let go of things we assume from our days in CL or scheme |
| 01:26 | lowlycoder | (class (map #(re-split #" " %) (line-seq (BufferedReader. (FileReader. "m393/m393.off"))))) |
| 01:26 | lowlycoder | why is this a LazySeq, and why can't I take the car of it? |
| 01:27 | tomoj | line-seq is lazy |
| 01:27 | replaca | lowlycoder: map always returns a lazyseq |
| 01:27 | lowlycoder | how do I take the care of a lazyseq |
| 01:27 | replaca | (first foo) |
| 01:28 | lowlycoder | so now, first & rest is the standard way to take items from a sequence, of any form, and car/cdr is just for persistent lists? |
| 01:28 | arbscht | ,(doc car) |
| 01:28 | clojurebot | "/;nil; " |
| 01:28 | replaca | lowlycoder: what do you mean car? clojure has no such function (and really doesn't have the exact same concept) |
| 01:28 | lowlycoder | wtf, I don't even have car? |
| 01:29 | arbscht | yes |
| 01:29 | tomoj | there are no cons cells, what do you need car for.. |
| 01:29 | lowlycoder | i'm just used to using it |
| 01:29 | replaca | lowlycoder: deep breath... you're leaving common lisp now... buckle your seatbelt and enjoy the ride :-) |
| 01:29 | lowlycoder | well, this is why they created define-macro :-D |
| 01:30 | replaca | lowlycoder: yeah, don't go there. you'll be paddling upstream |
| 01:30 | replaca | lowlycoder: try to really get into the "clojure way" and then see if you like it once you've got it |
| 01:30 | lowlycoder | i like the java libraries :-D |
| 01:31 | replaca | you might or might not, but fighting it pretty much guarantees you'll end up in a place that won't make you happy |
| 01:33 | replaca | if it turns out that you want Lisp on the java libs there are other solutions (kawa, for instance) that could get you there in a more familiar envinronment |
| 01:33 | replaca | a lot of us have realized that clojure is awfully well put together, once we let go of what we're used to |
| 01:34 | replaca | (and I know - I wrote the CL compatible format for clojure :-)) |
| 01:34 | arbscht | if you haven't already, watch rich's presentations on blip.tv where he explains how clojure is different from CL or Scheme and the rationale behind the changes |
| 01:36 | tomoj | replaca: does it have ~r? |
| 01:38 | rlb | ...or, if you've spent much quality time with posix threads, his talk covering the ant demo... |
| 01:38 | rlb | "quality" |
| 01:48 | lowlycoder | user=> (def x '(1 2 3 4 5)) |
| 01:48 | lowlycoder | #'user/x |
| 01:48 | lowlycoder | user=> (map print x) |
| 01:48 | lowlycoder | (12nil 3nil 4nil 5nil nil) |
| 01:48 | lowlycoder | doesnt' map generate lazy sequences? |
| 01:48 | lowlycoder | why does it print 1 2 3 4 5? |
| 01:48 | rlb | lowlycoder: because the repl needs to print the result? |
| 01:48 | lowlycoder | user=> (def y (map print x)) |
| 01:48 | lowlycoder | #'user/y |
| 01:48 | lowlycoder | user=> y |
| 01:48 | lowlycoder | (12nil 3nil 4nil 5nil nil) |
| 01:49 | lowlycoder | this is intresting, on future 'y' 's, it only shows the nils |
| 01:49 | lowlycoder | map really is lazy; that is good to know |
| 01:49 | lowlycoder | any other surprises I should know? |
| 01:49 | rlb | hard to know in advance what might surprise you ;> |
| 01:49 | rlb | If you're coming from s |
| 01:50 | rlb | Scheme, there's no TCO. |
| 01:50 | rlb | (tail call optimization), at least no guaranteed TCO. |
| 01:50 | rlb | You have to use loop/recur explicitly. |
| 01:50 | lowlycoder | that i also know |
| 01:50 | lowlycoder | what else? |
| 01:51 | rlb | Not sure offhand. Stuart's book might be helpful. |
| 01:51 | rlb | And I did find the ant video quite interesting. |
| 01:56 | lowlycoder | how do I convert _anything_ to a string? |
| 01:57 | lowlycoder | str |
| 01:57 | lowlycoder | whoa, that is so easy |
| 02:00 | arbscht | lowlycoder: as I said, watch rich's presentations on blip.tv. that might clear up a number of potential surprises |
| 02:01 | hiredman | lowlycoder: str doesn't really work on lazy sequences |
| 02:01 | hiredman | you have to use prn-str |
| 02:02 | hiredman | ,(str (map inc (range 10))) |
| 02:02 | clojurebot | "clojure.lang.LazySeq@c5d38b66" |
| 02:02 | hiredman | ,(prn-str (map inc (range 10))) |
| 02:02 | clojurebot | "(1 2 3 4 5 6 7 8 9 10)\n" |
| 02:02 | hiredman | ,(pr-str (map inc (range 10))) |
| 02:02 | clojurebot | "(1 2 3 4 5 6 7 8 9 10)" |
| 02:02 | hiredman | this is unfortunate, and was not the case once |
| 02:03 | lowlycoder | can I download these blip.t episodes? |
| 02:03 | hiredman | yes |
| 02:04 | lowlycoder | how? on clojure.blip.tv i see the movie but can't see the link |
| 02:04 | hiredman | lower right of the page there is a menu called "files" or something similar |
| 02:04 | hiredman | it has links to download mp4s or flvs |
| 02:06 | lowlycoder | even after clicking on deatils, I see it it not |
| 02:07 | hiredman | ~blip.tv |
| 02:07 | clojurebot | blip.tv is http://clojure.blip.tv/ |
| 02:07 | lowlycoder | i'm looking at clojure.blip.tv |
| 02:08 | hiredman | lowlycoder: you have to open one of the videos |
| 02:08 | lowlycoder | i clicked on play on one of them |
| 02:08 | lowlycoder | I don't see where the link is |
| 02:08 | hiredman | and on the page for the video there is a menu called "files and links" |
| 02:08 | hiredman | click on it |
| 02:10 | lowlycoder | hmm, i actuallllly don't see files and links |
| 02:10 | lowlycoder | i'm using firefox 3.0 |
| 02:10 | lowlycoder | on ubuntu |
| 02:10 | hiredman | on the lower right of the page |
| 02:11 | lowlycoder | let's binary search; above or below the line that syas " Subscribe to this show via iTunes, Miro, channels.com or RSS" ? |
| 02:12 | hiredman | I think you don't actually have the page for the video open |
| 02:12 | lowlycoder | i'm an idiot |
| 02:12 | lowlycoder | i see it now |
| 02:32 | replaca | tomoj: are you still here? yup, it has full ~r support. |
| 02:36 | tomoj | nice |
| 02:36 | tomoj | did you do that yourself or does java know how to do that somewhere? |
| 02:44 | lowlycoder | whoa, so let works like let* |
| 02:45 | hiredman | yes |
| 02:48 | replaca | tomoj: sorry, i'm jumping in and out |
| 02:48 | replaca | wrote it all myself |
| 02:49 | replaca | doc is here: http://richhickey.github.com/clojure-contrib/doc/pprint/CommonLispFormat.html |
| 02:50 | replaca | and api overview is on the pprint page: http://richhickey.github.com/clojure-contrib/pprint-api.html#pprint/cl-format |
| 02:52 | lowlycoder | is there a wya to convert a string to an integer besides read-string? |
| 02:53 | hiredman | ~jdoc Integer |
| 02:53 | hiredman | er |
| 02:54 | hiredman | anyway, there are a few methods there |
| 02:54 | hiredman | Integer also has a constructor that takes a string |
| 02:54 | replaca | ,(Integer/parseInt "34") |
| 02:54 | clojurebot | 34 |
| 02:57 | lowlycoder | how do I get the length of a sequence? |
| 02:57 | lowlycoder | length does not seem to be bound |
| 02:57 | hiredman | ,(doc count) |
| 02:57 | clojurebot | "([coll]); Returns the number of items in the collection. (count nil) returns 0. Also works on strings, arrays, and Java Collections and Maps" |
| 02:58 | lowlycoder | if I have (def x '(1 2 3 4 5 6 7)) |
| 03:00 | lowlycoder | is there anyway I do a binding of the form [y z] |
| 03:00 | lowlycoder | to have z = '(2 3 4 5 6 7) ? |
| 03:00 | lowlycoder | [y z] gets z = 2 |
| 03:00 | lowlycoder | and I can't do [y . z] |
| 03:00 | hiredman | ,let [[y & z] '(1 2 3 4 5 6 7)] z) |
| 03:00 | clojurebot | java.lang.Exception: Can't take value of a macro: #'clojure.core/let |
| 03:00 | hiredman | bah |
| 03:01 | hiredman | ,(let [[y & z] '(1 2 3 4 5 6 7)] z) |
| 03:01 | clojurebot | (2 3 4 5 6 7) |
| 03:03 | lowlycoder | nice; thans |
| 03:04 | hiredman | ~destructuring |
| 03:04 | clojurebot | destructuring is http://clojure.org/special_forms#let |
| 03:08 | lowlycoder | is there a builtin for taking a list and splitting it into the first 100 elements and the rest? |
| 03:08 | hiredman | ,(doc split) |
| 03:08 | clojurebot | "clojure.contrib.str-utils2/split;[[s re] [s re limit]]; Splits string on a regular expression. Optional argument limit is the maximum number of splits." |
| 03:08 | hiredman | lowlycoder: there are docs on clojure.org |
| 03:09 | hiredman | ,(doc split-with) |
| 03:09 | clojurebot | "([pred coll]); Returns a vector of [(take-while pred coll) (drop-while pred coll)]" |
| 03:09 | hiredman | hmm |
| 03:09 | lowlycoder | hiredman: i didn't know what to search for :-) |
| 03:10 | hiredman | (fn [n s] [(take n s) (drop n s)]) |
| 03:11 | hiredman | ah |
| 03:11 | hiredman | ,(doc split-at) |
| 03:11 | clojurebot | "([n coll]); Returns a vector of [(take n coll) (drop n coll)]" |
| 03:11 | hiredman | http://clojure.org/sequences |
| 03:14 | lowlycoder | take & drop, cool :-) |
| 03:20 | lowlycoder | why does (doc str) work but (doc re-split) not? |
| 03:21 | hiredman | ,(doc re-split) |
| 03:21 | clojurebot | "clojure.contrib.str-utils/re-split;[[pattern string] [pattern string limit]]; Splits the string on instances of 'pattern'. Returns a sequence of strings. Optional 'limit' argument is the maximum number of splits. Like Perl's 'split'." |
| 03:21 | hiredman | re-split is in contrib |
| 03:21 | hiredman | so you might not have it loaded |
| 03:21 | lowlycoder | nice; thanks |
| 03:22 | hamza | hey guys, i can not call the following method from clojure second argument seems to be optional. http://java.sun.com/javase/6/docs/api/javax/swing/RowFilter.html#regexFilter%28java.lang.String,%20int...%29 |
| 03:22 | replaca | lowlycoder: for contrib refs see: http://richhickey.github.com/clojure-contrib/index.html |
| 03:22 | hiredman | hamza: you have to pass in an array |
| 03:22 | lowlycoder | web pages is cool, but I like accessing repl instead |
| 03:22 | hiredman | even an empty one |
| 03:23 | lowlycoder | user=> (doc re-split) |
| 03:23 | lowlycoder | ------------------------- |
| 03:23 | lowlycoder | clojure.contrib.str-utils/re-split |
| 03:23 | lowlycoder | ([pattern string] [pattern string limit]) |
| 03:23 | lowlycoder | ... it works |
| 03:23 | hamza | i am calling like so (RowFilter/regexFilter "input" 0 ) |
| 03:23 | replaca | lowlycoder: you've got to load the namespace your interested in then (as hiredman pointed out) |
| 03:23 | lowlycoder | I did :-) |
| 03:23 | lowlycoder | leading to my comment above of "nice; thanks" |
| 03:23 | hiredman | hamza: (into-array Integer/TYPE [0]) |
| 03:23 | lowlycoder | ah, taht could have been interpreted as hiredman's use of clojurebot |
| 03:23 | replaca | but the web page tells you about things that aren't loaded |
| 03:24 | replaca | yeah, hiredman has a "special" doc function, I think |
| 03:24 | hiredman | hamza: java varargs are syntactic suger for passing an array |
| 03:24 | hamza | kk it worked why is the syntax different? |
| 03:25 | hiredman | clojure doesn't have the syntactic sugar |
| 03:25 | alinp | hi |
| 03:25 | alinp | I have an agent defined like this: |
| 03:25 | alinp | (def x (agent 0)) |
| 03:25 | alinp | and want to do this: |
| 03:26 | alinp | (send-off x #(+ %1 %2) 3 4) |
| 03:26 | alinp | @x -> 7 |
| 03:26 | alinp | what's wrong with it ? |
| 03:26 | alinp | what I'm doing wrong here ? |
| 03:26 | hiredman | ,(doc send-off) |
| 03:26 | clojurebot | "([a f & args]); Dispatch a potentially blocking action to an agent. Returns the agent immediately. Subsequently, in a separate thread, the state of the agent will be set to the value of: (apply action-fn state-of-agent args)" |
| 03:26 | hiredman | ↑ |
| 03:27 | hiredman | in what you described, the function send-off needs to take three arguments |
| 03:27 | alinp | it will use the initial state as the 1st param ? |
| 03:28 | alinp | well .. I send 3 arguments |
| 03:28 | alinp | but .. still, doesn't work |
| 03:28 | hiredman | the function you send-off |
| 03:28 | alinp | (#<IllegalArgumentException java.lang.IllegalArgumentException: Wrong number of args passed to: user$eval--335$fn>) |
| 03:28 | hiredman | ^- |
| 03:28 | hiredman | you are send-off'ing a 2 arg function where it needs a three arg function |
| 03:29 | alinp | whay is that ? |
| 03:30 | hiredman | is the docstring not clear? (apply action-fn state-of-agent args) |
| 03:30 | hiredman | args is [3 4] |
| 03:30 | alinp | ah, ok then |
| 03:30 | alinp | thanks |
| 03:30 | alinp | missed that |
| 03:42 | lowlycoder | user=> (doc do) |
| 03:42 | lowlycoder | Please see http://clojure.org/special_forms#do |
| 03:42 | lowlycoder | wtf, if you have room for an online documentation system, why give me a URL? |
| 03:42 | hiredman | do is a special form, so there is no var to attach a docstring to |
| 03:43 | alinp | hiredman: and this means that all special forms are "documented" this way ? |
| 03:44 | lowlycoder | user=> (doc do) |
| 03:44 | lowlycoder | ------------------------- |
| 03:44 | lowlycoder | do |
| 03:44 | hiredman | all six or seven of them |
| 03:44 | alinp | ah, ok |
| 03:44 | lowlycoder | if the system can look it up to print a message, why can't it put the doc there? |
| 03:45 | hiredman | lowlycoder: *shrug* |
| 03:45 | hiredman | it would have to be put inside the doc lookup function |
| 03:46 | alinp | user=> (doc doc) |
| 03:46 | alinp | ------------------------- |
| 03:46 | alinp | clojure.core/doc |
| 03:46 | alinp | ([name]) |
| 03:46 | alinp | Macro |
| 03:46 | alinp | Prints documentation for a var or special form given its name |
| 03:46 | alinp | nil |
| 03:46 | alinp | " or special form" |
| 03:46 | alinp | :) |
| 03:47 | Fossi | how about not pasting so much stuff in here? both of you. thanks. |
| 03:47 | alinp | ,(doc doc) |
| 03:47 | clojurebot | "([name]); Prints documentation for a var or special form given its name" |
| 03:47 | hiredman | ditto |
| 03:47 | hiredman | ~url |
| 03:47 | clojurebot | Excuse me? |
| 03:47 | hiredman | er |
| 03:47 | hiredman | lisppaste8: url |
| 03:47 | lisppaste8 | To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste. |
| 03:48 | hiredman | ~def print-special-doc |
| 03:49 | hiredman | god github is slow |
| 03:51 | arbscht | ,(doc foo) |
| 03:51 | clojurebot | "/;nil; " |
| 03:52 | arbscht | hiredman: thoughts on a patch like this so clojurebot says something sensible when the symbol isn't found? http://gist.github.com/169596 |
| 03:53 | hiredman | I think you reverse d that patch |
| 03:54 | hiredman | anyway, yes, something should be done about it |
| 03:54 | arbscht | so I did, yes |
| 03:54 | arbscht | I can fork clojurebot and do a pull request if you want |
| 03:55 | hiredman | I'd have it reply with one of the befuddled responses |
| 03:55 | arbscht | heh |
| 03:56 | hiredman | if you want, sure, I'd hate to put you through the trouble for something so small |
| 03:57 | arbscht | might as well, could be handy in the future |
| 03:59 | arbscht | er, if github co-operates, that is. |
| 04:00 | hiredman | ,(doc foo) |
| 04:00 | clojurebot | "I don't understand." |
| 04:00 | arbscht | :-) |
| 04:00 | hiredman | arbscht: abort, abort! |
| 04:07 | Fossi | clojurebot: is weird in speaking far too many languages |
| 04:07 | clojurebot | It's greek to me. |
| 04:08 | lowlycoder | does clojure have c++ equiv of /* ... */ |
| 04:09 | Fossi | C-SPC M-C-; |
| 04:09 | Fossi | that is: i don't think so |
| 04:10 | Fossi | you could write a macro for it |
| 04:10 | hiredman | there is commet |
| 04:10 | hiredman | comment |
| 04:10 | Fossi | ah, right |
| 04:10 | hiredman | but comment is a macro, not really a comment |
| 04:10 | arbscht | clojurebot: def defn |
| 04:11 | Fossi | (10:13:35) arbscht: clojurebot: def defn |
| 04:11 | Fossi | (10:13:37) clojurebot: (notice) defn: http://tinyurl.com/p7c7c4 |
| 04:11 | Fossi | (10:13:49) defn_ [i=defn@anapnea.net] entered the room. |
| 04:11 | Fossi | ;D |
| 04:11 | arbscht | ha |
| 04:12 | arbscht | the README says google code still |
| 04:15 | AWizzArd | lowlycoder: if you want to comment out a whole form just put #_ in front of it |
| 04:15 | AWizzArd | ,(println (+ 1 2) #_(+ 3 4) #_(+ 5 6)) |
| 04:15 | clojurebot | 3 |
| 04:15 | AWizzArd | ,(println (+ 1 2) #_(+ 3 4) (+ 5 6)) |
| 04:15 | clojurebot | 3 11 |
| 04:16 | lowlycoder | how does #_ work? |
| 04:16 | lowlycoder | i suspect it's a macro for something else |
| 04:16 | AWizzArd | The comment macro can also be fine, but you should be aware that it will evaluate to nil. |
| 04:17 | AWizzArd | lowlycoder: it is a reader macro |
| 04:17 | lowlycoder | and it turns out to comment something out |
| 04:17 | lowlycoder | that evalutes to nil? |
| 04:17 | AWizzArd | the reader reads the form and throws it away |
| 04:17 | AWizzArd | ,(str (+ 1 2) (comment (+ 3 4)) (+ 5 6)) |
| 04:17 | clojurebot | "311" |
| 04:17 | AWizzArd | okay, stupid example as str ignores the nil |
| 04:18 | AWizzArd | ,(+ 1 (comment 2)) |
| 04:18 | clojurebot | java.lang.NullPointerException |
| 04:18 | AWizzArd | but #_ does not get evaluated |
| 04:18 | AWizzArd | the reader consumes the form, but won't eval it |
| 04:19 | arbscht | comment is nice at the top level for documentary sections etc |
| 04:19 | AWizzArd | yes |
| 04:25 | hamza | hey guy's, if i use proxy to extend JButton how can i pass variables to its contructor? |
| 04:28 | lowlycoder | AWizzArd: thanks |
| 04:30 | d2dchat | is there a protected division operator? |
| 04:30 | d2dchat | like % ? |
| 04:30 | d2dchat | I know traditionally that is used for modulus but |
| 04:30 | d2dchat | it can also be protected division |
| 04:31 | d2dchat | any function like that avail? |
| 04:38 | mebaran151 | what do you mean by protected division: the regular clojure one's check for overflow I think |
| 04:38 | mebaran151 | and div by zero |
| 04:39 | Fossi | hamza: ,(doc proxy) |
| 04:42 | lowlycoder | so if I (print ...) something in a child thread, it doesn't pop up in the main repl stdout? |
| 04:44 | Fossi | i don't think so |
| 04:44 | Fossi | with slime you can switch that |
| 04:45 | Fossi | not sure for the repl |
| 04:56 | Neronus | lowlycoder: You could try passing *out* of the repl to the thread at its creation (it has some main function, I guess?) and then binding it in the main function or around the main function |
| 04:59 | Neronus | lowlycoder: (send-off (agent [*out* "foo"]) (fn [[out o]] (binding [*out* out] (println o)))) something like that |
| 05:00 | hiredman | lowlycoder: use println instead of print |
| 05:00 | hiredman | or if you must use print, call flush |
| 05:03 | Neronus | hiredman appears to be right for child threads, as (.run (Thread. #^Callable (fn [] (println "foo")))) prints to the *out* of its creating thread |
| 05:03 | hiredman | :| |
| 05:04 | hiredman | you know no Thread constructor takes a Callable right? |
| 05:08 | Neronus | You're right, I meant runnable of course. Works either way :) |
| 05:09 | hiredman | I doubt a type hint there would ever give you a performance increase, so even with #^Runnable, best to omit the hint |
| 05:22 | Neronus | This wan't about performance, this was about a memory associated wrong. With ThreadPoolExecutor.sumbit I had to do that declaration, or clojure didn't know which .submit I meant (I didn't care, but how should the compiler know that?) |
| 05:25 | lowlycoder | this is really dumb |
| 05:26 | lowlycoder | how do I load in "test.clj" from the current directory |
| 05:26 | lowlycoder | (use 'test) is not loading it in |
| 05:27 | hiredman | ,(doc load) |
| 05:27 | clojurebot | "([& paths]); Loads Clojure code from resources in classpath. A path is interpreted as classpath-relative if it begins with a slash or relative to the root directory for the current namespace otherwise." |
| 05:27 | hiredman | ,(doc load-file) |
| 05:27 | clojurebot | "([name]); Sequentially read and evaluate the set of forms contained in the file." |
| 05:32 | lowlycoder | I have gears.clj in current directory; I can do (use '(gears)) ; gears.clj has a function (go) defined in it ... why can't I call (gears.go) ? |
| 05:35 | Neronus | You can do either (go) after use because you refer each defined symbol of the namespace gears in the namespace doing the (use ...), or you can do gears/go, which is the way to refer function go of namespace gears |
| 05:36 | lowlycoder | (ns gears) |
| 05:37 | lowlycoder | that is the first line of gears.clj |
| 05:37 | lowlycoder | do i need to export go? |
| 05:37 | Neronus | na, if you defined go by (def) or (defn) its exported |
| 05:37 | lowlycoder | hmm, user=> (use '(gears)) |
| 05:37 | lowlycoder | nil |
| 05:37 | lowlycoder | user=> gears/go |
| 05:37 | lowlycoder | java.lang.Exception: No such namespace: gears (NO_SOURCE_FILE:0) |
| 05:38 | lowlycoder | ~/genesis:master*$ cat gears.clj| grep go |
| 05:38 | lowlycoder | (defn go [] |
| 05:38 | clojurebot | I don't understand. |
| 05:39 | Neronus | lowlycoder: (use 'gears) |
| 05:40 | lowlycoder | user=> (use 'gears) |
| 05:40 | lowlycoder | java.io.FileNotFoundException: Could not locate gears__init.class or gears.clj on classpath: (NO_SOURCE_FILE:0) |
| 05:41 | lowlycoder | nice, it works now |
| 05:42 | lowlycoder | i had incorretly set up class paths |
| 05:42 | Neronus | great :) |
| 07:18 | Neronus | Does anyone here know if the loading of a string literal via ldc (bytecode instruction) causes the class java.lang.String to be loaded? |
| 07:22 | Neronus | Ah, found it. thanks |
| 07:30 | Fossi | Neronus: so? |
| 07:51 | Neronus | If the constant pool entry to be loaded by ldc is to be loaded for the first time, a new String object will be constructed. Thus, String has to be loaded |
| 07:52 | Neronus | JVMS 5.1 |
| 08:55 | AWizzArd | I have (def x {:abc "ABC"}) and defined an inline accessor for it: (definline abc [obj] `(:abc ~obj)). So (abc x) ==> "ABC". |
| 08:56 | AWizzArd | I set *warn-on-reflection* to true. Now (.toLowerCase (abc x)) gives me a warning as expected. But unfortunately (.toLowerCase #^String (abc x)) also does. If abc is not an inline macro but a function then the type hint works. |
| 08:56 | AWizzArd | Any idea why it does not work for the inline? |
| 08:57 | Chouser | Use macroexpand and *print-meta* to see what the compiler actually consumes. |
| 08:58 | Chouser | hm, except macroexpand doesn't work on :inline |
| 08:58 | AWizzArd | Yes, it's strange, I can't macroexpand it. |
| 08:58 | AWizzArd | right |
| 08:58 | Chousuke | maybe you need to do #^String `(:abc ~obj) |
| 08:58 | AWizzArd | In the inline itself? I will try that. |
| 08:58 | Chousuke | ,(meta #^String `test) |
| 08:59 | clojurebot | nil |
| 08:59 | Chousuke | hmm |
| 08:59 | Chouser | well, I'm pretty sure this is what's happening: |
| 08:59 | Chousuke | ,(meta #^String 'test) |
| 08:59 | clojurebot | nil |
| 08:59 | Chousuke | :/ |
| 08:59 | Chouser | the String :tag is put on the list (abc x). Then the :inline is expanded, and the results replace the old list |
| 08:59 | AWizzArd | Chousuke: oh cool trick, it works when I do (definline abc [obj] `#^String (:abc ~obj)) |
| 09:00 | Chouser | those new results have no tag, thus the reflection warning |
| 09:00 | Chouser | ,(meta '#^String test) |
| 09:00 | clojurebot | {:tag String} |
| 09:00 | AWizzArd | Yes, that could be it Chouser. But good that Chousukes trick works. Thanks you two. |
| 09:01 | Chouser | rhi<tab> ... rhi<tab> ... *sigh* |
| 09:02 | Chousuke | I just added autofn support for my reader. |
| 09:02 | AWizzArd | Chousuke: what is that? |
| 09:02 | Chousuke | #() |
| 09:02 | Chousuke | the worker function is *ugly* but at least it works :P |
| 09:02 | AWizzArd | Chouser: yes, he takes some days off it seems :) |
| 09:04 | Chouser | AWizzArd: he said a week. It's now been more. |
| 09:04 | Chouser | how dare he. ;-) |
| 09:05 | Chouser | oh, hooray. |
| 09:06 | drewr | rhickey: welcome back! |
| 09:06 | Jenncaspot | hi |
| 09:06 | rhickey | hi all! |
| 09:06 | Chouser | Chousuke: as soon as it passes the test suite, I'll start using it. |
| 09:06 | Jenncaspot | i am new here |
| 09:06 | Chouser | Jenncaspot: welcome. |
| 09:07 | Jenncaspot | thanks |
| 09:07 | Jenncaspot | this is my first time to chat |
| 09:07 | AWizzArd | oh funny, rhickey, only 2 minutes ago we were talking about you and your holidays :-) |
| 09:07 | AWizzArd | wb |
| 09:08 | rhickey | AWizzArd: that would be holiday (singular), first without working on Clojure since I released it |
| 09:10 | AWizzArd | It's a good thing.. holiday without your child - nice to have from time to time. |
| 09:59 | LauJensen | rhickey: In your absence I updated http://en.wikipedia.org/wiki/Functional_programming to include Clojure under functional languages used in industry - dunno how they could have forgot :( |
| 10:00 | rhickey | LauJensen: putting it first probably isn't a good idea |
| 10:00 | LauJensen | Oh. I felt it would be wrong to put it behind any of the inferior languages in the same category. |
| 10:01 | LauJensen | If you had updated the site, then I could see a potential problem :) |
| 10:02 | rhickey | as the most recent entrant, Clojure should go last |
| 10:03 | rhickey | being pushy won't win Clojure any converts, and may seem fanboyish, and thus less credible |
| 10:04 | rhickey | let's stay modest, as a community |
| 10:04 | Fossi | i think the list should be alphabetically ordered |
| 10:04 | Fossi | which it also seems to be |
| 10:05 | LauJensen | Its your language and therefore your call. I just feel it would be wrong to put Clojure in a less visible position and thereby perhaps leading some down the wrong path first. I'd hate to be the cause of somebody wasting a year in F# because I tried to display a false sense of humility. I know it seems like I'm overthinking something as simple as the order of mention, but I would really feel bad if it happend anyway |
| 10:06 | Fossi | then again such lists with "... including [list goes here]" are always a discussion topic anyway |
| 10:07 | Fossi | and a reference would surely help |
| 10:07 | LauJensen | rhickey: I've updated the page now |
| 10:07 | Fossi | especially since the other mentions have them |
| 10:07 | LauJensen | its the last mention, although in uppercase red letters size 72 |
| 10:07 | rhickey | LauJensen: thanks |
| 10:07 | LauJensen | np |
| 10:09 | Fossi | LauJensen: also check the "R and S-Plus" part of the discussion page |
| 10:11 | LauJensen | I dont have the patience for those types of discussions |
| 10:12 | Fossi | yes, but you seem to have the time to make an edit |
| 10:12 | Fossi | so imho you either do neither or both |
| 10:12 | Fossi | but be free to be reverted |
| 10:18 | Fossi | i want to modify the values in a map. anybody got a merge-with example or can tell me how to return a (new?) MapEntry? |
| 10:19 | tomoj | what do you want a MapEntry for? |
| 10:19 | AWizzArd | Fossi: maybe update-in can do the job |
| 10:25 | Fossi | Is the documentation grammatically wrong or is it my brain being too stupid to parse it? |
| 10:25 | Fossi | ,(doc update-in) |
| 10:25 | clojurebot | "([m [k & ks] f & args]); 'Updates' a value in a nested associative structure, where ks is a sequence of keys and f is a function that will take the old value and any supplied args and return the new value, and returns a new nested structure. If any levels do not exist, hash-maps will be created." |
| 10:26 | Chouser | ,(assoc {:a 0, :b 1, :c 2} :b 99) |
| 10:26 | clojurebot | {:a 0, :b 99, :c 2} |
| 10:26 | Chouser | Fossi: do you want more than that? |
| 10:27 | Fossi | also ,(update-in {:foo 'foo :bar 'bar} #(do (println %) %)) doesn't work so well |
| 10:27 | Fossi | for every val in the map, i want to add something to it |
| 10:27 | Chouser | add as in + or as in conj? |
| 10:27 | Fossi | or i might even replace it |
| 10:28 | Chouser | ,(into {} (for [[k v] {:a 0, :b 1, :c 2}) [k (+ 100 v)])) |
| 10:28 | clojurebot | Unmatched delimiter: ) |
| 10:28 | Chouser | ,(into {} (for [[k v] {:a 0, :b 1, :c 2}] [k (+ 100 v)])) |
| 10:28 | clojurebot | {:c 102, :b 101, :a 100} |
| 10:28 | Fossi | ,(update-in {:foo 'foo :bar 'bar} #(do (println %) %)) |
| 10:28 | clojurebot | java.lang.IllegalArgumentException: Wrong number of args passed to: core$update-in |
| 10:28 | Fossi | ,(update-in {:foo 'foo :bar 'bar} #(do (println %) %) nil) |
| 10:28 | clojurebot | java.lang.UnsupportedOperationException: nth not supported on this type: sandbox$eval__2411$fn__2413 |
| 10:29 | Fossi | seems k &ks is not optional, but has to be a vec |
| 10:29 | Chouser | update-in is for nested maps |
| 10:29 | Chouser | and probably not the best choice if you're going to change every value of the map |
| 10:30 | Chouser | if you're going to touch every value, it's probably best to iterate over them (using 'map', 'for', etc.) and then build them back into a map using 'into', as I demonstrated. |
| 10:32 | Fossi | yeah, i had a map there to start with, but got confused how to make it keep the map type |
| 10:33 | Fossi | "map" |
| 10:33 | Chouser | If you want to keep the particular variety of map you started with (sorted or whatever), you can use (into (empty my-map) ...) instead of (into {} ...) |
| 10:47 | cemerick | rhickey: welcome back :-) |
| 10:55 | cschreiner | On the Macintosh; In Emacs 22 (Carbon Port, CVS version) you can use the variable ‘mac-control-modifier’ to remap the Control key. |
| 10:55 | cschreiner | What denotes the caps-lock key? |
| 10:57 | Chousuke | I think you need to remap caps-lock from the keyboard settings. |
| 10:57 | cschreiner | (wrong group, heh) |
| 10:57 | cschreiner | So I cannot do this locally for emacs only |
| 10:58 | Chousuke | try M-x apropos capslock? :P |
| 10:58 | clojurebot | x is y |
| 10:59 | Chousuke | I mapped mine through the keyboard preferences to control and then in emacs I swap meta with control |
| 10:59 | Chousuke | I need to be careful with cmd-w now though :P |
| 10:59 | cschreiner | hehe |
| 11:00 | Chousuke | in emacs it'll be ctrl-w. but in other apps it'll close the window ;( |
| 11:03 | Chousuke | cschreiner: do you happen to know how I turn *off* eldoc-mode? ;( it's slowing down scrolling in my buffers |
| 11:03 | Chousuke | there's turn-on-eldoc-mode but no turn-off... |
| 11:03 | tomoj | M-x eldoc-mode ? |
| 11:06 | Chousuke | ah, it works as a toggle. duh |
| 11:07 | Neronus | For gtk-apps, you can tell gtk to use emacs like keybindings... e.g. pidgin ignores that though and closes the window none the less |
| 11:08 | Neronus | again, IIRC |
| 11:08 | Fossi | i have [[k1 v1] ...] and [[k1 x1] ...] and like to merge them as [k1 [v1 x1] ...]. any hints? |
| 11:09 | Chousuke | easiest to make those into maps first, then use (merge-with vector ...) |
| 11:11 | Chousuke | ,(vec (merge-with vector (into {} [[:k1 1] [:k2 2]]) (into {} [[:k1 2] [:k3 3]]))) |
| 11:11 | clojurebot | [[:k3 3] [:k2 2] [:k1 [1 2]]] |
| 11:13 | Chousuke | hmm |
| 11:14 | Chousuke | I wonder if there's something wrong with the way clojure-mode (or clojure-swank) does eldoc. it doesn't cause lag with elisp :/ |
| 11:14 | Fossi | thanks |
| 11:20 | Chouser | Hm, I'd like to use the timeout arg to promise's CountDownLatch.await() |
| 11:24 | danlarkin | Hey LauJensen, why the move to gitorious? |
| 11:24 | alrex021 | I have a test in attr-map of my function: (defn #^{:test (fn [] (is (= (add3 6) 9)))} add3 [n] (+ 4 n)) |
| 11:24 | alrex021 | I get a FAIL in clojure.lang.PersistentList$EmptyList@1 (NO_SOURCE_FILE:1) as expected....but I also get a :ok as a result |
| 11:25 | LauJensen | danlarkin: Speed and consistent use of markup all around the site. |
| 11:25 | LauJensen | (hey btw) |
| 11:25 | alrex021 | expected: (= (add3 6) 9) actual: (not (= 10 9)) ....and then on last line REPL I see .... :ok ...how does tht make sense? |
| 11:27 | danlarkin | LauJensen: I see, good reasons |
| 11:28 | Chouser | alrex021: looks like a mismatch between 'is' and 'test' |
| 11:28 | stuartsierra | alrex021: you're mixing clojure.test with the older clojure.core/test. |
| 11:28 | Chouser | alrex021: 'is' returns true or false. 'test' expects an exception on failure, not just 'false' |
| 11:28 | stuartsierra | Run your tests with clojure.test/run-tests. |
| 11:28 | alrex021 | oh I see |
| 11:29 | rhickey | Chouser: timeout on deref of promise? returning what if timed out? |
| 11:29 | alrex021 | so when using functions from clojure.test ...use run-tests |
| 11:30 | Chousuke | rhickey: you could require the user to specify a timeout value |
| 11:30 | alrex021 | so run-tests will actually look at functions in namespaces :test and treat it the same way as deftest functions? |
| 11:30 | alrex021 | just want to make sure I understand this |
| 11:31 | Chousuke | rhickey: then it could look like (deref obj timeout ::timeoutval) |
| 11:31 | Chouser | rhickey: yes. nil would work in this case, though I suppose one might eventually want to specify the value to return on failure. |
| 11:32 | rhickey | I'm not sure I want to overload deref for this, but both future and promise have potentially blocking derefs and timeout options |
| 11:33 | Chouser | yeah, it stretches deref quite a bit. maybe a new interface. :-/ |
| 11:33 | Chouser | since I'm on 1.0 and have my own copy of 'promise' anyway, I may just add (invoke [timeout unit] ...) to the proxy. |
| 11:34 | Chousuke | heh |
| 11:34 | alrex021 | What is the best practice, if any, when writing tests in clojure.....to have them closely tied to function using :test or to define them using deftest macro? |
| 11:34 | cemerick | adding an available?/done? fn to IDeref would make setting up timeouts on any IDeref pretty straightforward with latch |
| 11:35 | Chouser | cemerick: those may be related. |
| 11:35 | Chouser | cemerick: I mean, things that might want a timeout on "deref" may also be the things that you'd want to ask 'available?' of. |
| 11:35 | rhickey | cemerick: I'm not sure I understand use case for timeouts on non-future/promise refs |
| 11:35 | clojurebot | for is not used enough |
| 11:36 | cemerick | Chouser: yeah, I know...trying to build my use-cases :-) |
| 11:36 | rhickey | In any case it's not going in IDeref, maybe IMightDerefIfImReady? |
| 11:37 | Chouser | perfect |
| 11:37 | stuartsierra | alrex021: it's really a matter of taste. |
| 11:37 | cemerick | rhickey: there is none -- I'm just pitching for an available/done marker on IDeref in general, which could be leveraged by a timeout mechanism |
| 11:37 | rhickey | IMightDerefIfYoureLicky |
| 11:37 | rhickey | cemerick: avaialble/done just invite polling, which is bad |
| 11:38 | stuartsierra | alrex021: In general, I would recommend only adding :test metadata directly if you're using the clojure.core/test, which expects an exception on failure. |
| 11:38 | Chouser | The question you have to ask yourself is, do you feel licky. Well do you, punk? |
| 11:38 | LauJensen | No.. Not real licky Chouser... :) |
| 11:38 | cemerick | rhickey: my use case is with regular delays, to avoid incurring computation in certain circumstances |
| 11:38 | Chouser | LauJensen: yeah, me either. |
| 11:39 | stuartsierra | alrex021: Personally, I use clojure.test/with-test to add small unit tests to isolated functions; I use deftest to write broader integration tests. |
| 11:39 | cemerick | right now, I carry around an atom/delay pair to track whether the latter's been accessed yet or not |
| 11:40 | alrex021 | stuartsierra: I must admit that I am loving the concept of testing using :test .... I'd prefer to look at source of function see its test right there. like the doc string |
| 11:40 | stuartsierra | alrex021: That's what clojure.test/with-test is for. |
| 11:41 | stuartsierra | ,(doc clojure.test/with-test) |
| 11:41 | clojurebot | Titim gan éirí ort. |
| 11:41 | stuartsierra | wha? |
| 11:42 | rhickey | cemerick: would you be satisfied with deref-with-timeout vs done?/available? |
| 11:46 | cemerick | probably not -- I use the atom/delay pair to help amortize the cost of certain operations in a data structure |
| 11:49 | cemerick | is the temptation to poll really that strong with some? |
| 11:49 | rhickey | cemerick: then I don't understand the semantics of available? - you haven't asked for anything to be done, who sets the atom? |
| 11:53 | m3lling | day 2 of this... http://blog.thinkrelevance.com/2008/9/16/pcl-clojure-chapter-3 |
| 11:54 | m3lling | personally i think there is a bug in clojure somewhere. |
| 11:54 | m3lling | checked my stuff out with git and built it. |
| 11:54 | m3lling | the example does work if I remove the spaces from the data and put in a - |
| 11:55 | m3lling | Dixie-Chicks ... for example |
| 11:55 | m3lling | otherwise it's java.lang.ArrayIndexOutOfBoundsException: 9 |
| 11:56 | cemerick | rhickey: The atom always starts at false, and is flipped to true when the delay is accessed. |
| 11:56 | cemerick | Specifically, the delay is deref'd (and the atom reset to true) on a query, which will build out the portion of the data structure it represents. On removal and swaps, those parts of the structure that haven't yet been accessed at all are just replaced with a new atom/delay. Those that have are replaced with an updated value from the already-forced delay. |
| 11:56 | duck1123 | are you sure "Dixie Chicks" is quoted appropriately? |
| 11:56 | m3lling | i copied it from the blog. |
| 11:56 | m3lling | doube-quotes...? |
| 11:57 | tomoj | that looks like it was written almost a year ago |
| 11:57 | tomoj | m3lling: ^ |
| 11:57 | m3lling | actually, i believe the problem is when trying to load the data from the file. |
| 11:57 | duck1123 | I don't see anything that looks like it wouldn't still apply though |
| 11:57 | m3lling | it doesn't get reparsed right. |
| 11:59 | m3lling | i have a simpler version on StackOverFlow... http://stackoverflow.com/questions/1291765/how-do-i-persist-and-restore-my-defstructs-to-a-file/1294018#1294018 |
| 11:59 | rhickey | cemerick: got it. It's interesting because in the non-async case of delay the has-been-calculated question is less about waiting for something else to complete, as with future/promise |
| 11:59 | m3lling | (def x (struct bookmark "news.ycombinator.com" "News" "Tech News")); Doesn't handle "Things in quotes" |
| 12:00 | m3lling | (save-db x "url-db.txt") ... (def y (load-db "url-db.txt")) .. will fail... |
| 12:00 | Chouser | you need prn instead of print |
| 12:01 | Chouser | or (pr-str db) instead of (with-out-str (print db)) |
| 12:02 | cemerick | rhickey: yeah. I think the available? semantics would apply to all IDerefs, though. |
| 12:02 | stuartsierra | m3lling: I don't think you can pr/read struct-maps right now. |
| 12:02 | cemerick | sort of useless with refs, but still applicable |
| 12:02 | m3lling | so this example doesn't work? |
| 12:02 | rhickey | cemerick: I'm not sure I agree, but now see the utility for delay |
| 12:02 | m3lling | it does work if no spaces are in the values |
| 12:03 | cemerick | rhickey: hey, it makes sense to me! ;-) |
| 12:03 | tomoj | I had trouble where pr'ing structmaps with *print-dup* true printed stuff that couldn't be read |
| 12:03 | stuartsierra | m3lling: it will work if you use pr instead of print, but when you read it back in, you'll get plain maps instead of struct maps. |
| 12:03 | tomoj | #=(clojure.lang.PersistentStructMap/create ...) |
| 12:04 | rhickey | I think delay/promise/future might support something like that, and promise/future something like deref-with-timeout. Name suggestions for functions and interfaces welcome |
| 12:04 | tomoj | "no matching method found: create" |
| 12:05 | stuartsierra | tomoj: Yes, I've had the same problem. |
| 12:06 | m3lling | k. i changed the save-db and it works. |
| 12:06 | m3lling | thx. |
| 12:06 | cemerick | deref-before seems like a no-brainer |
| 12:07 | cemerick | or deref-within maybe |
| 12:08 | cemerick | the terracotta guys are growing (http://blog.terracottatech.com/2009/08/terracotta_and_ehcache_a_marri.html). Glad they're doing so well. |
| 12:10 | m3lling | are we sure this thing isn't a struct when it's read back in? (println (= x y)) is true. |
| 12:10 | m3lling | x is original and y is loaded value. |
| 12:10 | stuartsierra | tomoj: created a ticket: http://www.assembla.com/spaces/clojure/tickets/176-structs-printed-with-*print-dup*-true-cannot-be-read |
| 12:11 | tomoj | stuartsierra: cool |
| 12:11 | hamza | how can i create a java.awt.geom.RoundRectangle2D.Double? |
| 12:11 | m3lling | k |
| 12:11 | hamza | (new java.awt.geom.RoundRectangle2D.Double ...) creates error |
| 12:11 | tomoj | I went down the road towards manually serializing/deserializing from json |
| 12:12 | stuartsierra | hamza: is "Double" a nested class of RoundRectangle2D? |
| 12:13 | cemerick | yes, it should be java.awt.geom.RoundRectangle2D$Double |
| 12:13 | hamza | dunno in java i can get it using g2.draw(new RoundRectangle2D.Double(0,0,(getWidth()-3),... |
| 12:14 | hamza | cemeric thx it worked.. |
| 12:14 | cemerick | hamza: RoundRectangle2D$Double is the real classname -- the period in java source code is just syntactic sugar |
| 12:16 | hamza | one more question if i proxy say JButton how can i override its contructor? |
| 12:16 | cemerick | you can't override constructors in proxies |
| 12:17 | hamza | is there any other way to do it? |
| 12:17 | cemerick | but you probably don't want to override its constructor, just provide it with whatever args you want in the second vector provided to the proxy fn |
| 12:17 | cemerick | ,(proxy [javax.swing.JButton] ["some text"]) |
| 12:17 | clojurebot | java.lang.IllegalStateException: Var null/null is unbound. |
| 12:18 | cemerick | huh, hadn't seen that before |
| 12:18 | cemerick | does clojurebot run in headless mode or something? |
| 12:20 | hamza | what about super call how can i refer it? |
| 12:22 | cemerick | hamza: see proxy-super |
| 12:38 | cemerick | oh, how I want to stop ever writing java |
| 12:41 | rhickey | cemerick: in Java because...? |
| 12:41 | cemerick | rhickey: legacy code base, java 1.4 compat required. |
| 12:41 | rhickey | ah, can't help you there |
| 12:42 | cemerick | I shouldn't complain, this is the first java I've written in at least a month. |
| 12:42 | cemerick | yeah, I've gone astray for 15 min |
| 12:47 | cable_ | rhickey: fantastic job with everything, ive finally found a JVM language worth switching to |
| 12:47 | rhickey | cable_: thanks! |
| 12:48 | technomancy | so... is there any way to build the fnparse library without an IDE? |
| 12:48 | technomancy | the build.xml files are a bit intimidating |
| 12:58 | Chousuke | Progress! (eval (first (item-seq (rh-from-str "(defn foo [#^String x] (.toUpperCase x))")))) now gives me a foo function without any pesky reflection warnings. |
| 12:59 | Chouser | Chousuke: that's your reader? |
| 12:59 | stuartsierra | ok, I think clojure.contrib.http.agent is finally finished. |
| 12:59 | Chousuke | yeah. |
| 12:59 | Chousuke | Tomorrow I'm going to try if my reader can read core.clj :P |
| 12:59 | Chouser | Chousuke: very cool |
| 13:00 | Chousuke | I still don't have support for \characterescapes but that should be simple. |
| 13:00 | Chousuke | and it's probably more lenient on what it accepts as tokens than the java reader |
| 13:04 | Chousuke | clojure.lang.reader> (= (read-string test-str) (my-read-str test-str)) |
| 13:04 | Chousuke | tru |
| 13:04 | Chousuke | e |
| 13:04 | Chousuke | reassuring |
| 13:05 | Chousuke | (metadata is probably different though) |
| 13:12 | technomancy | hiredman: what rev of fnparse are you running clojurebot on? |
| 13:17 | hiredman | technomancy: running ant just always worked for me, but I haven't built it in a few months |
| 13:18 | hiredman | technomancy: I'm not sure |
| 13:22 | technomancy | I got it to compile by tearing out a bunch of crap from the build.xml and hardcoding some classpath vars in, but now I'm getting wrong number of args |
| 13:23 | technomancy | if you've got a sha1 rev for me to work from that'd be awesome |
| 13:25 | hiredman | I don't :( |
| 13:25 | technomancy | OK, I'll go back a couple months |
| 13:25 | technomancy | see if that does it |
| 13:27 | cemerick | technomancy: is this a netbeans build process? |
| 13:28 | technomancy | cemerick: yeah, actually I think it's just copied from the enclojure build process |
| 13:28 | cemerick | well, enclojure is a netbeans module suite, which is a whole lot more complicated than a regular project. |
| 13:28 | cemerick | For the latter, you should be able to just set a system property to bootstrap the whole thing. |
| 13:29 | cemerick | what do you get if you just "ant jar" the thing? |
| 13:30 | technomancy | cemerick: it was complaining about not having clojure.jar on the classpath |
| 13:30 | technomancy | apparently ignoring the CLASSPATH environment var |
| 13:30 | cemerick | hrm. what's the github url? |
| 13:30 | cemerick | (the CLASSPATH env var is a scourge on our society IMO, but anyway... :-) ) |
| 13:31 | technomancy | cemerick: I don't use it unless I'm desperate. =) |
| 13:31 | technomancy | http://github.com/joshua-choi/fnparse |
| 13:32 | cschreiner | I loathe the classpath concept |
| 13:34 | cemerick | technomancy: ugh. The clojure jar is set up as a platform library, e.g. you'd have to either be in a properly-configured NB IDE or have an NB platform harness around configured just like Joshua's in order to get it to build. |
| 13:35 | cemerick | Not the best thing to do with a lib that's going to get built elsewhere (e.g. set up core stuff as platform libraries) |
| 13:35 | Chousuke | I don't think the classpath is that different from LD_LIBRARY_PATH... the main problem I guess is that classes aren't versioned so you can't have two versions of the same class at the same time. :/ |
| 13:38 | technomancy | cemerick: sounds like I just need to get the author to get his build process fixed then |
| 13:38 | cemerick | heh, people are touchy about their build processes :-) |
| 13:38 | cemerick | but yeah, I'd say it's essentially unbuildable as-is, based on my skimming of the project files |
| 13:38 | technomancy | well I'm on metered 3G bandwidth right now, so there's no way I'm downloading netbeans. =) |
| 13:39 | cemerick | you'd still have to set up clojure as a "platform library", which is ill-advised outside of very constrained circumstances. |
| 13:40 | cemerick | e.g. ties you to your current IDE, unless you're building against an internally-canonical NB platform harness (which we happen to do in one case, but for very good reasons) |
| 13:41 | technomancy | well I can try my "disable the tests and hardcode the classpath" approach with an earlier revision |
| 13:41 | technomancy | hiredman: what do you use fnparse for? |
| 13:41 | Chouser | Chousuke: LD_LIBRARY_PATH is not recommended either -- there are global config files that are preferred, but AFAIK the jvm has no such thing. |
| 13:41 | technomancy | could I just rip out that functionality? |
| 13:42 | technomancy | looks like just factoids? |
| 13:42 | technomancy | what exactly are ... factoids? |
| 13:46 | hiredman | clojurebot: clojure? |
| 13:46 | clojurebot | clojure is cheating |
| 13:46 | hiredman | that is a factoid |
| 13:47 | duck1123 | "You can't just have concurrency without having to worry about deadlocks, that's cheating" |
| 13:47 | technomancy | hiredman: ah, so all the dictionary stuff? |
| 13:47 | hiredman | yeah |
| 13:47 | technomancy | would be a shame to lose that. |
| 13:47 | hiredman | it'd didn't always uses fnparse |
| 13:52 | hiredman | does fnparse need to be built? maybe just jar up the source? |
| 13:52 | technomancy | maybe |
| 13:52 | technomancy | I'll add that back in later once I have it running |
| 13:54 | hiredman | ugh |
| 13:54 | hiredman | java.lang.IllegalArgumentException: Wrong number of args passed to: fnparse$followed-by (factoids.clj:14) |
| 13:55 | technomancy | yup. =\ |
| 13:56 | hiredman | I think I must be using pre-monad fnparse |
| 13:57 | hiredman | ugh |
| 13:57 | hiredman | it returns a map now |
| 13:57 | hiredman | technomancy: do you want the working fnparse.jar I have? |
| 13:57 | technomancy | sure |
| 13:58 | hiredman | http://www.thelastcitadel.com/lab/fnparse.jar |
| 13:58 | technomancy | thanks |
| 14:13 | technomancy | hiredman: would it be a lot of hacking to get clojurebot running in multiple channels? |
| 14:21 | technomancy | this doesn't seem to... work. at all. |
| 14:22 | technomancy | changeNick and joinChannel are no-ops |
| 14:23 | technomancy | sendMsg seems to work though |
| 14:27 | konr | What should I use as a GUI designer with swing? |
| 14:32 | cemerick | konr: NetBeans matisse is pretty good |
| 14:32 | cemerick | apparently, the instantiations swing designer is superior, but I'm decidedly not an eclipse fellow |
| 14:53 | mebaran151 | are there any web frameworks a little lighter than compojure out there |
| 14:54 | mebaran151 | something that doesn't have any batteries for html etc |
| 14:55 | dnolen | compojure about as light as it gets it seems to me. I personally never use it's built in HTML facilities, I prefer Enlive. |
| 14:55 | stuartsierra | mebaran151: ring |
| 14:55 | mebaran151 | does ring have a routing layer? |
| 14:55 | dnolen | compojure is actually heavily based on ring's routing layer. |
| 14:55 | stuartsierra | http://github.com/mmcgrana/ring/tree/master |
| 14:56 | stuartsierra | Does compojure use Ring internally, or just implement the same API? |
| 14:56 | mebaran151 | oh nice |
| 14:56 | mebaran151 | and can I easily make a war out of a ring app |
| 14:56 | mebaran151 | it's http, just without any html |
| 14:56 | dnolen | stuartsierra: I forget how closely related their codebase is... |
| 15:02 | LauJensen | Anybody know of a simple quick java image processing lib that I can use for cropping and scaling ? |
| 15:10 | mebaran151 | I think java.awt.image might have some useful classes for this sort of thing |
| 15:11 | cemerick | Cropping is pretty straightforward just using the standard Java2D stuff. |
| 15:11 | cemerick | Scaling is pretty complicated, and Image.getScaledInstance is often not what you want: http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html |
| 15:12 | cable_ | there's jai as well |
| 15:12 | cemerick | SwingX contains some utility functions that implement the recommendations of the above article, which it mentions. |
| 15:18 | tomoj | stuartsierra: I don't think it uses ring, as I didn't have to download ring to get compojure to work |
| 15:19 | stuartsierra | right, makes sense |
| 15:20 | LauJensen | Alright - Thanks alot guys |
| 15:21 | dnolen | LauJensen: while it's definitely not simple, the Advanced Imaging library does have a lot of functionality, I've always hoped someone would created a simpler interface to it. |
| 15:22 | hiredman | technomancy`: I don't think it would take that much |
| 15:22 | hiredman | I have clojurebot running in here and in #clojurebot |
| 15:55 | mebaran151 | it's nice to have only one type of datastructure, the seq |
| 15:56 | mebaran151 | a lot of my old oop code seemed to be used to repurpose various types of reducing operations over subtly different collections |
| 15:56 | LauJensen | dnolen: A bit beyond the scope of this project - But remind me next time something like this comes up :) |
| 16:05 | hiredman | http://twitter.com/clojure/status/3382120972 <-- ha ha |
| 16:10 | Chousuke | :p |
| 16:10 | Chousuke | hmm |
| 16:11 | cemerick | does rhickey control the clojure twitter acct? |
| 16:11 | hiredman | clojuredev |
| 16:11 | hiredman | clojure is someone else, I assume |
| 16:11 | Chousuke | if I have a function that takes a seq (aseq) as a parameter and I want to do this: (let [aseq (do-some-stuff-that-consumes aseq)] ...), how do I avoid holding onto the head? |
| 16:11 | cemerick | ah, that explains the Germany location. |
| 16:14 | Chousuke | hmm. or does nth hold on to the head of lazy seqs? that was what I tested with :/ |
| 16:18 | LauJensen | Looking at Swing, its not obvious to me how I would render an image, and then provide some easy way of stretching out a rectangle for cropping it. Containing the image could be done with ImageIcon, but then what ? |
| 16:21 | Chousuke | hm |
| 16:22 | Chousuke | let seems to cause things to hold onto their head |
| 16:23 | Chousuke | ((fn [aseq] (let [aseq (nth aseq 1000000)] aseq)) (iterate inc 1)) fails, but simply ((fn [aseq] (nth aseq 1000000)) (iterate inc 1)) doesn't. |
| 16:26 | LauJensen | First one doesnt fail here |
| 16:27 | Chousuke | try with a bigger n? |
| 16:28 | Chouser | I don't think much of anything about swing is obvious. |
| 16:29 | cable_ | heh re: swing |
| 16:30 | LauJensen | Chousuke: yea x50 blows the heap after a while |
| 16:30 | Chousuke | I wonder why that is. |
| 16:31 | LauJensen | I'm ashamed to say, that Rich actually explained it a couple of weeks ago, but I forgot |
| 16:31 | Chouser | of course it does -- your are returning the head, so it must be retained |
| 16:31 | Chouser | oh. |
| 16:31 | Chouser | wait. |
| 16:31 | stuartsierra | When you let-bind the head of a sequence, the compiler doesn't know that you're not going to use it latert |
| 16:32 | Chousuke | hmm |
| 16:32 | stuartsierra | (let [aseq (make-big-sequence)] (consume aseq) ... what happens here?) |
| 16:32 | Chouser | let is in the tail position, so it could theoretically null out the earlier aseq. Apparently it doesn't. |
| 16:33 | stuartsierra | yeah, I think the analysis for whether or not aseq gets consumed could get pretty complicated |
| 16:35 | Chousuke | hmm |
| 16:36 | Chousuke | so how do I avoid holding on to the head of the function parameter at all? |
| 16:36 | Chousuke | it seems using let will cause it to be held, no matter what I do :( |
| 16:36 | Chouser | they get nulled out before whatever you call in the tail position, I believe. |
| 16:36 | LauJensen | Didnt Rich give an example of how he rewrote filter to avoid retaining the heaed? |
| 16:36 | Chousuke | ((fn [aseq] (let [foo (nth aseq 1000000)] foo)) (iterate inc 1)) also boom |
| 16:37 | cemerick | LauJensen: You'd need to handle the rendering of the lasso and such yourself. I'm not familiar with any libraries that provide a lasso "control". |
| 16:37 | Chousuke | ((fn [aseq] (nth aseq 1000000)) (iterate inc 1)) no boom, but no good either ;( |
| 16:37 | LauJensen | Chousuke: How about ((fn [aseq] (let [foo (nth aseq 1000) bar 5] ...) ? |
| 16:38 | Chousuke | LauJensen: adding more stuff to the let makes no difference. |
| 16:38 | LauJensen | Sure about that? |
| 16:38 | Chousuke | user=> ((fn [aseq] (let [foo (nth aseq 1000000) bar 5] foo)) (iterate inc 1)) |
| 16:38 | stuartsierra | Chousuke: what exactly are you trying to do, anyway |
| 16:38 | Chousuke | java.lang.OutOfMemoryError: Java heap space (NO_SOURCE_FILE:0) |
| 16:39 | LauJensen | k |
| 16:40 | Chousuke | stuartsierra: well, in my reader I currently do (let [[item rh] (consume rh)] ...) a lot. |
| 16:40 | Chousuke | stuartsierra: but if that causes the old rh to be held, it causes unnecessary slowdown and memory use :( |
| 16:46 | Chouser | yeah, that's a bit tricky. |
| 16:51 | Chousuke | Hi, technomancy. I have a question for you. eldoc-mode seems to cause some rather nasty lag within clojure buffers in my Cocoa emacs when scrolling lines. I suspect swank-clojure is to blame... it seems to try connecting to the clojure instance immediately when I scroll to a new line, somehow blocking rendering when I hold down the scroll key. elisp buffers don't have this |
| 16:51 | Chousuke | behaviour, and I noticed they have a slight delay before the arg documentation appears in the minibuffer. |
| 16:51 | Chousuke | But I have no idea where, or how, to fix that :/ |
| 16:52 | technomancy | Chousuke: I believe eldoc works with an idle timer... |
| 16:52 | technomancy | so it shouldn't even try to activate until you've paused on a line |
| 16:53 | technomancy | what's your value for eldoc-idle-delay? |
| 16:53 | Chousuke | looks like it's not working in my clojure buffers :/ |
| 16:53 | clojurebot | clojure is a very attractive hammer with a nice heft to it |
| 16:53 | Chousuke | I'll check. |
| 16:55 | Chouser | Chousuke: do you have a specific example of where you're running into that OOM error? |
| 16:56 | Chousuke | I'm not getting it with my reader yet, fortunately. |
| 16:57 | Chousuke | but since it appears with the (let [foo (use foo)] ...) pattern, it's quite certainly there :P |
| 16:57 | Chousuke | technomancy: it was 0.5. I set it to 1.0, with no apparent effect. |
| 16:59 | Chousuke | technomancy: it looks like it's ignored |
| 17:00 | Chousuke | technomancy: elisp buffers honour the value, but clojure buffers don't seem to. |
| 17:00 | technomancy | weird; I can't repro myself. and it only occurs when eldoc-mode is on? |
| 17:00 | Chousuke | yeah. |
| 17:00 | technomancy | try ruling out platform-specific problems... do you get it when you run in terminal Emacs? |
| 17:03 | LauJensen | Dudes and Dudettes, how do I proxy my way out of something like this |
| 17:03 | Chousuke | hmm, clojure-mode doesn't even work in my terminal emacs :P |
| 17:03 | LauJensen | class SliderListener implements ChangeListener { public void stateChanged(ChangeEvent e) { |
| 17:03 | technomancy | we have more than one dudette now? |
| 17:03 | Chousuke | probably because it's 22.1 |
| 17:04 | technomancy | Chousuke: yeah, can you run your 23 install with -nw? |
| 17:05 | Chousuke | hmm, it still fails to load. it seems I have some Cocoa-specific configs |
| 17:05 | technomancy | is this a post-1.0-ism? (import (java.util.logging Logger Level)) |
| 17:06 | technomancy | Chousuke: yeah, I try to toss those into a (when (= window-system 'ns) block |
| 17:06 | technomancy | but that sounds like a yak shave |
| 17:07 | hiredman | technomancy: yes |
| 17:08 | technomancy | Chousuke: how much do you have on top of the standard clojure-slime-config? |
| 17:08 | hiredman | I think sometime post 1.0 the need to quote stuff in import and require and use went away |
| 17:08 | technomancy | are you on the starter kit? |
| 17:08 | technomancy | hiredman: cool; thanks |
| 17:08 | technomancy | I'm thinking about backporting contrib's logging lib to 1.0-compat |
| 17:09 | Chousuke | technomancy: looks like it happens only in Cocoa emacs. |
| 17:09 | technomancy | Chousuke: not sure I can help then. =\ |
| 17:09 | technomancy | very strange that the idle-timer behaviour is different |
| 17:10 | technomancy | maybe in the mean time I can clean up the obscene amounts of trailing whitespace in this logging.clj file. =\ |
| 17:10 | Chousuke | technomancy: no, wait. |
| 17:10 | Chousuke | technomancy: clojure-mode still ignores the delay |
| 17:11 | Chousuke | the terminal version is just quick enough that it doesn't mind the lag I guess. |
| 17:14 | Chousuke | I suspect that if I disable the delay, elisp buffers will get laggy too |
| 17:14 | Chousuke | I'll try. |
| 17:14 | technomancy | Chousuke: are you using the starter kit? how much do you have on top of clojure-slime-config? |
| 17:17 | Chousuke | technomancy: no. I cloned this as a base: http://github.com/purcell/emacs.d/tree/master |
| 17:17 | Chousuke | but I have quite many changes to it already. |
| 17:17 | Chousuke | though, nothing to clojure-mode that should affect this. |
| 17:18 | Chousuke | and I tested on elisp buffers... they work fine even with no delay it seems. |
| 17:18 | technomancy | Chousuke: would be interested to know if you could repro with the starter kit as per http://technomancy.us/126 |
| 17:18 | technomancy | but again: kind of a yak shave |
| 17:19 | hiredman | ~yak |
| 17:19 | clojurebot | fastest sheers on IRC |
| 17:25 | Chousuke | hmm. |
| 17:25 | Chousuke | clojure-install seems to have taken over emacs :P |
| 17:25 | technomancy | it does take a while unfortunately |
| 17:25 | technomancy | no concurrency =\ |
| 17:26 | bitbckt | It's even worse when git:// is blocked... |
| 17:26 | Chousuke | I wonder if it's even possible to have proper concurrency in emacs. |
| 17:27 | technomancy | Chousuke: well lexical scope is targeted for 24 |
| 17:27 | technomancy | that's the main thing holding it back |
| 17:29 | Chousuke | emacs starter kit has no problems it seems. |
| 17:30 | Chousuke | I guess it's something in my config. |
| 17:30 | JAS415 | i had better luck doing a manual install |
| 17:31 | JAS415 | was not too complicated after i figured out what the heck classpaths are |
| 17:32 | technomancy | JAS415: what problems were you seeing specifically? |
| 17:32 | technomancy | curious |
| 17:32 | Chousuke | Maybe I should see if I could move my config on top of emacs starter kit |
| 17:33 | JAS415 | well it was just a matter of I have sbcl installed as well as clojure, and I had trouble finding the stuff that I needed to manipulate to add different libraries and stuff to the classpath |
| 17:34 | Chousuke | looks like it has most of the features I care about anyway |
| 17:34 | JAS415 | also i wanted to build from the most recent github version |
| 17:34 | JAS415 | so i kind of used clojure-install to get an idea of what things were supposed to look like |
| 17:35 | JAS415 | then i uninstalled it and reinstalled it again so I had an idea of how it actually worked |
| 17:35 | JAS415 | (reinstall by hand) |
| 17:35 | technomancy | oh yeah, I never bothered to figure out how to use it with CL too |
| 17:36 | technomancy | I figure if you know CL, you're probably capable of figuring it out on your own. =) |
| 17:36 | Chousuke | I'm quite impressed by paredit btw. |
| 17:36 | Chousuke | I couldn't quite figure it out previously, but then I realised how to use barf and slurp and that alone makes it awesome :P |
| 17:37 | Chousuke | next I need to learn the commands for navigating sexps I guess |
| 17:37 | technomancy | I'm working on a screencast. |
| 17:37 | technomancy | slowly... |
| 17:37 | Chousuke | the emacs transpose feature is weird btw. |
| 17:38 | technomancy | clojurebot: paredit screencast is http://p.hagelb.org/paredit-screencast.html |
| 17:38 | clojurebot | c'est bon! |
| 17:38 | Chousuke | I haven't found a single useful use for it yet, but it's interesting :P |
| 17:40 | lrenn | Chousuke: transpose sexp can be used to move an sexp down (just keep hitting it). I don't use it, but there ya go. |
| 17:49 | JAS415 | technomancy: for me its more like i'm stubborn enough to not admit that I can't figure it out |
| 17:55 | technomancy | hiredman: did you say you were able to run clojurebot in slime? |
| 17:55 | technomancy | I'm getting a lot of java.security.AccessControlExceptions from the securitymanager -D args |
| 17:56 | hiredman | technomancy: I don't use emacs |
| 17:56 | hiredman | technomancy: do you have the policy file setup? |
| 17:57 | technomancy | hiredman: oops. /path/to/this.policy. |
| 17:57 | hiredman | easiest if you just copy example.policy to ~/.java.policy |
| 17:57 | technomancy | =) |
| 17:58 | hiredman | I could not get specifying the path to the policy file to work |
| 17:58 | Chousuke | it needs to be an URL |
| 17:58 | hiredman | oh |
| 17:58 | Chousuke | file:///path/to/policy.file |
| 17:58 | hiredman | well, there you go |
| 17:59 | technomancy | I meant that I had it set to the literal "file:///path/to..." instead of the actual path |
| 17:59 | hiredman | nice |
| 18:00 | technomancy | still getting access denied though... I'll stick with rlwrap for now. |
| 18:00 | hiredman | I have code for getting clojurebot to work in a multiuserchat with jabber too, I just haven't shoehorned it in yet |
| 18:01 | Chousuke | I did run clojurebot in emacs... hmm |
| 18:01 | Chousuke | I think I have my old emacs config somewhere |
| 18:02 | mebaran151 | are compojure and ring likely to merge: it seems like they mirror each other's functionality |
| 18:03 | hiredman | ring is lower level, I think compojure is built on top of ring these days |
| 18:04 | LauJensen | True |
| 18:05 | Chousuke | technomancy: I had '(swank-clojure-extra-vm-args (list "-server" "-Djava.security.manager" "-Djava |
| 18:05 | Chousuke | .security.policy=file:///Users/oranenj/.emacs.policy")) |
| 18:05 | Chousuke | where .emacs.policy is the example.policy |
| 18:06 | rhickey | Dan Weinreb with nice things to say about Clojure: http://www.youtube.com/watch?v=xquJvmHF3S8 |
| 18:06 | rhickey | 50 minutes in |
| 18:07 | rhickey | but the rest a nice survey about the applicability of Lisp to hard problems requiring flexibility, an area Clojure should also cover well |
| 18:13 | JAS415 | are there any plans for multiple value return in clojure? |
| 18:14 | JAS415 | it would be really nice :-) |
| 18:21 | mebaran151 | JAS415, what's wrong with simply packing a vector and destructuring on input |
| 18:21 | rhickey | JAS415: no plans, sorry |
| 18:22 | rhickey | there isn't the requisite stack manipulation in Java bytecode for it |
| 18:22 | rhickey | so it would be 'faked' in any case |
| 18:23 | rhickey | I had an implementation when first doing Clojure, using thread locals |
| 18:23 | JAS415 | ah that's too bad |
| 18:24 | JAS415 | membaran: nothing intrinsically, just a little less efficient to be creating and destroying objects all the time |
| 18:24 | technomancy | GC is cheap |
| 18:25 | JAS415 | oops x'd the box when i wanted to resize |
| 18:26 | JAS415 | well i guess its just i just have sort of a mental differentiation between a vector that i'm destructuring and returning multiple values |
| 18:26 | JAS415 | it also seems like people get mislead into writing fairly inefficient code |
| 18:28 | JAS415 | there was that 'uncle bob' thread in the clojure google groups and he was asking 'why is this so slow' and it was kind of obvious, as he was making like 8,000,000 2 length immutable vectors and destructuring |
| 18:29 | JAS415 | or maybe it was 16,000,000 |
| 18:30 | mebaran151 | but for multiple return, you would have to pack it in SOMETHING |
| 18:30 | mebaran151 | because Java has not native tuple type |
| 18:30 | hiredman | Map.Entry |
| 18:31 | Chousuke | :P |
| 18:31 | JAS415 | unless you can manipulate the stack like rich was talking about, which you can't |
| 18:31 | Chousuke | are thread locals too slow them? :/ |
| 18:31 | JAS415 | so i'll wait for it along with TCO |
| 18:31 | Chousuke | then* |
| 18:31 | hiredman | ,(java.util.AbstractMap.SimpleImmutableEntry. :a :b) |
| 18:31 | clojurebot | java.lang.ClassNotFoundException: java.util.AbstractMap.SimpleImmutableEntry |
| 18:31 | hiredman | bah |
| 18:31 | hiredman | ,(java.util.AbstractMap$SimpleImmutableEntry. :a :b) |
| 18:31 | clojurebot | #<SimpleImmutableEntry :a=:b> |
| 18:32 | Chousuke | hiredman: that's still creating a new object though. |
| 18:32 | rhickey | JAS415: multiple returns are not coming, so don't wait for them :) |
| 18:32 | JAS415 | haha |
| 18:32 | JAS415 | fair enough |
| 18:34 | rhickey | the #1 use case (for me) of multiple return in CL was gethash, covered by optional not-found arg to get |
| 18:34 | JAS415 | honestly most of the uses of multiple return in CL i've found have been in incomprehensible spaghetti code |
| 18:35 | rhickey | Otherwise nice but not necessary. And the inefficiencies today of ephemeral tuples for returns might disappear with the escape analysis of tomorrow... |
| 18:35 | Chousuke | I guess if you have a function returning multiple values or tuples in a tight loop you'll just have to use some mutable thread-local slot to hold the values and unpack them immediately. :/ |
| 18:35 | JAS415 | the thing is I kind of feel like I want either to be able to return multiple values or to be able to use state |
| 18:37 | technomancy | hiredman: you have some defmultis in clojurebot that check for clojure.lang.PersistentHashMap that should check for IPersistentMap |
| 18:37 | technomancy | since small maps are usually PersistentArrayMaps... you shouldn't care about the size of the map |
| 18:39 | Chousuke | rhickey: btw, how do you avoid holding on to the head of aseq in code like (fn [aseq] (let [aseq (consume-a-lot-of aseq)] (first aseq))). I noticed that using let for some reason doesn't "overwrite" the function argument reference and you end up consuming more memory than needed |
| 18:39 | hiredman | technomancy: good catch |
| 18:39 | hiredman | thanks |
| 18:41 | hiredman | looks like just the one |
| 18:42 | rhickey | Chousuke: lazy seqs are not ephemeral seqs, so if you realize part/all of it and then go on to use the head you've got the whole seq there. It's not possible to get rid of it since you asked for it and still need it. Args and ocals are cleared on tail calls only (when it is known that they can't be used again). Also, the let 'aseq' and the arg 'aseq' are two completely different lexical things. Calling the let one 'foo' would make no diff |
| 18:45 | technomancy | hiredman: ah, you're right; just one |
| 18:46 | technomancy | unfortunately I'm modifying the codebase pretty significantly or I'd be inclined to send patches instead of just "hey, could you fix..." =) |
| 18:46 | hiredman | shouldn't really be there anyway |
| 18:46 | hiredman | I imagine it would take a significant modification to make it suitable for anyone beyond #clojure |
| 18:47 | technomancy | mostly just ripping things out so far |
| 18:47 | Chousuke | rhickey: in my reader I do (let [[item rh] (consume rh)] (do-something-more item rh))) a lot, and code like that ends up holding on to the old rh for longer than necessary. the thing is, I can't quite see how to avoid that without removing all the lets from my code. :/ |
| 18:47 | technomancy | Chousuke: you mentioned you were using clojurebot? what for? |
| 18:48 | Chousuke | technomancy: ages ago :P |
| 18:48 | Chousuke | when I hacked it from v1 to v2. :P |
| 18:48 | technomancy | heh; right |
| 18:48 | hiredman | and an excellent job he did |
| 18:49 | Chousuke | I do regret the "dfn" macro though. |
| 18:49 | Chousuke | because when I re-read my code a while ago I couldn't figure out what I was thinking. |
| 18:49 | hiredman | haha |
| 18:50 | rhickey | Chousuke: it would clarifythings a bit for you if you used different names, as I said, they are different things, and reusing the name is giving you false expectations |
| 18:50 | hiredman | what is a code base without its peculiarities |
| 18:51 | rhickey | (let [[foo bar] (consume baz)] (do-something-more foo bar))) |
| 18:51 | rhickey | same |
| 18:52 | rhickey | baz will stick around until the tail call to do-something-more |
| 18:55 | Chousuke | hmm, I think I will have to restructure my code a fair bit then. |
| 18:55 | Chousuke | No matter. I have a feeling the end result will be more functional, in both senses of the word |
| 18:57 | Chousuke | Many thanks for the clarification. |
| 19:13 | technomancy | hiredman: also clojurebot would be a lot more repl-friendly if you used defonce for some of your initializing stuff like *bots* |
| 19:18 | hiredman | yeah, I've been ignoring that part of core |
| 19:19 | technomancy | minor point |
| 19:19 | hiredman | it hasn't been an issue for me, because I am in the habit of sending a function at a time to the repl, and not a whole file |
| 19:21 | rhickey | Chousuke: it is a possible future optimization to tighten arg/local lifetime to point of last use (instead of tail call), which would solve this problem for you and many others. might not happen until cinc |
| 19:25 | technomancy | is defvar like defonce but with docstring sugar? |
| 19:26 | technomancy | oh, it's not once-only like it is in elisp. |
| 19:30 | konr | Do you guys know of more Clojure examples with Swing, besides the Celsius/Fahrenheit one? |
| 19:33 | technomancy | hiredman: did you take a look at the fnparse followed-by problem? |
| 19:36 | jfields | how can I convert a char to a byte, eg \A to 65 |
| 19:37 | technomancy | ,(int \A) |
| 19:37 | clojurebot | 65 |
| 19:37 | jfields | thanks |
| 19:55 | konr | do you guys know of any enclojure (preferably with matisse) tutorial? |
| 20:02 | cemerick | there's a PDF tutorial in the google group, IIRC |
| 20:30 | hiredman | technomancy: I haven't |
| 20:34 | hiredman | they are some big changes between the version I am using and the latest version |
| 20:34 | technomancy | strange that I'm still getting that error with the fnparse jar you sent me though |
| 20:34 | hiredman | oh? |
| 20:35 | hiredman | uh |
| 20:35 | hiredman | I hope I gave you the right one |
| 20:35 | hiredman | yeah, that is the same jar I have in ~/.jars/ |
| 20:35 | technomancy | could you give me the URL again? |
| 20:35 | hiredman | SHA1 (.jars/fnparse.jar) = b281abd4b298f5cdbac876791629e2014e356867 |
| 20:36 | technomancy | that's what I've got. weird |
| 20:36 | hiredman | http://www.thelastcitadel.com/lab/fnparse.jar |
| 20:36 | hiredman | hmmm |
| 20:37 | technomancy | no big deal; I don't really need factoids now |
| 21:12 | tomoj | what's the deal with sync vs dosync? |
| 21:13 | tomoj | oh, nevermind, rich explained it a few seconds later :) |
| 21:33 | hiredman | haha, "what the hell, just crash it" |
| 21:33 | hiredman | clojurebot: memory leak is <reply>what the hell, just crash it |
| 21:33 | clojurebot | In Ordnung |
| 21:48 | JAS415 | clojurebot: memory leak |
| 21:48 | clojurebot | what the hell, just crash it |
| 22:55 | technomancy | any jruby people; I've got my clojure-gem working pretty decently: http://github.com/technomancy/clojure-gem |
| 22:55 | technomancy | supports dosync and the 4 major persistent collections |
| 22:55 | technomancy | just no lazy seqs yet. |
| 22:59 | Chouser | technomancy: nice. We're using a mix of C++, Java, Clojure, and JRuby now. |
| 22:59 | Chouser | I'll pass the URL along to our ruby guy. |
| 23:00 | hiredman | (through the bars of his dank prison cell) |
| 23:02 | TheBusby | interesting mix of languages, end up with C, Ruby, Clojure here |
| 23:02 | TheBusby | seems like a combination of C/C++ for performance, Clojure for structure, and ruby/python for scripting is becoming very common |
| 23:03 | hiredman | funny, I seem to recall someone predicting clojure for scripting and scala for structure |
| 23:04 | Chouser | our C++ is for legacy reasons more than performance |
| 23:04 | TheBusby | although I'm very fond of clojure, ruby's simple string handling, quick startup time, and backticks make it much easier for scripting I think |
| 23:04 | Raynes | It's sad how when people see a side-by-side of Clojure and Scala they see 'OOP' tacked on Scala's side, and immediately lose interest in Clojure. :| |
| 23:15 | technomancy | Raynes: it's arrow-oriented! |
| 23:22 | hiredman | ~scala |
| 23:22 | clojurebot | Scala often gets in the way when trying to write neat code -- seen in #scala |
| 23:24 | TheBusby | I'm just waiting for a language to come out that compiles to C code |
| 23:25 | hiredman | :( |
| 23:25 | hiredman | my facilities does C offer to entice language designers? |
| 23:25 | TheBusby | it compiles on every platform |
| 23:25 | hiredman | … |
| 23:26 | TheBusby | pick just about any chip/platform/system these days, and they all have support for C |
| 23:27 | TheBusby | (speaking mainly for the embedded world) |
| 23:27 | hiredman | they don't support C, there is a compiler that turns C into asm for the chip |
| 23:28 | TheBusby | correct, and for many platforms that is the only compiler available for that chip |
| 23:31 | albino | TheBusby: Seen gambit-scheme? |
| 23:31 | TheBusby | no, googling now |
| 23:33 | albino | There have been some blog entries lately on using gambit to generate C that runs on the iPhone |
| 23:33 | TheBusby | albino: much appreciated, I'll be trying this out at once |