Ah so it seems a "lazy sequence" implements IPending?

Thanks,
Ambrose


On Thu, Apr 17, 2014 at 3:39 AM, gianluca torta <giato...@gmail.com> wrote:

> this issue on core.typed
> http://dev.clojure.org/jira/browse/CTYP-96
>
> in particular the comment:
> "This is starting to make me rethink what a clojure.core docstring means
> exactly by a "lazy sequence"
>
> cheers,
> Gianluca
>
>
> On Wednesday, April 16, 2014 6:45:01 PM UTC+2, Mars0i wrote:
>>
>> The docstring for iterate says that it returns a lazy sequence, but it
>> returns a Cons wrapped around a LazySeq.  This means, for example, that
>> realized? can't be applied to what iterate returns.  Is this a problem
>> with the iterate docstring?  Or should realized? be applicable to
>> Conses?  I assume that there's a good reason that iterate returns a Cons
>> instead of a LazySeq.
>>
>> Clojure 1.6.0
>> user=> (doc iterate)
>> -------------------------
>> clojure.core/iterate
>> ([f x])
>>   Returns a lazy sequence of x, (f x), (f (f x)) etc. f must be free of
>> side-effects
>> nil
>>
>> user=> (def xs (iterate inc 0))
>> #'user/xs
>>
>> user=> (class xs)
>> clojure.lang.Cons
>>
>> user=> (class (rest xs))
>> clojure.lang.LazySeq
>>
>> user=> (realized? (rest xs))
>> false
>>
>> user=> (realized? xs)
>> ClassCastException clojure.lang.Cons cannot be cast to
>> clojure.lang.IPending  clojure.core/realized? (core.clj:6883)
>>
>> user=> (take 5 xs)
>> (0 1 2 3 4)
>>
>> user=> (realized? (rest xs))
>> true
>>
>> user=> (realized? xs)
>> ClassCastException clojure.lang.Cons cannot be cast to
>> clojure.lang.IPending  clojure.core/realized? (core.clj:6883)
>>
>> user=> (doc realized?)
>> -------------------------
>> clojure.core/realized?
>> ([x])
>>   Returns true if a value has been produced for a promise, delay, future
>> or lazy sequence.
>> nil
>>
>  --
> 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to