2009-01-11
| 00:38 | hiredman | 1d8 |
| 00:39 | mfredrickson | hiredman: 6 |
| 00:39 | mfredrickson | you slay the elf |
| 00:39 | hiredman | 1d8 |
| 00:39 | clojurebot | 6 |
| 00:40 | mfredrickson | jinks! |
| 00:51 | arohner | 1d8 |
| 00:51 | clojurebot | 3 |
| 00:54 | hiredman | man, clojurebot totally needs to do markov chains generated from channel logs |
| 01:34 | vogelrn | 1d8 |
| 01:34 | clojurebot | 8 |
| 01:34 | vogelrn | 1d10 |
| 01:34 | clojurebot | 6 |
| 01:34 | vogelrn | 1d1000000000000000000000000000 |
| 01:34 | vogelrn | hmmmm |
| 01:34 | vogelrn | unfortunate :P |
| 01:38 | hiredman | hmm |
| 01:39 | vogelrn | I was expecting intmax |
| 01:39 | vogelrn | not silence |
| 02:44 | hiredman | is there a prefered mimtype for clj files? |
| 02:50 | hiredman | application/x-clojure it is |
| 04:38 | rryan | Hi -- does clojure have call/cc? |
| 04:39 | hiredman | nope |
| 04:40 | rryan | alright.. google didn't turn up anything useful so I assumed not. Any workaround? Any reason why? |
| 04:44 | kotarak | rryan: }:-) Why should it have call/cc? |
| 04:45 | rryan | :) |
| 04:45 | kotarak | rryan: I suspect that this is not easy to implement, things Clojure allows easy calls to Java. |
| 04:45 | kotarak | s/things/since/ |
| 04:45 | rryan | yea -- the more I think about it, it sounds hard |
| 04:46 | rryan | For fun, I was going to rewrite CONSPIRE (a scheme time sharing system) in clojure. |
| 04:46 | kotarak | You'll need either you own call stack or other means to implement it, which makes interop hard, or you have to do bad things like copying stack in C and such.... (Which I don't even know whether it's possible in Java or not) |
| 04:46 | rryan | and it relies pretty heavily on call/cc |
| 04:49 | kotarak | that's not the right thing I guess. ;) :conspire: a conspiracy theory generator, for the conspiracy theorist in a hurry |
| 04:49 | hiredman | rhickey has said on the google group that "Clojure is not going to provide continuations |
| 04:49 | hiredman | any time soon" |
| 04:50 | rryan | gotcha |
| 04:50 | hiredman | but I don't see him giving a reason |
| 04:50 | hiredman | but I would suspect that kotarak is right |
| 06:17 | asbjxrn | Is there a way of getting "unchecked-add" behaviour for floats? |
| 06:19 | Lau_of_DK | Good afternoon everyone =) |
| 06:19 | kotarak | Hi Lau. |
| 06:43 | asbjxrn | Tip: (+ (float 0.1) (float 0.1) (float 0.1)) is about 9 times slower than (+ (float 0.1) (+ (float 0.1) (float 0.1))) |
| 06:57 | Chousuke | the last float probably gets reboxed or something as IIRC + uses reduce for more than 2 arguments. |
| 08:34 | rfgpfeiffer | '#=(symbol "test symbol") |
| 08:35 | rfgpfeiffer | i think i found a bug |
| 08:35 | kotarak | symbol does not validate the string, in case that's what you want to say. |
| 08:36 | rfgpfeiffer | #=(keyword "key word") |
| 08:36 | rfgpfeiffer | this works as expexted |
| 08:40 | rfgpfeiffer | symbol just creates a symbol with the name "test symbol", the problem is somewhere else |
| 08:43 | rfgpfeiffer | (symbol "test symbol") works fine also |
| 08:44 | kotarak | It's somehow the combination of ' and #=. |
| 08:44 | Chouser | #= isn't meant to be used directly |
| 08:45 | rfgpfeiffer | it seems like symbols are parsed again after read time |
| 08:48 | Chousuke | calling symbol with arguments that would result in unreadable symbols is unsupported anyway, as far as I know |
| 08:50 | kotarak | I think it's on the issue list to implement validators. |
| 08:50 | Chousuke | yeah |
| 08:53 | Chousuke | I figured out the following: symbols must not contain whitespace, must not start with numbers , # or /; must not end with / (exception: just '/ is allowed), can't contain ', or the comma (since it's whitespace). |
| 08:54 | Chousuke | anything missing there? :/ |
| 08:54 | kotarak | maybe ()? What does the reader do here: foo(+ 1 2) |
| 08:54 | Chousuke | symbols containing / among other valid characters are allowed but cause problems. |
| 08:54 | Chousuke | ah, true |
| 08:55 | Chousuke | also must not start with : since that's for keywords |
| 08:56 | Chousuke | keywords have similar rules but are a bit less restricted because they always start with :, so the "must not start with" rules can be ignored |
| 08:57 | rfgpfeiffer | what about ^, @,%, and ~? |
| 09:01 | rhickey | http:/clojure.org/reader says "Symbols begin with a non-numeric character and can contain alphanumeric characters and *, +, !, -, _, and ? " |
| 09:01 | rhickey | http://clojure.org/reader |
| 09:04 | rhickey | the problem with '#=(symbol "test symbol") is that it tries to embed the symbol with the name "test symbol" as a constant in the compiled code. Constants are stored readably, and symbols using just their print representation, so in restoring the constant one object is read in from the string "test symbol" is read, yielding the symbol test |
| 09:05 | rfgpfeiffer | okay |
| 09:05 | Chousuke | rhickey: can you clarify if / should be allowed in symbol names other than '/? Allowing it seems to cause problems. :/ |
| 09:08 | rfgpfeiffer | perhaps (.toString (symbol "this symbol")) should return |this symbol| |
| 09:08 | Chousuke | (namespace 'a/a/b) returns a/a but a namespace like that won't work; even if you create it and def the b var, trying to evaluate a/a/b says that the namespace a/a does not exist |
| 09:22 | Lau_of_DK | (doc interleave) |
| 09:22 | clojurebot | Returns a lazy seq of the first item in each coll, then the second etc.; arglists ([& colls]) |
| 10:21 | asbjxrn | So I've spent a good chunk of the weekend translating http://www.dgp.toronto.edu/people/stam/reality/Research/pdf/GDC03.pdf to Clojure. (Fluid dynamics for games.) |
| 10:21 | asbjxrn | And I only get 1 frame/sec for a 100x100 grid... |
| 10:22 | Chousuke | :/ |
| 10:23 | asbjxrn | Hardly convincing smoke effects at that pace.. (Very small movements from frame to frame as well.) |
| 10:24 | Chousuke | have you gotten rid of all reflection in your app already? |
| 10:24 | asbjxrn | Anyone feel like giving it a shot? |
| 10:25 | Chousuke | but that kind of stuff looks like it might be easier to use java to write the parts that need speed and then tie it all together with clojure. |
| 10:25 | asbjxrn | Not all. I'm not sure hot to get rid of the last parts. Tried using YourKit to figure out where the time went, but... |
| 10:27 | asbjxrn | I agree. Not what I would expect Clojure to excel at, but I would have hoped it would be reasonably fast. |
| 10:27 | asbjxrn | I'm also not using idiomatic clojure, I guess. I'm using java arrays for the data. |
| 10:29 | Chousuke | do you have the code on github or something? |
| 10:29 | karmazilla | idea: what if PersistentStructMap$Def implemented IFn and calling it would yield an instance of that struct with the parsed arguments as values? |
| 10:31 | Chousuke | karmazilla: you mean (defstruct foo ...) and then (foo ...) -> structmap? |
| 10:31 | asbjxrn | It's real ugly, do they have anonymous accounts? :) |
| 10:32 | Chousuke | asbjxrn: gist.github.com |
| 10:32 | karmazilla | Chousuke: yes |
| 10:32 | Chousuke | asbjxrn: the best pastebin I know :D |
| 10:32 | Chousuke | asbjxrn: because even the pastes are git repos |
| 10:33 | Chousuke | you can fork them and import their history into a real git project if the gist ends up growing into a real app |
| 10:36 | asbjxrn | It's a bit too late here now. I'm off to bed. I'll check it out tomorrow. |
| 10:40 | bOR_ | how would you solve this? I've a regex matcher, and when I call (.find mymatcher) it will return true until it can no longer find any matches in the string, and then it starts returning false. |
| 10:40 | bOR_ | I want the number of trues. |
| 10:40 | bOR_ | take-while pred coll seemed nice, but warns me not to use a pred that has side-effects. |
| 10:40 | bOR_ | and I toyed a bit with trying to turn (.find mymatcher) into a lazy-cons |
| 10:41 | Chousuke | isn't there a re function that returns a seq of matches |
| 10:41 | Chousuke | call count on that. |
| 10:41 | bOR_ | its not the standard java regex engine. |
| 10:41 | bOR_ | brics automaton. |
| 10:42 | bOR_ | (unless I misunderstood your answer) |
| 10:44 | Chousuke | ah. hmm |
| 10:44 | bOR_ | ah. |
| 10:44 | bOR_ | got the lazy-cons to work |
| 10:44 | bOR_ | that seems to be it |
| 10:44 | bOR_ | (defn lazy-find |
| 10:45 | bOR_ | [matcher] |
| 10:45 | bOR_ | (lazy-cons (.find match) (lazy-find matcher))) |
| 10:45 | bOR_ | . |
| 10:45 | bOR_ | a take 10 on that works nicely |
| 10:45 | bOR_ | so now I might be able to tag on a (count (take-while true (lazy-find match))) |
| 10:46 | bOR_ | victory :) |
| 10:46 | achim_p | bOR_: you might be able to use repeatedly (count (take-while identity (repeatedly #(.find ...)))) - didn't test that though |
| 10:47 | bOR_ | (take-while #(= true %) (lazy-find match)) did work |
| 10:47 | bOR_ | but violates the 'pred cant have side-effects rule though' |
| 10:47 | bOR_ | not sure how much I should worry about that. |
| 10:47 | bOR_ | I'll look at repeatedly. |
| 10:48 | achim_p | not sure about side-effects and take-while either, but repeatedly does allow them explicitly |
| 10:48 | bOR_ | (take 10 (repeatedly (fn [] (.find match)))) |
| 10:48 | bOR_ | noticed. |
| 10:48 | bOR_ | that works. |
| 10:49 | bOR_ | thanks! |
| 10:49 | bOR_ | getting tired. not sure if it works :) |
| 10:49 | bOR_ | but thanks for pointing out repeatedly. |
| 10:50 | asbjxrn | http://gist.github.com/45724 <- Ugly, slow, broken code. |
| 10:52 | achim_p | bOR_: you're welcome. just looked up the code for repeatedly - looks like a generalized version of lazy-find :) |
| 10:53 | bOR_ | gracias. |
| 10:53 | bOR_ | man. I'll summarize the mess I went through on the forum one of these days :). |
| 10:53 | bOR_ | but it seems all is working out eventually. |
| 10:54 | bOR_ | (was working on a bottleneck in a simulation model in clojure) |
| 10:58 | achim_p | bOR_: thanks for pointing me to brics automaton, i've been looking for a regex engine with complement support! |
| 10:59 | bOR_ | nice :). |
| 11:00 | bOR_ | what does complement mean in regard to regex engines? |
| 11:00 | bOR_ | saw that function, couldn't figure out what it did from the description? |
| 11:01 | bOR_ | I am using the union function though, which can merge my regexs before I let it getfinitestrings |
| 11:01 | bOR_ | (whenever I can't calculate getfinitestrings in an easier way) |
| 11:02 | achim_p | non-occurence of patterns - most regex engines can't express that |
| 11:05 | bOR_ | ah. cool, so basically the opposite of the sequence space that can be presented. |
| 11:05 | bOR_ | hmm. opposite.. better is to say the rest of the sequence space. |
| 11:11 | achim_p | i knew their mona tool a little and that it was good in minimizing state machines, but wasn't aware there was a java regex implementation with that built in. pretty cool |
| 12:43 | jacky | Hi - I have a question about the threadlocal semantics of vars |
| 12:43 | jacky | (def k 10) |
| 12:44 | jacky | now, k is bound to the value 10. |
| 12:44 | jacky | (.start (Thread. (fn [] (def k 5)(println k)))) -- this should bound k to the value of 5 only within the thread. |
| 12:44 | hiredman | no |
| 12:44 | hiredman | def is global |
| 12:44 | jacky | But when I check for the value of k in repl, it shows 5 |
| 12:44 | kotarak | (doc binding) |
| 12:44 | clojurebot | binding => var-symbol init-expr Creates new bindings for the (already-existing) vars, with the supplied initial values, executes the exprs in an implicit do, then re-establishes the bindings that existed before.; arglists ([bindings & body]) |
| 12:45 | jacky | I see.. The threadlocal semantics apply on if you use binding? |
| 12:45 | kotarak | And there is with-local-vars, but I never used that one up to now. |
| 12:46 | hiredman | (doc with-local-vars) |
| 12:46 | clojurebot | varbinding=> symbol init-expr Executes the exprs in a context in which the symbols are bound to vars with per-thread bindings to the init-exprs. The symbols refer to the var objects themselves, and must be accessed with var-get and var-set; arglists ([name-vals-vec & body]) |
| 12:48 | jacky | so, to create a threadlocal binding, we should use binding |
| 12:48 | kotarak | binding worked very well for me up to now. |
| 15:05 | dreish | ,(#(identical? (rest %) (rest %)) [1 2 3]) |
| 15:05 | clojurebot | false |
| 15:10 | hiredman | ,(#(identical? (rest %) (rest %)) (seq [1 2 3])) |
| 15:10 | hiredman | hmmm |
| 15:11 | hiredman | ,(#(identical? (rest %) (rest %)) (seq [1 2 3])) |
| 15:11 | clojurebot | false |
| 15:13 | eyeris | Using Maven2 Jetty plugin, where do I put my clojureql.jar file? I've tried specifying -Djetty.class.path="/full/path/to/clojureql.jar" but I still get a classnotfound exception. |
| 15:14 | eyeris | (this is for use with Webjure, btw) |
| 15:38 | Chouser | ,(#(identical? (rest %) (rest %)) (map identity [1 2 3])) |
| 15:38 | clojurebot | true |
| 15:42 | danlarkin | So in an object-oriented language I would be saying like, you have to pass me an object here that has at least one of these 4 methods. Would a reasonable analog in clojure be saying you have to pass me a namespace that has one of these 4 functions named in a specific way? |
| 15:43 | danlarkin | or should I use gen-interface and make them use proxy |
| 15:44 | hiredman | pass me a hash that has at least one of these four keys |
| 15:46 | hoeck | danlarkin: or pass a function that does one of these 4 things |
| 15:46 | hiredman | hoeck: but how would you know which of the four the function does? |
| 15:46 | danlarkin | hoeck: well the 4 different functions get executed at different times... like pre_ and post_ hooks etc |
| 15:47 | Chouser | hash-map of functions? |
| 15:47 | hiredman | ^- |
| 15:47 | danlarkin | yeah, the hash of functions might be a good way |
| 15:48 | hiredman | and you can do all that fun hash destructuring |
| 15:48 | Chouser | that's essentially what irefs do now. (agent foo :validator fn) |
| 15:49 | Chouser | I think passing a namespace would be pretty rough on both producer and consumer |
| 15:49 | Chouser | clojure.zip uses a data object with several functions attached as metadata |
| 15:53 | danlarkin | yeah I think a good way to do this will be have them pass in a hashmap of functions, thanks hiredman and Chouser |
| 15:56 | lsantha | hello |
| 15:57 | lsantha | I'm testing clojure on an experimenta java platform |
| 15:58 | lsantha | and I noticed that the bytecode generated by clojure contains dead code which makes it fail in this env |
| 15:59 | lsantha | is it possible to fix this problem? Where shold I post a bugreport? |
| 16:03 | Chouser | lsantha: post it to the google group |
| 16:04 | lsantha | ok, thanks |
| 16:04 | cpfr | hey how easy is it to use Clojure for mobile phone apps? |
| 16:04 | cpfr | since i kinda hate coding in java |
| 16:05 | hiredman | s know |
| 16:05 | hiredman | er |
| 16:06 | hiredman | be the first to do it, and let us know |
| 16:07 | Chouser | cpfr: it's now working for applets and android, so you have a fighting chance at getting j2me working. |
| 16:07 | cpfr | Chouser, awesome! |
| 16:08 | cpfr | hiredman, i barely know how to do it with java, but will do |
| 16:40 | lsantha | Chouser: I postgred it but not showing up, is waiting in a moderation queue? |
| 16:41 | lsantha | * I posted it ... |
| 16:41 | Chouser | lsantha: yeah, if it's your first post, it'll be held (to prevent spam) |
| 16:41 | lsantha | ok |
| 16:41 | Chouser | which may work to your advantage, because it means rhickey will have to see it. |
| 16:41 | Chouser | :-) |
| 16:42 | lsantha | :-) |
| 16:43 | lsantha | I also tried a sort of a fix which fixed one part of the problem |
| 16:43 | lsantha | maybe it's not so hard to fix it for the authors |
| 16:44 | lsantha | and for mobile platforms such things maybe be important even if for Java SE they go unnoticed |
| 16:44 | rhickey | lsantha: what's JNode? |
| 16:44 | lsantha | it's an experimental OS written in Java |
| 16:44 | lsantha | http://www.jnode.org/ |
| 16:46 | rhickey | I think it should be tolerant of dead bytecode |
| 16:46 | lsantha | I think you are right |
| 16:47 | rhickey | Clojure definitely relies on the VMs to do last-mile optimization |
| 16:48 | lsantha | that's one place for fixing the bug, but also posted it to you just in case you are interested |
| 16:50 | rhickey | lsantha: thanks. If you want, you can create an issue for it so it won't get lost, bit not a top priority right now |
| 17:06 | Lau_of_DK | How do I debug a "No matching clause" ? |
| 17:07 | karmazilla | Chouser: textjure future? |
| 17:07 | Chouser | Lau_of_DK: that's from a condp? |
| 17:07 | Lau_of_DK | Chouser: No, its from my run macro, or somewhere after it |
| 17:09 | Chouser | Lau_of_DK: I think condp is the only form that throws that exception. |
| 17:09 | Lau_of_DK | Then you've answered my question, thanks CHous' :) |
| 17:10 | Chouser | karmazilla: hopefully textjure has more future than it does past. |
| 17:11 | rhickey | poll: Clojure supports CL-style nil-punning, how much would you miss it if it didn't? |
| 17:11 | Chouser | like (cons :foo nil) ? |
| 17:11 | Chouser | and we'd have to say (cons :foo ()) instead? |
| 17:11 | rhickey | Chouser: no, like (if (rest x)...), using seqs fns as predicates etc |
| 17:12 | Lau_of_DK | rhickey: Counter-question: What would I gain if I lost nil-punning? |
| 17:12 | karmazilla | Chouser: hehe, that's a way to put it :) I fiddled with it a bit and sort of got it to save the one file you opened with it |
| 17:12 | rhickey | Lau_of_DK: one poll at a time :) |
| 17:12 | Lau_of_DK | hehe, alright |
| 17:12 | danlarkin | rhickey: so (rest [1]) would be what |
| 17:12 | Chouser | so we'd have to say (if (series? (rest x)) ...) instead? |
| 17:12 | rhickey | danlarkin: opaque, seq would work on it |
| 17:12 | Lau_of_DK | Then I cant answer due to lack of polls, I think I'd miss it |
| 17:13 | rhickey | Chouser: (if (seq (rest x)) ...) |
| 17:14 | hiredman | :( |
| 17:14 | rhickey | danlarkin: (seq (rest [1])) -> nil |
| 17:14 | Chouser | I suppose (rest x) would then evaluate to something true in cases where it currently is nil? |
| 17:14 | rhickey | Chouser: yep |
| 17:15 | Lau_of_DK | Now I know I'd miss it |
| 17:15 | hiredman | :( |
| 17:15 | danlarkin | yeah I'm -1 |
| 17:15 | Chouser | I think that'd break a lot of my code. |
| 17:15 | rhickey | hiredman: no voting twice :) |
| 17:16 | hiredman | running a markov chain deal on the irc logs a channel where people paste code does not get you english output |
| 17:16 | Chousuke | rhickey: so what would this change enable? |
| 17:16 | rhickey | Chouser: one possibility, for rest, if for rest to be defined as (seq (tail x)) where tail is the new rest |
| 17:16 | Chouser | I suppose I could get used to it. "Public" api functions already have to use (seq x) generally to allow empty containers to work right... |
| 17:16 | rhickey | Chouser: exactly, mush code already does (seq coll) |
| 17:17 | rhickey | much |
| 17:17 | rhickey | There are basically two ways to support streams |
| 17:18 | rhickey | first is bifurcation, a second set of all seq fns for streams, both can be generated from a single definition |
| 17:18 | rhickey | since: (def map (comp seq map-stream)) |
| 17:19 | rhickey | second method is change to seq semantics, rest would return a logical coll, not an ISeq/nil |
| 17:19 | rhickey | seq still returns ISeq/nil |
| 17:19 | rhickey | first is the same |
| 17:20 | rhickey | then seq/stream fns can return either seqs/streams or other things |
| 17:20 | rhickey | one set of fns |
| 17:20 | rhickey | the new seq model can support fully-lazy seqs, not possible now |
| 17:20 | Chouser | other functions might need 'seq' around them too, though, right? filter, map, etc. if you want to test for empty result. |
| 17:20 | rhickey | since Delay could implement Seqable, you could write seq fns returning delays |
| 17:21 | rhickey | Chouser: yep |
| 17:22 | Chouser | especially without having a sense of what benefit I'd get from interacting directly with streams instead of seqs, the first way sounds better. |
| 17:22 | Chouser | my existing code works, new code doesn't need more (seq ...) sprinkled everywhere, and I can use map-stream if I know I want it. |
| 17:22 | rhickey | stream versions of fns likely to be 2-4x faster |
| 17:23 | Lau_of_DK | hmmm :) |
| 17:23 | rhickey | if everyone chooses the stream verions all the time they'll have seq calls when needed anyway |
| 17:23 | Lau_of_DK | And there's no way to obtain that speed increase with this re-design ? |
| 17:23 | Chouser | clojure's already too fast for me. |
| 17:23 | rhickey | heh |
| 17:24 | rhickey | Lau_of_DK: speed is due to essential difference between seqs and streams |
| 17:24 | rhickey | this is just an api thing |
| 17:24 | Lau_of_DK | oh... I think thats a very heavy argument |
| 17:24 | rhickey | IO likely to be exposed only as streams |
| 17:24 | rhickey | ditto queues |
| 17:25 | Lau_of_DK | I want to change my vote |
| 17:25 | rhickey | bifurcation: +compatible -no-full-lazy-seqs -two-verions-of-every-fn |
| 17:26 | rhickey | unified model: -breaking +fully-lazy-seqs +more-elegant-api -no-punning |
| 17:26 | danlarkin | two versions of every fn should count as two minuses |
| 17:27 | danlarkin | but so should no punning, gah! |
| 17:27 | rhickey | danlarkin: there will be (defstream map ...) generating map and map* |
| 17:27 | Chouser | it's more than just compatible, it's also more succinct for any seq users, isn't it? |
| 17:27 | Chouser | though rather less succinct for stream users. |
| 17:28 | Chouser | "it" being bifurcation in both the above |
| 17:28 | karmazilla | could an ILogical interface make "empty seqs" become logical false, or is that going too far for too little? |
| 17:28 | Chouser | empty streams |
| 17:28 | rhickey | karmazilla: its not the interface, it's the eagerness of determining emptiness |
| 17:29 | Chouser | hmmm. |
| 17:29 | rhickey | nil punning is fundamentally in conflict with full laziness, and other indirections |
| 17:29 | karmazilla | ah, I see now |
| 17:29 | rhickey | I've come to conclude |
| 17:29 | rhickey | much to my chagrin |
| 17:29 | Chouser | was my post incorrect that dug into exactly how existing seqs are already fully lazy? |
| 17:30 | rhickey | Chouser: which one? |
| 17:31 | rhickey | the way I've implemented streams, you can chain them and then just seq the end, yielding great perf + easy consumption, caching etc |
| 17:31 | rhickey | there is a one-time threadsafe transition of a stream into a seq |
| 17:32 | rhickey | note I like nil punning quite a bit, as I did in CL, why I made it work in Clojure |
| 17:34 | rhickey | and have pushed back against the even/odd laziness arguments, arguing for lazy-except-for-first being a reasonable compromise |
| 17:34 | Chouser | http://groups.google.com/group/clojure/msg/cfa89c8265a33f2c |
| 17:34 | rhickey | but it is interesting that the same thing is needed for both full laziness and stream/seq transparency |
| 17:37 | rhickey | Chouser: right, so only first and rest can be lazy, but not the work needed to determine if there is a first, which often needs to get the first of some other seq |
| 17:37 | Chouser | basically, 'first' being lazy allows you to split the determination of "if there's more" from "what the next value" |
| 17:43 | rhickey | basically rest returning nil means at least some work (that required to determine if there is any more) cannot be lazy |
| 17:44 | danlarkin | that makes sense, makes me sad though :'( |
| 17:45 | rhickey | as Chouser's post indicated, it i not really a problem in practice very often. Certainly this change would not be justified by full-laziness only |
| 17:47 | rhickey | if rest returned something opaque, it could be a Delay |
| 17:47 | Chouser | I'm still not quite following. The only work 'rest' ever has to do is determine if there's more. To find out what that more is, the also-lazy 'first' can then be computed. How much more split up can the work be? |
| 17:49 | rhickey | Chouser: (defn foo [] ... (rest x)) |
| 17:49 | rhickey | if the consumer never uses it, this does too much work |
| 17:50 | rhickey | it's more where the split lies, but there are three distinct things: the seq itself, the first value, the rest value |
| 17:50 | rhickey | right now the seq itself is always eager |
| 17:50 | rhickey | if you could delay the seq, then most likely you would delay seq+first together, and rest |
| 17:50 | rhickey | still two delays, but at different points |
| 17:52 | rhickey | most seq fns would look like (defn aseqfn [] (delay #( ... (lazy-rest-only-cons x (cal-rest))))) |
| 17:56 | rhickey | a simple example is drop, must do most of its work in all cases |
| 17:57 | rhickey | and the work of producing the dropped items of the seq it's manipulating |
| 17:57 | rhickey | not fully lazy |
| 18:06 | Chouser | you'd still force the 'first's in order to cache, even when just dropping, as LazyCons does now? |
| 18:07 | rhickey | Chouser: yes, seqs are still persistent |
| 18:10 | rhickey | the difference is drop would do no work until you called seq/first on what it returned |
| 18:24 | Chouser | ok, the drop example helps me, thanks. |
| 18:24 | Chouser | The cutover pain is going to be real, but I'm in favor of removing the wart that nil punning requires. |
| 18:27 | rhickey | Chouser: thanks for the considered feedback |
| 18:30 | rhickey | I still haven't made a decision, one thing I'll be doing is an audit of the changes required by Clojure itself - I use a good bit of nil punning |
| 18:30 | rhickey | also, there is a secondary issue regarding code that relies on the type of the return values of seq fns, like the compiler! |
| 19:22 | rhickey | hmm... that conversation seemed to scare everyone off :) |
| 19:22 | Chousuke | heh |
| 19:24 | Chousuke | rhickey: while you're still here: http://code.google.com/p/clojure/issues/detail?id=41 |
| 19:26 | rhickey | ok |
| 19:56 | knapr | how can I interact with C++ code from Clojure? |
| 19:57 | hiredman | jni? |
| 19:57 | knapr | im writing my own Matrix-lib for a huge-ass sparse matrix and I want to write the highlevel code in lisp not C++. |
| 19:57 | knapr | ok |
| 19:57 | Chousuke | hm |
| 19:57 | knapr | and how is the overhead? is it worth it? |
| 19:58 | knapr | or it will then be like i wrote it in Java? |
| 19:58 | Chousuke | do you need to write your own lib? |
| 19:58 | knapr | maybe I should use python instead? |
| 19:58 | Chousuke | I mean, there are java matrix libraries. |
| 19:58 | knapr | maybe I cant use the JVM |
| 19:58 | knapr | actually |
| 19:58 | knapr | i need special-purpose superpacked |
| 19:59 | Chousuke | but no, the overhead of JNI shouldn't be much more than what overhead generally is for such things. |
| 19:59 | Chousuke | I don't know for sure, but I've never heard of anyone complaining about JNI overhead :/ |
| 20:04 | knapr | = java native interface? |
| 20:06 | luxanctus | I hear crickets chirping. |
| 20:06 | luxanctus | Was it me? |
| 20:06 | luxanctus | Welcome back. |
| 20:09 | luxanctus | Bye. |
| 21:37 | durka | is there any way |
| 21:37 | durka | whoops |
| 21:37 | durka | is there any way to have clojure attempt to eval some code without actually doing anything |
| 21:38 | durka | in other words, i want the exceptions that would be thrown during load |
| 21:38 | danlarkin | (doc read) |
| 21:38 | clojurebot | Reads the next object from stream, which must be an instance of java.io.PushbackReader or some derivee. stream defaults to the current value of *in* .; arglists ([] [stream] [stream eof-error? eof-value] [stream eof-error? eof-value recursive?]) |
| 21:41 | durka | but does that resolve symbols |
| 21:41 | danlarkin | yeah |
| 21:41 | danlarkin | there's a request for a non resolving reader, I'm pretty sure? |
| 21:42 | danlarkin | not sure what the priority is |
| 21:43 | Chouser | I don't think 'read' resolves symbols. |
| 21:44 | Chouser | ,(namespace (read-string "filter")) |
| 21:44 | clojurebot | nil |
| 21:46 | durka | ,(read-string "(WildlyInvalidCode.)") |
| 21:46 | clojurebot | (WildlyInvalidCode.) |
| 21:47 | durka | but i would want an exception there |
| 21:47 | Chouser | ,(read-string "(invalid(syntax") |
| 21:47 | clojurebot | java.lang.RuntimeException: java.lang.Exception: EOF while reading |
| 21:49 | durka | i'm reading valid syntax but looking for unresolvable symbols |
| 21:51 | Chouser | (clojure.lang.Compiler/analyze clojure.lang.Compiler$C/STATEMENT (read-string "filter")) |
| 21:54 | Chouser | ,(clojure.lang.Compiler/analyze clojure.lang.Compiler$C/STATEMENT (read-string "filter")) |
| 21:54 | clojurebot | #<VarExpr clojure.lang.Compiler$VarExpr@510dc2> |
| 21:55 | Chouser | ,(clojure.lang.Compiler/analyze clojure.lang.Compiler$C/STATEMENT (read-string "(java.util.Date.)")) |
| 21:55 | clojurebot | #<NewExpr clojure.lang.Compiler$NewExpr@1033450> |
| 21:55 | Chouser | ,(clojure.lang.Compiler/analyze clojure.lang.Compiler$C/STATEMENT (read-string "(java.util.Date. 55)")) |
| 21:55 | clojurebot | #<NewExpr clojure.lang.Compiler$NewExpr@5b6d00> |
| 21:56 | lisppaste8 | durka pasted "looks like we have a winner" at http://paste.lisp.org/display/73458 |
| 21:59 | Chouser | I don't know how stable that API will be, but ClojureScript uses it, so you've got a fighting chance. |
| 22:04 | durka | cool |
| 22:04 | durka | thanks Chouser |
| 22:06 | Chouser | note that #=() expressions are evaluated. I haven't found any way that those are dangerous, but I'm not completely sure. |
| 22:09 | Chouser | oh, scratch that. #=(java.lang.System/exit 0) does what it does. |
| 22:11 | Chouser | clojurebot: feeling lucky? |
| 22:11 | clojurebot | I don't understand. |
| 22:11 | Chouser | ,#=(java.lang.System/exit 0) |
| 22:11 | Chouser | clojurebot: still here? |
| 22:11 | clojurebot | It's greek to me. |
| 22:12 | Chouser | hm! |
| 22:13 | durka | evaluated but still subject to the JVM security policies, yes? |
| 22:14 | Chouser | I would assume so. |
| 22:14 | Chouser | oh, you mean why clojurebot didn't kick it. yes, I'm sur eyou're right. |
| 22:19 | arohner | is the command line behavior of clojure.lang.Repl / clojure.lang.Main documented anywhere? |
| 22:19 | arohner | clojure.org is empty on that page |
| 22:20 | mmcgrana | (doc clojure.main/main) |
| 22:20 | clojurebot | Pardon? |
| 22:21 | mmcgrana | well yeah chech out the docs for clojure.main/main, either at the repl or in the main.clj source file |
| 22:21 | arohner | mmcgrana: thanks |
| 22:21 | mmcgrana | np |
| 23:34 | danlei | hi! i've got a problem running slime, everything is up to date, i haven't changed my configuration (which worked), but i'm getting "java.lang.NoClassDefFoundError: clojure/main" when i try to start slime. my classpath seems to be set correctly in .emacs though ... any ideas? |
| 23:35 | danlei | (if my whole configuration would help, i'll paste it at lisppaste) |
| 23:36 | durka | are you sure clojure is up to date? |
| 23:36 | danlei | well, i ran svn up a few minutes ago and mvn installed it |
| 23:36 | danlei | so ... yes |
| 23:37 | danlei | r1162 |
| 23:38 | durka | aha |
| 23:38 | danlei | running via command line works fine |
| 23:38 | durka | are you using the google code repository |
| 23:38 | durka | current revision is 1207 |
| 23:38 | danlei | no, sourceforge |
| 23:38 | danlei | did that change? |
| 23:38 | durka | that is abandoned |
| 23:38 | durka | yes |
| 23:38 | danlei | oh |
| 23:38 | danlei | thank you! |
| 23:38 | durka | http://code.google.com/p/clojure/ |
| 23:39 | danlei | thanks |