On Wed, Feb 18, 2009 at 12:35 AM, Rob <[email protected]> wrote:
>
> I'm wondering if I found a bug. I have the latest source from svn
> (r1291).
>
> user=> (bean 1)
> java.lang.IllegalArgumentException: Wrong number of args passed to:
> core$bean--5161$fn--5179$thisfn
You sure did. The conversion to lazy-seq code appears to introduce a
paren typo and an incorrect nil pun. Patch attached.
Rich, I think it'd be pretty useful to have as you mentioned in IRC a
variant of & destructuring that provided an unforced lazy-seq. It
seems pretty common to want, in the body of a lazy-seq, a destructured
'first' but an unforced 'rest'. This is already the third or fourth
time I've wanted to be able to do something like:
(fn thisfn [plseq]
(lazy-seq
(when-let [[pkey &rest etc] plseq]
(cons (new clojure.lang.MapEntry pkey (v pkey))
(thisfn etc)))))
--Chouser
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---
commit 539242b543c99bf430c5b821f9c4a0ca769a8a26
Author: Chouser <[email protected]>
Date: Wed Feb 18 10:57:25 2009 -0500
Fix bean lazy-seq
diff --git a/trunk/src/clj/clojure/core_proxy.clj b/trunk/src/clj/clojure/core_proxy.clj
index 2b2d01d..120ffbf 100644
--- a/trunk/src/clj/clojure/core_proxy.clj
+++ b/trunk/src/clj/clojure/core_proxy.clj
@@ -340,11 +340,11 @@
(count [] (count pmap))
(assoc [k v] (assoc (snapshot) k v))
(without [k] (dissoc (snapshot) k))
- (seq [] ((fn thisfn [pseq]
+ (seq [] ((fn thisfn [plseq]
(lazy-seq
- (when pseq
+ (when-let [pseq (seq plseq)]
(cons (new clojure.lang.MapEntry (first pseq) (v (first pseq)))
- (thisfn (rest pseq))))) (keys pmap)))))))
+ (thisfn (rest pseq)))))) (keys pmap))))))