2009-08-20
| 00:00 | lowlycoder | procrastinate by helping me get work done |
| 00:00 | lowlycoder | and the cosmic balance is maintained |
| 00:00 | hiredman | lowlycoder: http://clojure.org/data_structures |
| 00:01 | lowlycoder | sounds like I want refs :-) |
| 00:01 | r2q2 | IRC is for idleing I thought everyone knew that. |
| 00:01 | derrida | r2q2: +1 |
| 00:05 | lowlycoder | are the items in a let expression guaranteed to be bound sequentially? |
| 00:05 | lowlycoder | (they must be, in order to allow a latter one to refer to a former one, right?] |
| 00:07 | rlb | lowlycoder: (doc let), follow link, second sentence (and yes). |
| 00:08 | rlb | ,(doc let) |
| 00:08 | clojurebot | "([bindings & body]); Evaluates the exprs in a lexical context in which the symbols in the binding-forms are bound to their respective init-exprs or parts therein." |
| 00:08 | rlb | Hmm, mine says: Please see http://clojure.org/special_forms#let |
| 00:09 | lowlycoder | is it just me, or is clojure code much much more dense than lisp code? |
| 00:13 | hiredman | let isn't really a special form, let is a macro that emits a call to let*, and let* is a special form |
| 00:13 | hiredman | one of the utility functions doc uses is hardwired to treat let as a special form |
| 00:14 | hiredman | but clojurebot's doc is not, so it can actually return the docstring from the let macro |
| 00:14 | lowlycoder | you are very knowledgable |
| 00:14 | lowlycoder | if I had a startup, could I hire you? |
| 00:15 | lowlycoder | the thing that surpises me with let and destructuring binding |
| 00:15 | lowlycoder | is that I can often times write entire functions in a let declaration body |
| 00:21 | hiredman | lowlycoder: well, maybe you should destructure in the function args and leave out the let |
| 00:21 | lowlycoder | nah; i need the sequential binding o th elet |
| 00:29 | lowlycoder | argh , -> ~ is so stupid, ',' is so easy to type, just using middle finger; ~ is so awkwaaard to type, using pinky on shirt + ring finger for ` ... wtf |
| 00:32 | lowlycoder | user=> (.printStackTrace *e) |
| 00:32 | lowlycoder | java.lang.NullPointerException (NO_SOURCE_FILE:0) |
| 00:32 | lowlycoder | how can I get more info thatn that? |
| 00:32 | lowlycoder | the line above it is a bunch of *.java files and a ... oh wait, I see a model.clj file |
| 00:32 | lowlycoder | that looks like my fault |
| 00:40 | lowlycoder | how do I read the value out of a ref? |
| 00:40 | lowlycoder | not the @ notation |
| 00:40 | lowlycoder | the actual function |
| 00:41 | lowlycoder | deref |
| 00:41 | lowlycoder | thanks |
| 00:45 | hiredman | ,(macroexpand '@foo) |
| 00:45 | clojurebot | (clojure.core/deref foo) |
| 00:45 | lowlycoder | that is smart |
| 01:14 | lowlycoder | is \ used much in clojure? |
| 01:14 | lowlycoder | i want to remap it to ~ |
| 01:14 | lowlycoder | since I use that alot |
| 01:16 | lowlycoder | can anyone hear me? |
| 01:16 | hiredman | \ is used for characters |
| 01:16 | hiredman | ,\a |
| 01:16 | clojurebot | \a |
| 01:17 | lowlycoder | how about one of !@#$%^&* ? |
| 01:17 | lowlycoder | @ is for deref, ! used for anything? |
| 01:17 | lowlycoder | * is probaly used for multiply |
| 01:20 | hiredman | you cannot chaning the meaning of \ without cracking open the reader |
| 01:21 | hiredman | which will make your code incompatible with everyone elses |
| 01:21 | lowlycoder | oh, i was going to remap it in vim/xmodmap |
| 01:21 | lowlycoder | so it'll still look like ~ |
| 01:44 | Fossi | what's ^ used for? or $? |
| 01:45 | hiredman | ,(macroexpand '^foo) |
| 01:45 | clojurebot | (clojure.core/meta foo) |
| 01:45 | hiredman | ,(macroexpand '$foo) |
| 01:45 | clojurebot | $foo |
| 01:45 | hiredman | nothing |
| 01:46 | Fossi | ah, right meta |
| 02:51 | demas | Hi, all. I'm read 'Programming Clojure' on page 174 and I'm trying the example 'male_female.clj' |
| 02:51 | demas | But I get error message: => (m 10) - |
| 02:51 | demas | • Игра с нулевой суммой - если один игрок выигрывает то, что проигрывает другой. |
| 02:51 | demas | • Ход - выбор одного из предусмотренных правилами игры вариантов. |
| 02:51 | demas | • Личный ход - сознательный выбор (в отличии от случайного хода) |
| 02:52 | demas | • Игра с полной информацией - игрок при каждом личном ходе знает результаты всех предыдущих ходов, как личных, так и случайных. |
| 02:52 | demas | • Конечной называется игра, если у игрока есть конечное число стратегий. |
| 02:52 | demas | sorry |
| 02:52 | demas | java.lang.IllegalArgumentException: Wrong number of args passed to: user$m (NO_SOURCE_FILE:0) |
| 02:52 | demas | Here is source code: |
| 02:52 | dulanov | @demas жги чувак ) |
| 02:52 | demas | (declare m f) |
| 02:52 | hiredman | demas: use a pastbin |
| 02:53 | demas | (defn m [n] |
| 02:53 | demas | (if (zero? n) |
| 02:53 | demas | 0 |
| 02:53 | demas | (- n (f (m dec n))))) |
| 02:53 | demas | (defn f [n] |
| 02:53 | demas | (if (zero? n) |
| 02:53 | demas | 1 |
| 02:53 | demas | (- n (m (f (dec n)))))) |
| 02:53 | hiredman | *sigh* |
| 02:53 | hiredman | lisppaste8: url |
| 02:53 | lisppaste8 | To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste. |
| 02:54 | demas | ok |
| 02:54 | demas | http://pastebin.com/m5cde0ed6 |
| 02:55 | hiredman | you are missing some parens |
| 02:57 | demas | yes, i see |
| 02:57 | demas | thank you |
| 03:13 | LauJensen | Top of the morning gents |
| 03:13 | LauJensen | ~clojurebot where are you ? |
| 03:13 | clojurebot | http://github.com/hiredman/clojurebot/tree/master |
| 03:43 | AWizzArd | hiredman: still awake? |
| 03:43 | hiredman | yessir |
| 03:44 | Raynes | AWizzArd: A real hacker never sleeps. Especially a Lisp hacker. And especially ones named hiredman. |
| 03:44 | AWizzArd | did you try out fnparse? |
| 03:44 | AWizzArd | Raynes: true, hired is the most awakest guy in here *g* |
| 03:44 | hiredman | *snort* |
| 03:45 | hiredman | you mean update clojurebot to work with the latest fnparse? |
| 03:45 | hiredman | (I haven't) |
| 03:46 | AWizzArd | you could teach the clojurebot to count parens for everything that gets posted here, and if it detects missing parens it could tell the user. |
| 03:46 | hiredman | :( |
| 03:47 | AWizzArd | with the exception of smilies |
| 03:47 | hiredman | AWizzArd: I'd rather code was pasted to a pastebin then to the channel |
| 03:48 | AWizzArd | also an option |
| 03:50 | hiredman | http://delicious.com/clojurebot/pastbin |
| 03:57 | Fossi | sure it's not *t*iredman? |
| 03:59 | hiredman | :/ |
| 06:54 | hamza | hey guys, how can i remove an element from a vector at a certain |
| 06:54 | hamza | index? |
| 07:22 | mtd | clojurebot: ,(assoc [0 1 2 3 4] 2 :two) |
| 07:22 | clojurebot | Gabh mo leithscéal? |
| 07:22 | mtd | ,(assoc [0 1 2 3 4] 2 :two) |
| 07:22 | clojurebot | [0 1 :two 3 4] |
| 07:23 | mtd | hamza: ^^ |
| 07:26 | ole3 | ,subvec |
| 07:26 | clojurebot | #<core$subvec__4942 clojure.core$subvec__4942@fb53f6> |
| 07:27 | Chousuke | hamza: you can overwrite it but actually removing it requires rebuilding most of the vector. |
| 07:27 | Chousuke | hamza: though if it's near the end it'll be reasonably cheap :) |
| 07:28 | rottcodd | ,(let [v [0 1 2] i 1] (reduce conj (subvec v 0 i) (subvec v (inc i) (count v)))) |
| 07:28 | clojurebot | [0 2] |
| 07:29 | ole3 | ,(let [v [0 1 2 3] i 2] (vec (concat (subvec v 0 i) (subvec v (+ i 1))))) |
| 07:29 | ole3 | + |
| 07:29 | clojurebot | [0 1 3] |
| 07:31 | Chousuke | that's O(n) though, and creates an entirely new vector. |
| 07:32 | Chousuke | though I guess the first one is O(n) too, technically :P |
| 07:36 | ole3 | yes |
| 08:36 | Fossi | i'm looking for a contrib function that groups maps according to a function. can't find it. somebody know where it's at? |
| 08:37 | Fossi | ok, was in seq-utils |
| 09:06 | LauJensen | ~paste |
| 09:06 | clojurebot | lisppaste8, url |
| 09:06 | lisppaste8 | To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste. |
| 09:08 | lisppaste8 | Lau pasted "Character cast? http-client" at http://paste.lisp.org/display/85731 |
| 09:08 | LauJensen | Does anyone know whats going on here? |
| 09:09 | Chouser | perhaps you want into-array ? |
| 09:10 | LauJensen | "Dont know how to create iseq from FilePart" |
| 09:10 | Chouser | (into-array [(FilePart. ...)]) |
| 09:10 | saml | man i thought i modified JLine so that tab completion works on windows.. but that only worked at the beginning of a line |
| 09:11 | LauJensen | Chouser, certainly you mean (defmacro >array [arg] `(into-array [~arg])) ? |
| 09:11 | LauJensen | Anyway, it did the trick, thanks alot :) |
| 09:14 | LauJensen | Wow - I just did a POST upload of a picture. Impressive :) |
| 09:15 | Chouser | nice. |
| 09:18 | LauJensen | Yea, thats really the goodness of running my website via compojure. Just added a POST /backdoor/ route handler, and there was no need to installed an ftp server or any such thing, which would have weakened the overall security of the server.. |
| 09:20 | Chousuke | I suppose you have some access checks in place for that backdoor? :P |
| 09:21 | LauJensen | No, people can upload whatever they want. Nothing will be executable or exceed a certain size |
| 09:23 | LauJensen | Chousuke: When I want to msg either you or Chouser, I have to write 5 letters before I can tab-complete. This is not satisfactory so I'll have to ask you do change your nick to Sukechou instead. |
| 09:23 | Chousuke | Not going to happen :) |
| 09:24 | LauJensen | With all diligence, search my last statement for a "?" - It was not a question boy |
| 09:24 | LauJensen | (I'm kidding dont kill me) |
| 09:24 | Chousuke | I tabcomplete most people's names with a single character anyway |
| 09:25 | Chousuke | Irssi's tabcompletion is context aware so most of the time it gets the right name. |
| 09:25 | LauJensen | Cool |
| 09:25 | LauJensen | I'm on Pidgin though |
| 09:25 | Fossi | Chousuke: so it knows that i want to talk to you? |
| 09:26 | Chousuke | Fossi: It prefers people who were last active. |
| 09:26 | Chouser | I've considered using a nick that's visually distinct to reduce confusion (even though I've had my name longe ;-) |
| 09:26 | Fossi | well, that would surely help me in this case ;) |
| 09:26 | Fossi | i meant the completion |
| 09:26 | Chouser | something like Ch_ouser. Or cccchouser. TheChouser |
| 09:27 | lrenn | LauJensen: Does that mean you solved your URLDecode problem? |
| 09:27 | LauJensen | lrenn: It means I've found one way of getting around it. Not optimal, since I dug into org.apache.commons, forsaking stuarts http-client |
| 09:28 | Chousuke | Chouser: You could always flip it around and make it ChrisH |
| 09:31 | LauJensen | Chouser: Then you wouldn't be mistaken for being Chinese |
| 09:31 | Chouser | Does chouser sound chinese? |
| 09:32 | LauJensen | Yes sir |
| 09:38 | Chouser | Chousuke: Or you could use Jarkko :-) |
| 09:39 | Chouser | no other ja* in here |
| 09:41 | LauJensen | Also a good point Mr. Chen |
| 09:45 | Chousuke | Chouser: Yeah, I could, but I doubt I will. :P |
| 09:45 | Fossi | ,(str (/ 100 3)) |
| 09:45 | clojurebot | "100/3" |
| 09:46 | Fossi | i'd really start thinking if my name was chous' uke |
| 09:46 | Chousuke | :P |
| 09:46 | Fossi | except of course if you like a little homoerotic touch :D |
| 09:47 | Chousuke | that's just forcing it. |
| 09:47 | Fossi | i hope not :D |
| 09:48 | Fossi | (it won't get any better from here ;) |
| 09:48 | Chousuke | besides, you're not allowed to break the name between s and u. that's impossible in Japanese orthography :P |
| 10:40 | stuartsierra | Tried to improve performance on base64 in Clojure. http://bit.ly/3ZArh7 |
| 10:40 | stuartsierra | Still 10-20 times slower than Commons Codec, I think limited by boxed bit-ops. |
| 10:42 | cemerick | unless one is targeting Android, etc., why not just use the com.sun stuff? |
| 10:42 | clojurebot | http://clojure.org/rationale |
| 10:42 | cemerick | clojurebot: don't talk to me about full-stack impls, dammit! :-P |
| 10:42 | clojurebot | Huh? |
| 10:44 | stuartsierra | No reason. I'll probably continue using Commons. I just wanted to see if I could do it. |
| 10:44 | Chousuke | stuartsierra: hmm, did you try if escape analysis has any effect on it? |
| 10:44 | stuartsierra | nno |
| 10:45 | cemerick | Don't mind me, I get twitchy when I see pure-clojure reimpls of existing java libs. |
| 10:45 | stuartsierra | But I offer the code up as an optimization challenge. |
| 10:45 | cark | stuart : the line variable could be forced to an int and you could use unchecked functions for it |
| 10:45 | Chousuke | hmm |
| 10:45 | stuartsierra | cark: tried it, difference was neglible |
| 10:45 | Chousuke | I wonder if make-array returns a type-hinted array. |
| 10:46 | cark | i guess you checked everything with *warn-on-reflection* true ? |
| 10:46 | stuartsierra | I don't think so. But I already checked that there are no reflective calls. |
| 10:46 | cark | ok |
| 10:46 | Chousuke | *warn-on-reflection* doesn't warn about array reflection |
| 10:46 | stuartsierra | pre-boxing the bytes as Integers yielded about 10% improvement. |
| 10:47 | Chousuke | ~def bit-and |
| 10:47 | Chousuke | hmm. looks like it does inlining at least. |
| 10:48 | cark | ah these re inlined |
| 10:48 | Chousuke | Is there really no primitive implementation for them? :/ |
| 10:49 | stuartsierra | Apparently not. Look at the BitOps classes in clojure/lang/Numbers.java |
| 10:49 | cark | well this goes to prove that it's good we have java to fall back to for low level stuff |
| 10:50 | cark | but it worries me for clojure-in-clojure ... |
| 10:51 | cark | will we loose lot of performances on data structures ? |
| 10:51 | Chousuke | cark: there's new-new now. you can actually implement interfaces with methods that take and return primitives now. |
| 10:52 | cark | what version is it scheduled for |
| 10:52 | cark | ? |
| 10:52 | Chousuke | 1.1 most likely :P |
| 10:52 | cark | cool =) |
| 10:53 | Chousuke | http://clj-me.blogspot.com/2009/08/clojure-as-fast-as-java.html |
| 10:54 | cemerick | ugh, that title makes me cringe now |
| 10:55 | stuartsierra | I can imagine a really clever compiler that provides a dynamically-typed implementation of bit-ops as a default, but generates primitive methods as needed based on type tags. |
| 10:56 | cark | i don't expect the clojure compiler to ever become very smart... it's ok as long as we have the java alternative |
| 10:58 | Chousuke | I think we have all the tools now to start rewriting a compiler in Clojure but no-one has started anything yet :/ |
| 10:58 | cark | maybe with compiler macros we could already do los of optimizations |
| 10:58 | stuartsierra | Perhaps the good is the enemy of the perfect. |
| 10:59 | Chousuke | I unfortunately know nothing about designing compilers so I wouldn't know where to start ;/ |
| 11:00 | Chousuke | Looking at the java compiler for inspiration is probably not a good idea. |
| 11:01 | cemerick | it seems like stuff like this definitely belongs in the host platform. Even if the clojure compiler were to get super-smart about these sorts of things, it seems like such an impl would depend on Java at the moment, making those optimizations pointless when js or objc or llvm, et al. is the host platform. |
| 11:02 | Chousuke | When I first started writing my clojure-reader I started with a PushbackReader and looked at the java implementation to see how it did things; I didn't get very far. |
| 11:03 | Chousuke | Then I restarted and ignored the java reader and started writing one that just takes a seq of strings as its input. Now it's progressing rather well |
| 11:04 | cemerick | almost certainly not as fast, but I'll bet it'll be a dream to maintain (by comparison) |
| 11:04 | Chousuke | Though I'll probably have to change how the input is fed to it. Because it requires a line-seq, you can't just read "(foo)" from a "(foo)(bar)\n" stream without reading the (bar) from the stream as well |
| 11:05 | Chousuke | but it works character-by-character so that shouldn't be impossible. |
| 11:05 | Chousuke | and yeah, performance is also a secondary concern |
| 11:06 | danlarkin | Chousuke: feature request: """triple quoted strings""" :) |
| 11:06 | cemerick | that's part of why I'm definitely going to produce a binary, serialization-based print-dup alternative -- reading will only get slower over time |
| 11:06 | stuartsierra | I used a PushbackReader in my JSON lib, worked fine, but the result was still imperative-looking. |
| 11:06 | Chousuke | danlarkin: I'll implement feature parity first. |
| 11:06 | Neronus | re smart compiler: The clojure compiler doesn't need to be that smart. javac isn't really smart either |
| 11:06 | Chousuke | and even if the reader turns out not quite good enough, I hope my helper functions will be useful at least :P |
| 11:07 | cemerick | danlarkin: to handle the 80% userland reader macro use case? |
| 11:07 | Chousuke | I already have a syntax-quote macro |
| 11:07 | danlarkin | cemerick: hm? |
| 11:07 | Chousuke | which I haven't tested thoroughly, but it appears to work :P |
| 11:08 | cemerick | danlarkin: I thought that's why you were suggesting triple-quoted strings |
| 11:08 | danlarkin | cemerick: oh, I want them so one doesn't have to escape inside docstrings |
| 11:08 | cemerick | ah |
| 11:09 | cemerick | heh, that'd make things easier for tools to reformat code + docs |
| 11:10 | Chousuke | If I could use something like fnparse I bet writing the reader would be ridiculously easy. |
| 11:10 | cemerick | there was a discussion on the group about using triple-quoted strings as a way to cover some large chunk of the use-cases for reader macros |
| 11:10 | danlarkin | and writing docstrings a lot more sane... |
| 11:11 | danlarkin | I must've missed that discussion |
| 11:11 | danlarkin | sounds interesting |
| 11:12 | cemerick | it was earlier this week, I think |
| 11:20 | LauJensen | ~paste |
| 11:20 | clojurebot | lisppaste8, url |
| 11:20 | lisppaste8 | To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste. |
| 11:20 | lisppaste8 | Lau pasted "POSTing a file" at http://paste.lisp.org/display/85738 |
| 12:34 | Chousuke | hm. |
| 12:35 | Chousuke | I'm again getting the eldoc lag with clojure-mode :( |
| 12:35 | Chousuke | earlier, it did seem like it honoured the setting |
| 12:35 | Chousuke | but now it doesn't, again. |
| 13:32 | LauJensen | Sukechou: Sounds awful |
| 13:32 | LauJensen | Whats eldoc doing for you ? |
| 13:52 | Chousuke | LauJensen: :P |
| 13:52 | Chousuke | LauJensen: I don't know what's causing it. |
| 13:52 | LauJensen | Sukechou: What it meant was: What do you gain from eldoc, I never used it? |
| 13:53 | Chousuke | it shows the arglists in the minibuffer. |
| 13:53 | Chousuke | LauJensen: but for some reason, clojure-mode ignores the eldoc delay altogether and that causes lag in display rendering. |
| 13:53 | Chousuke | maybe I need to git bisect my config... |
| 13:54 | Chousuke | though it might just be some incompatibility with clojure-mode and the version of clojure I'm using. |
| 13:54 | Chousuke | and/or swank |
| 13:55 | Chousuke | I'm somewhat behind master in my clojure-reader branch. I haven't done a merge since I started coding it. |
| 13:56 | Chousuke | and I won't, until I'm mostly done with it. :P |
| 13:56 | tomoj | are we supposed to have tab-completion in source buffers, or just in the slime repl? |
| 13:56 | LauJensen | How close are you to completeting it ? |
| 13:56 | LauJensen | tomoj: In source buffers you can also have it by binding tab to dabbrev-expand as I recall |
| 13:57 | tomoj | LauJensen: nice, thanks |
| 13:57 | Chousuke | LauJensen: Well, it's almost at feature-parity I think. |
| 13:57 | Chousuke | missing unicode escapes, #! and #_ ... and maybe some other stuff I've forgotten. |
| 13:58 | LauJensen | feature-parity = feature-complete? |
| 13:58 | Chousuke | I guess. |
| 13:59 | Chousuke | But after I'm done with the basic functionality there's still a fair amount of work before it can replace the java reader. |
| 14:00 | Chousuke | if you want to play with it, you can find it on my github, entirely undocumented! |
| 14:00 | LauJensen | I cant help wonder why its such a big challenge to write a reader where you already have the java code ? |
| 14:00 | Chousuke | Well, I'm not looking at the java code at all :P |
| 14:00 | Chousuke | But it hasn't been much of a challenge so far, really. :) |
| 14:01 | Chousuke | I've just been slow with it. |
| 14:01 | Chousuke | implementing a feature or two at a time whenever I feel like it. :P |
| 14:01 | LauJensen | Ah ok |
| 14:01 | LauJensen | Spoken like a true freetard :) |
| 14:01 | Chousuke | Well, I'm in no hurry. |
| 14:02 | Chousuke | I suppose I should add my rh-from-string function to the source file :P |
| 14:04 | wtetzner | hey guys, i wrote an ant build script for one of my projects, and when compiling i get this error: [java] Exception in thread "main" java.io.FileNotFoundException: Could not locate clojure/test__init.class or clojure/test.clj on classpath: (read.clj:33) |
| 14:04 | wtetzner | does anyone know what i'm missing from the classpath? |
| 14:04 | Chousuke | the consume function takes a "reader-handle" which is a fancy way of saying "a pair containing lines a seq of strings and an offset to the current line" |
| 14:04 | wtetzner | i included clojure.jar and clojure-contrib.jar |
| 14:04 | Chousuke | as* |
| 14:05 | Chousuke | wtetzner: which version of clojure? |
| 14:05 | wtetzner | 1.0 |
| 14:05 | Chousuke | 1.0 doesn't have clojure.test |
| 14:05 | wtetzner | hmm |
| 14:05 | Chousuke | you need a recent version from from git |
| 14:05 | wtetzner | ok |
| 14:06 | LauJensen | Its also worth noting that tests are primarily for noobs |
| 14:07 | wtetzner | Chousuke: so if 1.0 doesn't have clojure.test, why would it be looking for it when compiling a class? |
| 14:09 | hiredman | wtetzner: are you using the 1.0 compat branch of contrib? |
| 14:10 | wtetzner | hiredman: i don't know |
| 14:10 | wtetzner | that might be the problem |
| 14:10 | wtetzner | how do i know if it's compatible? |
| 14:12 | wtetzner | hiredman: that was the problem |
| 14:13 | wtetzner | hiredman: i used the wrong version of clojure-contirb |
| 14:13 | wtetzner | thanks |
| 14:16 | LauJensen | Gents - I'm trying to file an image to disk via a bufferedimage. There's a static function called ImageIO/write which should handle this and it works when I output my image as png, but b0rks when I choose jpg. Any idea why ? |
| 14:17 | Chouser | I have a vague recollection of needing some kind of external plugin to write certain kinds of image file formats. I may be pretty off base though. |
| 14:18 | LauJensen | They docs say the same thing, but for everything but gif, jpg and png, which should be available on all platforms |
| 14:18 | LauJensen | "Their" |
| 14:20 | LauJensen | Also - When I call ImageIO/getSupportedFormats it says jpg, JPG and jpeg are supported |
| 14:21 | LauJensen | ,(doseq [r (ImageIO/getWriterFormatNames)] (print r)) |
| 14:21 | clojurebot | java.lang.Exception: No such namespace: ImageIO |
| 14:22 | LauJensen | ,(doseq [r (javax.imageio.ImageIO/getWriterFormatNames)] (print r)) |
| 14:22 | clojurebot | BMPbmpjpgJPGwbmpjpegpngPNGJPEGWBMPGIFgif |
| 14:24 | Chouser | what kind of b0rks do you get? |
| 14:24 | LauJensen | Ah, "JPG" works... |
| 14:24 | LauJensen | Exception in thread "AWT-EventQueue-0" javax.imageio.IIOException: Invalid argument to native writeImage |
| 14:24 | LauJensen | at com.sun.imageio.plugins.jpeg.JPEGImageWriter.writeImage(Native Method) |
| 14:24 | LauJensen | at com.sun.imageio.plugins.jpeg.JPEGImageWriter.writeOnThread(JPEGImageWriter.java:1055) |
| 14:24 | LauJensen | at com.sun.imageio.plugins.jpeg.JPEGImageWriter.write(JPEGImageWriter.java:357) |
| 14:24 | LauJensen | (oops, sorry, I know that was 4 lines) |
| 14:26 | LauJensen | JPEG didnt work either |
| 14:26 | LauJensen | jpg in its entirety is b0rked |
| 14:28 | tomoj | LauJensen: which java? |
| 14:28 | l0st3d1 | Hi - newbie question - If I have a list like '(1 2 3 4 5) how do I turn that into a list of lists with every combination missing, i.e. '(1 2 3 4 5), '(nil 2 3 4 5), '(1 nil 3 4 5). '(nil nil 3 4 5), etc ? |
| 14:28 | LauJensen | Gif and Png works, Bmp outputs faulty file, jpg doesnt output anything |
| 14:28 | LauJensen | tomoj: 1.6 |
| 14:28 | tomoj | sun? |
| 14:29 | LauJensen | Si |
| 14:29 | tomoj | dunno then |
| 14:29 | cemerick | LauJensen: you're doing something wrong :-) |
| 14:29 | LauJensen | cemerick: thanks for chiming in, we'll talk tomorrow right? :) |
| 14:29 | cemerick | ? |
| 14:29 | Chouser | l0st3d1: how long do you expect that list to get? |
| 14:30 | LauJensen | Hmm, whats openjdk doing on this system ? |
| 14:30 | l0st3d1 | 10 - 15 items |
| 14:30 | tomoj | LauJensen: that could be the problem |
| 14:30 | LauJensen | tomoj: Of course its the problem. its developed by freetards and lusers (quote linuxhater)... :) |
| 14:35 | LauJensen | apt-get purge openjdk* , and tada!! :) |
| 14:35 | LauJensen | Thanks for staying sharp tomoj |
| 14:36 | l0st3d1 | chouser: 10 - 15 items, so not too long. I started with (let [l '(1 2 3 4 5)] (for [i l] (map #(if (not (= % i)) % nil) l))), but I'm not sure how to proceed |
| 14:36 | Chouser | l0st3d1: a tidy recursive solution seems likely. |
| 14:37 | tomoj | looks like 32 items to me |
| 14:38 | LauJensen | Ok, interesting. The image is now outputted without errors, the resolution is correct, but its entirely black, all details are lost. And only when output in jpg |
| 14:40 | Chouser | (defn nils [c] (let [[c1 & cs] c] (if cs (concat (map #(cons c1 %) (nils cs)) (map #(cons nil %) (nils cs))) [[c1] [nil]]))) |
| 14:41 | Chouser | ,(letfn [(nils [c] (let [[c1 & cs] c] (if cs (concat (map #(cons c1 %) (nils cs)) (map #(cons nil %) (nils cs))) [[c1] [nil]])))] (nils '(1 2 3))) |
| 14:41 | clojurebot | ((1 2 3) (1 2 nil) (1 nil 3) (1 nil nil) (nil 2 3) (nil 2 nil) (nil nil 3) (nil nil nil)) |
| 14:42 | tomoj | I guess before you blow the stack you'll have far too many possibilities anyway? |
| 14:42 | Chouser | that'll blow the stack for longer input lists |
| 14:42 | LauJensen | Chouser, isnt this where you trampoline it instead? |
| 14:43 | Chouser | that'd be one solution for longer lists. I'm sure there are others. |
| 14:43 | l0st3d1 | Chouser: excellent ... thanks ... I was messing with embedded fors ... longer lists and performance aren't a problem for me right now ... many thanks |
| 14:44 | Chouser | I think using 'for' instead of recursion would only work if you new the length of the list at compile time. |
| 14:44 | Chouser | you'd need one 'for' clause per list item |
| 14:45 | Chouser | you could use 'for' instead of the 'map' in my solution of course, and still recurse. |
| 14:45 | l0st3d1 | I'm slowly reading your solution and trying to inderstand ;) |
| 14:46 | l0st3d1 | I was trying to build a partial list in an outer for and mapping all the things in the outer list to nil in an inner list ... |
| 14:46 | l0st3d1 | I'm sure it wouldn't have worked ;) |
| 14:58 | LauJensen | Ok - The situation is this. Using Sun-java6 I can save an imageicon=>bufferedimage=>file. Perfect. Except to save it correctly you need to know the type of the image, for instance TYPE_INT_RGB. This differes from image to image. Anybody know an easy way to determine which type is correct? |
| 15:00 | wtetzner | hey guys, another question: i'm signing some jar files to be run as an applet, and i'm getting the error: Exception in thread "main" java.lang.SecurityException: class "clojure.proxy.java.lang.Object$ActionListener"'s signer information does not match signer information of other classes in the same package |
| 15:00 | wtetzner | i think it's because the actionlistener class ends up in the same jar file as the applet jar |
| 15:00 | wtetzner | but clojure is in its own jar file |
| 15:01 | wtetzner | is there a solution to this? |
| 15:01 | Chouser | I've always put all classes into a single .jar file for applets |
| 15:02 | wtetzner | so you unzip clojure.jar etc. and put the contents into the applet jar? |
| 15:02 | Chouser | yeah |
| 15:02 | wtetzner | ok |
| 15:02 | Chouser | dunno if that's right or recommended or anything, but I never figured out how to specify more than one .jar for an applet, so this is what I've been doing. |
| 15:04 | wtetzner | in the applet tag, you can use the archive attribute: archive="applet.jar,clojure.jar,clojure-contrib.jar" |
| 15:05 | wtetzner | but if you sign each one separately, even using the same certificate, it doesn't like it |
| 15:05 | wtetzner | if two things from the same package are in different jars |
| 15:06 | wtetzner | are there any licensing issues of me moving the ActionListener stuff to the clojure.jar file? |
| 15:08 | Chouser | I think you can combine the .class files in whatever jars you want. Distributing modified class files is where you start running into restrictions. I think. |
| 15:08 | wtetzner | ok |
| 15:08 | wtetzner | thanks |
| 15:11 | LauJensen | Ok - The situation is this. Using Sun-java6 I can save an imageicon=>bufferedimage=>file. Perfect. Except to save it correctly you need to know the type of the image, for instance TYPE_INT_RGB. This differes from image to image. Anybody know an easy way to determine which type is correct? |
| 15:11 | LauJensen | Followup: I've now tried forcing all image types indivually and none of them emits a correct image - whats up !? |
| 15:12 | Chouser | LauJensen: maybe #java can help you? |
| 15:12 | LauJensen | Last resort |
| 15:13 | hiredman | are you sure imageicon is what you want? |
| 15:14 | LauJensen | Ok, update: passing the getScaledInstance image through ImageIcon through .getImage did the trick |
| 15:14 | LauJensen | All is well in la la land |
| 15:15 | hiredman | ImageIO can give you a buffered image from a url |
| 15:16 | LauJensen | Trouble is I wont always have an Url, sometimes I'll just have some scaling factors and an image |
| 15:16 | LauJensen | But its working now |
| 15:17 | LauJensen | True to Clojure's slogan "I get by with a little from my friends" |
| 15:33 | Chouser | I guess it hinges on the phrase "derivitive work". I would assume changing Clojure's sourse results in a derivitive work, but I would think combining it in a jar with other stuff does not? |
| 15:35 | tomoj | "contributions do not include additions to the program which... are seperate modules of software distributed in conjuction with thi program under their own license agreement" |
| 15:35 | Chouser | ah, nice. |
| 15:35 | rsynnott | that's a nice clarification |
| 15:35 | rsynnott | far too many people either don't clarify or clarify the other way ;) |
| 15:36 | rsynnott | (the authors of clisp, for instance, claim that any piece of software written in clisp and accessing the foreign function interface _falls under GPL for redistribution purposes_) |
| 15:36 | Chouser | that then shifts to what makes up a "module". I suppose, one might try to claim that's what a .jar is. |
| 15:41 | wtetzner | why are classes created by proxy in the clojure namespace vs the namespace proxy was called in? |
| 15:45 | tomoj | second clause in that list was that contributions do not include additions which are not derivative works :) |
| 15:45 | Chouser | this has come up before. As it is, multiple namespaces can share the same proxy class if it would be identidal |
| 15:45 | Chouser | also they're put in a package that's not used for anything else, which reduces the changes of collision. |
| 15:46 | Chouser | wtetzner: all that said, it might be better to put them elsewhere for easier packaging. |
| 15:54 | weissj | I'd like to make a function that if I pass it '("user" "passwd") it will return a lazy seq of ("user1" "pass1"), ("user2" "pass2") ... |
| 15:55 | weissj | i can't quite figure out where to put the call to inc :) |
| 15:55 | weissj | sorry s/passwd/pass |
| 15:56 | wtetzner | Chouser: yeah, for now i'm just putting everything in one jar |
| 15:56 | wtetzner | Chouser: but it would be nice to not have to upload all of the clojure stuff every time i re-upload the applet |
| 15:56 | Chouser | yeah |
| 15:57 | Chouser | wtetzner: do you really have to sign the applet? |
| 15:59 | wtetzner | Chouser: i got security exceptions from dynamic class loading when the applet wasn't signed |
| 15:59 | Chouser | if you're careful to remove all reflection and AOT compile it, those go away. |
| 16:00 | Chouser | ,(letfn [(crack [c] (cons c (map (fn [n] (map #(str % n) c)) (iterate inc 1))))] (take 3 (crack '("user" "pass")))) |
| 16:00 | clojurebot | (("user" "pass") ("user1" "pass1") ("user2" "pass2")) |
| 16:00 | wtetzner | Chouser: how can i tell if i've removed all reflection? |
| 16:00 | weissj | Chouser: thanks |
| 16:00 | Chouser | (set *warn-on-reflection* true) before you even do (ns ...) at the top of your file. |
| 16:00 | wtetzner | Chouser: oh, ok |
| 16:01 | Chouser | then you'll get warnings at compile time for code that would cause security exceptions at runtime |
| 16:01 | wtetzner | Chouser: so to remove reflection, what do i need to do? just add in type hints? |
| 16:03 | Chouser | wtetzner: generally, yeah. |
| 16:03 | Chouser | hm, last I checked 'ns' itself generated some reflection. I have a patch for that, but haven't mentioned to anyone yet. |
| 16:04 | Chouser | http://tinyurl.com/nqqubv -- clojure-type-hints.diff |
| 16:05 | Chouser | dunno if that's still needed or not |
| 16:08 | Chouser | ah, it is. Or use the patch here: http://www.assembla.com/spaces/clojure/tickets/171 |
| 16:09 | wtetzner | Chouser: also, i wanted to be able to use the java web start, and i think that requires that the files are signed |
| 16:09 | wtetzner | Chouser: i want the ability to drag the applet from the browser, and create a link on the desktop |
| 16:09 | Chouser | ah, that's why I asked in the first place. |
| 16:10 | Chouser | If you have some other reason to sign it, it's probably not worth chasing down all the runtime reflection (except possibly for performance). |
| 16:10 | wtetzner | Chouser: yeah, it seems like a lot of work to add all those type hints |
| 16:10 | Chouser | yep. |
| 16:10 | wtetzner | and then the code doesn't look as pretty |
| 16:21 | LauJensen | Anybody here know how to integrate a .clj script into nautilus' right-click menu ? |
| 16:24 | angerman | how would I translate something like Foo.class (java) to clojure? |
| 16:24 | hiredman | Foo |
| 16:27 | Chouser | no official way to get to a map's .keySet() method? |
| 16:28 | wtetzner | what does .keySet() do? |
| 16:28 | Chouser | it seems sad to do an O(n) (set (keys my-map)) when (.keySet my-map) is there already. |
| 16:29 | kotarak | Chouser: well keys could return the keySet, no? (Dunno whether it does...) |
| 16:29 | wtetzner | keys returns a sequence of keys |
| 16:30 | kotarak | Then it could be modified to return the keySet... |
| 16:30 | wtetzner | or just add a key-set function to clojure.core |
| 16:30 | kotarak | (which might not help much, if the set has to be constructed internally also....) |
| 16:31 | kotarak | I think (.keySet some-clojure-map) already works. |
| 16:31 | wtetzner | yeah |
| 16:31 | wtetzner | but it's not as pretty as (key-set some-clojure-map) |
| 16:31 | Chouser | not as pretty and more likely to change out from under me. |
| 16:31 | wtetzner | oh yeah, that too |
| 16:32 | kotarak | Chouser: then work on rhickey to get keys returns the set. :) Turning it back into a seq is possible anyway... |
| 16:33 | Chouser | well, that's why I'm asking. |
| 16:36 | rhickey | as long as a map is a Map then keySet will work |
| 16:36 | rhickey | e.g. low risk |
| 16:36 | Chouser | ok |
| 16:37 | Chouser | if 'keys' only promised a collection instead of a seq, it could call .keySet itself. |
| 16:52 | wtetzner | i don't know if you guys have seen this already, but this is a set of "look and feel"'s for swing |
| 16:52 | wtetzner | https://substance.dev.java.net/see.html |
| 16:52 | wtetzner | it makes swing look really good |
| 16:53 | gko | hello. |
| 16:55 | cemerick | wtetzner: yeah, substance is awesome. I'm hoping NetBeans becomes compatible with it in v7. |
| 16:56 | wtetzner | i think one of the reasons people don't like java applications is that the default gui is so ugly |
| 16:57 | gko | I have code like this: ... (let [x (produce-a-list) b (map #(use-list %) x)]) ... |
| 16:57 | gko | after (produce-a-list), x has for example 10 elements, but when using map, the use-list function is called only twice... |
| 16:58 | Chouser | gko: map is lazy |
| 16:58 | Chouser | gko: it will call use-list only as many times as needed, based on whatever is using b |
| 16:59 | gko | Chouser: so doall ? |
| 16:59 | Chouser | if use-list has side-effects, and you want those to happen for every item in x, I'd recommend doseq |
| 16:59 | gko | Chouser: but in the let, the list is used... |
| 16:59 | Chouser | but doall and/or runall might do as well. |
| 17:00 | Chouser | gko: oh, it has side effects and the return values are used? |
| 17:00 | gko | yes |
| 17:01 | Chouser | it might be worth trying to split that up a bit -- keep your side-effect stuff as separate as possible from the seq/computational stuff. |
| 17:01 | Chouser | but failing that, doall or vec wrapped around map will force it and let you get at the values. |
| 17:03 | gko | not working with doall... |
| 17:03 | gko | I have code like this: ... (let [x (produce-a-list) b (map #(use-list %) (doall x))]) ... |
| 17:03 | Chouser | (doall (map use-list x)) |
| 17:03 | kotarak | (doall (map ...)) |
| 17:03 | wtetzner | gko: call doall over the map |
| 17:04 | gko | Oh... It works now... Thanks! |
| 17:05 | gko | Have seriously to read that chapter 5 .. |
| 17:57 | sh10151 | I really dislike Groovy. :( |
| 17:57 | Chouser | hm, what's groovy's weak spot? macroless? How's its performance? |
| 17:58 | Chouser | mutable |
| 17:58 | sh10151 | They have a way to get at the abstract syntax tree |
| 17:58 | sh10151 | not sure if anyone would care either way, though |
| 17:59 | sh10151 | Unfortunately I think the main reason it's gotten traction is it is designed to look enough like Java to fool the unwary. |
| 17:59 | Chouser | yeah |
| 17:59 | sh10151 | never mind that declaring a variable a certain type and then assign to it does an autocast, even when an autocast is nonsensical |
| 18:00 | sh10151 | I mean, honestly if it were familiarity they were after, JavaScript Rhino should have been top choice -- but no one hypes it. |
| 18:00 | hiredman | yeggie did |
| 18:00 | sh10151 | Groovy seems to have a big hype machine on the enterprisey blogroll |
| 18:00 | sh10151 | yeah and look what happened to him! |
| 18:00 | sh10151 | like that! *poof* he's gone! |
| 18:00 | Chouser | what did happen to him? |
| 18:00 | sh10151 | ;) |
| 18:00 | hiredman | good point |
| 18:01 | sh10151 | probably got pulled into Google's V8 and now can't talk about it any more... |
| 18:01 | sh10151 | just my theory |
| 18:01 | hiredman | ooo |
| 18:01 | sh10151 | You like JavaScript eh, well *JavaScript This!* |
| 18:03 | sh10151 | anyway, not sure what to do about it. I'm giving a presentation on Clojure at work next week but who knows how it will be received. :) |
| 18:03 | hiredman | hard to say, I have difficulty imagining anyone not jumping on clojure, but I guess I am brainwashed |
| 18:04 | Chouser | .keySet returns a set that is not a IFn |
| 18:05 | hiredman | how unfortunate |
| 18:05 | hiredman | ~ticket #69 |
| 18:05 | clojurebot | {:url http://tinyurl.com/ntknnt, :summary "GC Issue 66: Add \"keyset\" to Clojure; make .keySet for APersistentMap return IPersistentSet", :status :test, :priority :low, :created-on "2009-06-17T19:55:38+00:00"} |
| 18:06 | Chouser | huh! |
| 18:07 | sh10151 | well |
| 18:07 | sh10151 | early feedback is people are prejudiced against Lisp ;) |
| 18:08 | Chouser | I'm shocked. shocked. |
| 18:08 | hiredman | sh10151: shows what they know |
| 18:10 | sh10151 | well, again if they were like "JavaScript works fine for us" that'd be one thing |
| 18:10 | sh10151 | but clojure is sensitive to where you stick newlines, and in a semantic way not a syntactic way |
| 18:11 | sh10151 | i.e. if you put a newline in one place, it behaves one way, and if you put a newline in another, it behaves differently |
| 18:11 | Chouser | that's groovy? |
| 18:11 | sh10151 | sorry |
| 18:11 | sh10151 | s/clojure/groovy/ of course :) |
| 18:11 | Chouser | javascript can occasionally have issues with that too |
| 18:11 | hiredman | sh10151: do you have anything on groovy clojure integration? |
| 18:12 | sh10151 | http://groovy.codehaus.org/Things+you+can+do+but+better+leave+undone |
| 18:12 | sh10151 | hehe no :) |
| 18:12 | sh10151 | Chouser: yes but not as frequently because JavaScript doesn't use a bare {} as its anonymous function syntax |
| 18:12 | hiredman | if you can get them to use clojure datastructures in groovy you are most of the way there |
| 18:12 | Chouser | sh10151: ah. |
| 18:13 | syamajala | i need a crash course in java |
| 18:13 | syamajala | is there a good book? |
| 18:13 | sh10151 | hiredman: hey, that's a good point |
| 18:13 | sh10151 | hiredman: I might give that a shot |
| 18:13 | hiredman | http://groovy.codehaus.org/JSR-223+access+to+other+JVM+languages |
| 18:14 | syamajala | i have experience with lisp/clos, ruby, and c, as well as a tiny bit of objc, but have never used java |
| 18:14 | syamajala | i've also read a bunch programming clojure |
| 18:15 | hiredman | there are video lectures on java from a few schools out there |
| 18:15 | sh10151 | syamajala: Maybe the Core Java book? |
| 18:15 | sh10151 | syamajala: Whatever you do, make sure it's recent |
| 18:15 | sh10151 | syamajala: covering Java 5 at least |
| 18:16 | sh10151 | I thought "The Java Programming Language" to be reasonable. |
| 18:16 | sh10151 | not quite as nice as "The C Programming Language" but that's down to all the libraries they cover. |
| 18:17 | syamajala | ok, i'm really just looking for something lite that can quickly get me up to speed on java's version of oop |
| 18:17 | hiredman | http://webcast.berkeley.edu/course_details_new.php?seriesid=2008-D-26332&semesterid=2008-D is java |
| 18:19 | sh10151 | "Effective Java" is light |
| 18:19 | sh10151 | but you'd have to pick up a lot by reading between the lines as far as basic syntax goes |
| 18:20 | sh10151 | I just have two Java books on my bookshelf: "The Java Programming Language" and "Effective Java." |
| 18:20 | sh10151 | the rest is pretty much in the javadocs online |
| 18:21 | hiredman | being able to read javadocs is best |
| 18:21 | hiredman | actually knowing java is kind of secondary |
| 18:22 | syamajala | sh10151: i don't think syntax will matter much because of clojure |
| 18:23 | syamajala | it would just better if i actually knew what things like a proxy are |
| 18:23 | sh10151 | in clojure or in java? |
| 18:23 | syamajala | java |
| 18:23 | hiredman | ,(class (proxy [Object] [])) |
| 18:23 | clojurebot | java.lang.IllegalStateException: Var null/null is unbound. |
| 18:23 | hiredman | ouch |
| 18:23 | sh10151 | in clojure it's just a short way to write new Interface() { public method1() {}} etc |
| 18:23 | sh10151 | at least afaict |
| 18:24 | hiredman | ,(class (proxy [clojure.lang.IDeref] [] (deref [] 1))) |
| 18:24 | clojurebot | java.lang.IllegalStateException: Var null/null is unbound. |
| 18:24 | hiredman | odd |
| 18:24 | Chousuke | hmm. |
| 18:24 | Chousuke | :p |
| 18:24 | syamajala | sh10151: see, i have no idea what an interface is though |
| 18:24 | Chousuke | syamajala: just a bunch of methods :) |
| 18:24 | syamajala | kinda like generic functions? |
| 18:24 | hiredman | no |
| 18:24 | sh10151 | syamajala: In Java an interface is a data type |
| 18:24 | Chousuke | an interface is a bunch of methods for a class to implement. |
| 18:24 | hiredman | an interface is a collection of method signatures |
| 18:25 | syamajala | ok |
| 18:25 | syamajala | yeah this is the type of stuff i need to learn... |
| 18:25 | hiredman | a class implements an interface by provoding bodies |
| 18:25 | sh10151 | maybe you should go l33t and read "A Little Java, A Few Patterns" |
| 18:25 | sh10151 | it's very light |
| 18:26 | sh10151 | not exactly high on the "best practices for enterpisey java" chart though |
| 18:26 | hiredman | http://math.hws.edu/javanotes/ |
| 18:26 | syamajala | ;-D it looks like the little schemer! |
| 18:28 | sh10151 | syamajala: exactly so |
| 18:28 | sh10151 | syamajala: actually it's pretty good |
| 18:28 | sh10151 | syamajala: It might have been the first Java book I read |
| 18:28 | syamajala | is it the same question answer type thing? |
| 18:28 | sh10151 | syamajala: yes |
| 18:28 | sh10151 | syamajala: and don't read it on an empty stomach |
| 18:28 | sh10151 | syamajala: it's all about pizza |
| 18:28 | syamajala | heh |
| 18:29 | sh10151 | definitely covers interfaces though |
| 18:29 | sh10151 | and how they work in patterns |
| 18:30 | syamajala | my neighbor let me borrow the little schemer when i was in high school, it helped with understanding recursion |
| 18:31 | sh10151 | i will bbl |
| 18:31 | sh10151 | toddler on rampage |
| 18:32 | syamajala | maybe i should get a few other books while i'm at it |
| 18:32 | hiredman | there is a clojure bookshelf |
| 18:32 | hiredman | ~books |
| 18:32 | clojurebot | Titim gan éirí ort. |
| 18:32 | hiredman | ~bookshelf |
| 18:32 | clojurebot | It's greek to me. |
| 18:32 | hiredman | bah |
| 18:32 | syamajala | i mean other books |
| 18:33 | syamajala | i've always wanted to learn haskell and erlang |
| 18:33 | hiredman | syamajala: books on those languages are on the list |
| 18:33 | hiredman | ~bookshelf is http://www.amazon.com/Clojure-Bookshelf/lm/R3LG3ZBZS4GCTH |
| 18:33 | clojurebot | You don't have to tell me twice. |
| 18:34 | syamajala | prolog! |
| 18:37 | hiredman | total for the list is only $1,670 |
| 18:38 | syamajala | i have some very big lists |
| 18:38 | syamajala | 47 cs books and 46 math books |
| 19:06 | lowlycoder | does clojure have any good constructs for persistence/hibernation? |
| 19:06 | cemerick | for those who frequent databases: are there any good clojure-y strategies for coordinating database operations and in-memory state? |
| 19:12 | cemerick | hrm, I wonder if I'm overusing (-> foo .bar .baz (.blah arg)) |
| 19:15 | Chouser | cemerick: is that even possible? |
| 19:15 | cemerick | well, my code is becoming littered with them :-P |
| 19:16 | cemerick | there's borderline case of (.method (SomeClass/staticMethod) arg) vs. (-> (SomeClass/staticMethod) (.method arg)) |
| 19:16 | cemerick | I suppose the latter is clearly preferable, but I start worrying when I use something too much :-) |
| 19:18 | lowlycoder | how can i, on exception, get a repl in the stack frame, rather than ust |
| 19:18 | lowlycoder | just a printout of the stack frame? |
| 19:22 | cemerick | lowlycoder: get a repl in the stack frame? |
| 19:22 | lowlycoder | yes |
| 19:22 | lowlycoder | and to be able to move up & down frames |
| 19:22 | cemerick | ah |
| 19:22 | cemerick | can't with the current impl |
| 19:22 | lowlycoder | so when it gives me an error of saying "x" is nil, and I see what I have let [{x :x} p] ... i can see what p is |
| 19:23 | lowlycoder | wtf? isn't "exception triggers recursive repl" standard to lisps? |
| 19:23 | cemerick | definitely possible in the JVM, but not in place |
| 19:23 | cemerick | lowlycoder: common lisps, yes |
| 19:23 | lowlycoder | scheme as well |
| 19:23 | lowlycoder | i'm disappointed, ... it's a common way I debug code :-( |
| 19:23 | cemerick | well, scheme is a broad world :-) |
| 19:23 | lowlycoder | how do you debug clojure code without recursive repl, println's all over the place? |
| 19:24 | Carkh | cemerick : really , possible in the jvm ? |
| 19:24 | Carkh | that would be so cool =) |
| 19:24 | cemerick | lowlycoder: no, current practice is to use a debugger. Enclojure is good in this respect. |
| 19:24 | Carkh | lowlycoder : i do print all over the place =) |
| 19:25 | cemerick | Carkh: yeah. Many Java IDE's are capable of "break on error" -- it's baked in to the JVM. |
| 19:25 | Carkh | debuggers are evil |
| 19:25 | cemerick | clojure doesn't hook into it, though. |
| 19:25 | cemerick | Carkh: it's all the same machinery, at least in the jvm / clr |
| 19:25 | Carkh | cemerick : i would love to break and add/modify definitions, common lisp style |
| 19:26 | cemerick | well, we're < 2 years in, CL's had ~25. Let's give it another year, and I'll bet you'll be able to do that. :-) |
| 19:27 | Carkh | hehe ok =- |
| 19:27 | rsynnott | common lisp's break isn't all that great in most implementations |
| 19:27 | clojurebot | Lisp isn't a language, it's a building material. |
| 19:28 | rsynnott | (and slime's support for it is generally very poor; it's one of the bits that isn't maintained well) |
| 19:29 | cemerick | agreed. I've seen some pretty hot stuff in lispworks, tho. |
| 19:29 | rsynnott | yep, lispworks has good debug facilities |
| 19:29 | rsynnott | the whole lispworks ide is terribly impressive |
| 19:30 | cemerick | I wonder if they could make a run at a clojure environment. |
| 19:30 | rsynnott | it's interesting that break-style debug facilities don't even seem to see much use, though |
| 19:30 | rsynnott | even where they work well |
| 19:30 | rsynnott | the slime one is basically undocumented |
| 19:31 | rsynnott | cemerick: I doubt you'd get a lispworks class slime dev environment without a major funded/commercial project |
| 19:31 | rsynnott | *clojure dev that is |
| 19:31 | cemerick | yeah, that's what I was saying. |
| 19:31 | rsynnott | MCL's was also quite nice |
| 19:31 | cemerick | e.g. a for-pay NetBeans plugin or whatever. |
| 19:32 | rsynnott | in my experience, even the best netbeans/eclipse plugins just aren't that food |
| 19:32 | rsynnott | *good |
| 19:33 | cemerick | no, mostly because they're unambitious junk with no market |
| 19:33 | cemerick | there's no market for dev tools in general |
| 19:33 | rsynnott | hasn't been for a while |
| 19:33 | cemerick | but depending on how the community goes, they could have a *growing* market of clojure devs willing to drop some real money on a top-notch environment |
| 19:33 | rsynnott | the good ones are mostly built t a loss to push other products |
| 19:34 | rsynnott | x-code, visual studio etc |
| 19:34 | cemerick | I can't imagine there's much upside in the CL tooling space. |
| 19:34 | rsynnott | hasn't really happened elsewhere |
| 19:34 | rsynnott | ruby doesn't even have a slime-class dev environment, for instance |
| 20:14 | cemerick | maybe rather than eliminating use, (use foo.bar.baz) should expand to (require [foo.bar.baz :as baz]) |
| 20:14 | cemerick | I do the latter constantly |
| 20:44 | JAS415 | is it wrong to want java to be much less verbose? |
| 20:44 | JAS415 | i can touch type pretty well and i'm getting tired |
| 20:56 | tomoj | use is going away? |
| 20:58 | cemerick | there's been a lot of talk about unifying require and use |
| 20:58 | cemerick | and require's usage is definitely more idiomatic |
| 21:06 | tomoj | what's a good way to represent a DAG? |
| 21:06 | tomoj | I'm thinking a vertex can be a map with an :edges key pointing to a vector of other vertices, as long as I never try to print that out |
| 21:07 | lowlycoder | why does immutabilty allow correct implementations of hashCode() and equals() autoamtically? |
| 21:08 | Chouser | tomoj: why could a vertex not just be a vector of other vertices? |
| 21:09 | tomoj | Chouser: need other info on each vertex |
| 21:09 | tomoj | hmm.. actually I need other info on each edge too :( |
| 21:10 | tomoj | lowlycoder: not sure what you mean by "allow" |
| 21:10 | tomoj | you could easily make an incorrect hashCode on an immutable data structure |
| 21:11 | Chouser | if you have a hash map keyed on mutable objects, and one of those object mutates, you have a real problem. |
| 21:12 | tomoj | hashCode is always an int, though, no? |
| 21:13 | lowlycoder | tomoj: 'allow' = autoamtically generate |
| 21:13 | lowlycoder | also, why does clojure lack continuations |
| 21:13 | tomoj | then it certainly doesn't |
| 21:14 | tomoj | I could hashCode my immutable data structure by returning the current time in seconds |
| 21:14 | Chouser | lowlycoder: clojure uses Java calling conventions for performance, and since Java doesn't have continuations, neither does Clojure. |
| 21:15 | cemerick | few programming environments outside of compliant schemes and smalltalk have "real" continuations |
| 21:15 | lowlycoder | so each clojure call is a java stack frame? |
| 21:15 | cemerick | yup |
| 21:22 | lowlycoder | are java exceptions are resumable? if so, how do I resume clojure code taht's shown an exception at the repl? |
| 21:22 | cemerick | unless you're running with a debugger that's stopping on exceptions, no. |
| 21:23 | lowlycoder | do these things not bother any of you? |
| 21:23 | cemerick | my code doesn't produce exceptions :-D |
| 21:23 | tomoj | if clojure weren't java, no one would know about it |
| 21:23 | tomoj | I'm ok with these things in return for java |
| 21:24 | cemerick | I took a round trip from Java -> python -> CL -> scala -> clojure. The tradeoffs with the last hit my sweet spot. |
| 21:25 | cemerick | well, actually, it was assembly -> RB -> CL -> scheme -> Java -> python -> CL -> scala -> clojure, but whatever :-) |
| 21:25 | lowlycoder | well, i started by pushing electrons around |
| 21:26 | tomoj | what's RB? |
| 21:26 | Ash | Root Beer |
| 21:26 | cemerick | lowlycoder: man, how do you get by with programming languages then? ;-) |
| 21:27 | cemerick | tomoj: RealBasic. It's actually a pretty pleasant environment. I picked it up in high school, used it for screwing around and started doing contract work. |
| 21:27 | cemerick | Then college hit, and someone threw MCL at me. |
| 21:27 | cemerick | if they had given me scheme at that point, I probably would have been a lot happier, a lot sooner |
| 21:40 | Chouser | Everytime I think I'm starting to understand git, I don't. |
| 21:42 | Raynes | I don't understand Git. I just use it. |
| 21:43 | Chouser | the latest commit is "Merge branch 'lazychain'", 'git show' shows me nothing, 'git diff HEAD^' show the preceding commit's diff |
| 21:43 | Chouser | I can't find any branch called 'lazychain'. |
| 21:43 | Chouser | what the heck was checked in? |
| 21:44 | rhickey | Chouser: lazychain was the name of my local branch, I guess that's an automatic message on merge |
| 21:44 | rhickey | I do all of my changes on local branches, then merge into master and push |
| 21:44 | Chouser | the interleave commit was in there? |
| 21:45 | rhickey | right |
| 21:45 | Chouser | ah, ok. |
| 21:45 | rhickey | only that |
| 21:45 | rhickey | I didn't know when I started the branch what the problem was exactly |
| 21:45 | Chouser | sure |
| 21:46 | Chousuke | Chouser: you might want to use some graphical tool for looking at git history. plain git log can be really confusing. |
| 21:47 | Chousuke | you can do a merge and then all the new commits introduced to the branch are somewhere down the log. |
| 21:47 | Chousuke | because they could be somewhat older than the other commits. |
| 21:50 | cemerick | Chouser: gitx is fan-freaking-tastic |
| 21:51 | lowlycoder | why is meta data useful? why do I want to use it? |
| 21:52 | lowlycoder | clearly, its important since it's got it's own macro reader symbol, but why? |
| 21:53 | Chouser | cemerick: wrong platform, but thanks anyway. :-) |
| 21:54 | cemerick | Chouser: no kidding, I pegged you as a mac user |
| 21:54 | cemerick | I mean, isn't everyone? :-P |
| 21:55 | cemerick | lowlycoder: lots of data is orthogonal to your domain data model |
| 21:55 | rhickey | gitx ... shiny |
| 21:55 | Chousuke | heh. |
| 21:55 | Chousuke | yeah, it's definitely shinier than gitk |
| 21:56 | cemerick | rhickey: whoa, yeah, you should've had that from the start :-) |
| 21:56 | tomoj | lowlycoder: used (doc ...) yet? |
| 21:56 | rhickey | cemerick: doing ok with IntelliJ's git support |
| 21:56 | cemerick | yeah. Honestly, I'm so pro-gitx because NetBeans sucks pretty hard on the git front. |
| 21:57 | cemerick | (not that it's not a nice tool all on its own) |
| 21:57 | rhickey | IntelliJ rules for Java |
| 21:57 | rhickey | IMO |
| 21:57 | Chousuke | on a semi-related note, I wonder what happened to egg |
| 21:57 | lowlycoder | tomoj: that's meta data ? |
| 21:57 | Chousuke | it's no longer showing me branch names in history view. |
| 21:57 | cemerick | rhickey: are you using the intellij clojure plugin as well, or still emacs? |
| 21:58 | lowlycoder | tomoj: whoa, the doc-string in defn is meta data? |
| 21:58 | Chouser | well maybe gitx would help. gitk's view of the log is hardly less confusing |
| 21:58 | Chousuke | ,^#'+ |
| 21:58 | clojurebot | {:ns #<Namespace clojure.core>, :name +, :file "clojure/core.clj", :line 629, :arglists ([] [x] [x y] [x y & more]), :inline-arities #{2}, :inline #<core$fn__4091 clojure.core$fn__4091@1bc6ed3>, :doc "Returns the sum of nums. (+) returns 0."} |
| 21:58 | rhickey | cemerick: I do look at and debug Clojure code in IntelliJ, but edit in emacs still until I'm 100% confident in the indentation, right now it is not as sophisticated as emacs for Lisp indentation |
| 21:59 | Chousuke | lowlycoder: all that is standard metadata found on most functions. |
| 21:59 | cemerick | lowlycoder just got bitten by the clojure bug :-P |
| 21:59 | cemerick | I wouldn't be able to cope with using multiple development environments |
| 21:59 | rhickey | does gitx do side-by-side? |
| 21:59 | lowlycoder | rhickey: hey, when are we going to get repls on exceptions? :-) |
| 21:59 | cemerick | hrm, I don't think so |
| 22:00 | rhickey | lowlycoder: not soon |
| 22:00 | lowlycoder | rhickey: why? what can I do to change that? |
| 22:01 | rhickey | cemerick: I'm used to this: http://cloud.github.com/downloads/richhickey/sdb/Picture_1.png |
| 22:03 | rhickey | lowlycoder: If you know about the Java debug API you might have a chance, but Clojure doesn't have the same kind of runtime infrastructure as say a typical CL |
| 22:04 | cemerick | rhickey: Both eclipse and netbeans have break-on-exception capability -- seems like there's a library that could be leveraged somewhere... |
| 22:04 | rhickey | cemerick: I'm happy for any contributions in that area, no doubt there are some facilities, just saying it's not going to fall out of the existing Clojure runtime |
| 22:05 | rhickey | also there's a debugger/debuggee dichotomy |
| 22:05 | cemerick | that's true |
| 22:05 | lowlycoder | how do you do exploratory programming without recursive repls / ability to resume on exceptions? |
| 22:06 | lowlycoder | above dichotomy = in existing libraries, i.e. if we use it', it's not clojure repl debugging a clojure program? |
| 22:06 | cemerick | but for the simple case, getting a repl and restart options should be doable, unless the IDEs are going some serious black magic |
| 22:08 | cemerick | rhickey: opendiff is pretty good if you like the side-by-side |
| 22:08 | cemerick | it's a darn good merge tool, actually |
| 22:08 | rhickey | cemerick: as I said, IntelliJ is working for me |
| 22:09 | tomoj | anybody use magit? |
| 22:09 | cemerick | sorry, I get chatty late at night |
| 22:11 | rhickey | :) |
| 22:14 | rhickey | lowlycoder: I'm open to contributions, myself, I don't like debugging |
| 22:15 | rhickey | more flightcaster: http://www.infoq.com/articles/flightcaster-clojure-rails |
| 22:17 | cemerick | hrm, ::foo is :myns/foo in a dosync, but *ns* is always clojure.core in a dosync |
| 22:17 | rhickey | I wonder how InfoQ does its schedule? I did a talk on state and identity at QCon I wish would come out soon |
| 22:18 | rhickey | cemerick: you are reading ::foo in a dosync? |
| 22:18 | tomoj | ,(dosync *ns*) |
| 22:18 | clojurebot | #<Namespace sandbox> |
| 22:19 | cemerick | rhickey: I was actually filtering some keywords based on their namespace, and none of them were matching the name of *ns*. Somehow *ns* is always clojure.core in this particular snippet. |
| 22:19 | cemerick | ^ but yes, the above in a dosync |
| 22:20 | cemerick | ...not that I can replicate this problem in a smaller example. |
| 22:22 | rhickey | wow, Andy Fingerhut's transcription of the Boston Lisp talk is an act of heroism - 3800 lines! |
| 22:25 | lowlycoder | maps/sets having stable orders -- does that mean garbage collection does not change their order? |
| 22:32 | rhickey | lowlycoder: they are immutable |
| 22:33 | lowlycoder | good point |
| 22:33 | lowlycoder | rhickey: how did you support yourself while developing clojure? |
| 22:34 | rhickey | lowlycoder: used up my savings |
| 22:35 | lowlycoder | how does this play with parts of life like ... family & friends? |
| 22:53 | lowlycoder | why is there lef and letfn ? |
| 23:00 | tomoj | letfn is a handy shortcut for letting fns |
| 23:01 | Chouser | more than that. letfn allows local mutually-referential fns |
| 23:02 | tomoj | ooh |
| 23:02 | tomoj | I read "all the names" but that didn't click |
| 23:02 | tomoj | pretty cool |
| 23:04 | Chouser | but it only does fn. 'let' is for other locals. |
| 23:04 | clojurebot | for is not used enough |
| 23:07 | lowlycoder | what'sthe cost of using a trampolie? |
| 23:08 | Chouser | I think the biggest drawback is you have to write the caller and each callee with the knowledge that trampoline is being used. |
| 23:10 | lowlycoder | chapter 6, concurrency; this is a great day |
| 23:13 | cemerick | lowlycoder: and to think I had pegged you as a skeptic ;-) |
| 23:21 | lowlycoder | can refs be built out of atoms? |
| 23:23 | Raynes | (atom x @y)? |
| 23:23 | Raynes | Er, vice versa. |
| 23:23 | Chouser | refs and atoms are two kinds of reference types -- each are used to point to a value |
| 23:23 | Chouser | you wouldn't generally store one in the other, if that's what you're asking. |
| 23:24 | Raynes | (def x (atom @(ref 10))), is what I was trying to say. :< I should sleep more. |
| 23:25 | Chouser | but that's just copying a value out of one and storing it in the other. |
| 23:25 | Chouser | on another level, mixing refs and atoms seems a bit risky, since to the ref/transaction world, changes to atoms would be a kind of side-effect. |
| 23:26 | Raynes | Chouser: You could interpret what he said that way. He needs to clarify. |
| 23:26 | lowlycoder | i will clarify |
| 23:26 | lowlycoder | if I gave you clojure without refs & stms; and only atoms |
| 23:27 | lowlycoder | can you build stms & refs on top of that single primitive? |
| 23:27 | lowlycoder | like how locks can be built on top of only "compare & swap" |
| 23:32 | lowlycoder | if a dosync transaction block fails, do the java calls inside of it get rolled back too? (i'm guessing not, since I can do stuff like send packets over the network / delete files) ... if not, how do i know which pieces of java code got executed? |
| 23:36 | cemerick | lowlycoder: nothing gets rolled back except for the state of whatever refs have been touched by the transaction |
| 23:37 | lowlycoder | cemerick: ahh, nice; thanks, this is _really_ clear :-) |
| 23:37 | lowlycoder | so basically, clojure stms only act in clojure land, and doesn't care at all about the rest of the world |
| 23:37 | cemerick | so, if you've got anything side-effecting in your transaction, you're going to get burned eventually |
| 23:37 | lowlycoder | so even if I called a clojure wrapper for file i/o or network, i lose |
| 23:37 | cemerick | yes |
| 23:38 | cemerick | that is, unless you're very clear about what the semantics of the call are. |
| 23:38 | cemerick | e.g. file reads will generally be OK |
| 23:38 | lowlycoder | bank transactions may be bad ideas though? |
| 23:39 | cemerick | bank transactions are a great thing to do, as long as you're not writing out the result within the transaction |
| 23:40 | cemerick | e.g. if you had the bank transaction history in a persistent data structure, in a ref, applying changes to it in a concurrent environment would always give you a consistent picture before and after each clojure transaction |
| 23:40 | drewr | Chouser: destructuring isn't working with the new doseq |
| 23:41 | drewr | e.g., (doseq [[k v] {:foo 1 :bar 2}] (prn [k v])) |
| 23:42 | lowlycoder | cemerick: got it; thanks |
| 23:47 | drewr | Chouser: I take that back |
| 23:48 | drewr | I was having classpath issues while updating |
| 23:52 | Chouser | drewr: whew. thanks. |
| 23:55 | drewr | sorry to scare you |
| 23:55 | drewr | the exception I was getting was strange though; not sure why it would have happened with either version of the code |