adambrewster <adambrews...@gmail.com> writes:

> I've come across what appears to be a bug in the implementation of
> seque.  Maybe I'm using it incorrectly and this isn't supposed to work
> at all, but
>
> Clojure 1.4.0
> user=> (range 10) ;this works
> (0 1 2 3 4 5 6 7 8 9)
> user=> (seque 3 (range 10)) ;this works
> (0 1 2 3 4 5 6 7 8 9)
> user=> (seque 3 (seque 3 (range 10)))
>
> On the last line, the process hangs.

Confirmed.  When I hit ^C then, I get

  IllegalMonitorStateException \
    java.util.concurrent.locks.ReentrantLock$Sync.tryRelease \
    (ReentrantLock.java:155)

> Am I doing something silly, or is this a bug?

The docs state

    Note that reading from a seque can block if the reader gets ahead of
    the producer.

That seems to be the case in your example.  A solution is to realize the
inner seque before passing it to the other seque.

    (seque 3 (doall (seque 3 (range 10))))

But then, there's no benefit for the inner seque.  Building the lazy seq
is cheap and only realizing it may be costly, so it doesn't really make
sense to nest seque calls.  Just use one seque as outermost thingy, and
even then only in case you define the lazy seq long time before you are
going to realize it.

Disclaimer: I've never used seque before, but that's what I understand
from the docs and implementation. ;-)

Bye,
Tassilo

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to