On 13 May 2013 17:30, Timothy Baldridge <tbaldri...@gmail.com> wrote:
>>> In fact, the way that count works on ISeqs is rather roundabout -- it
> only works because all implementations of ISeq in clojure.jar also
> happen to implement java.util.List, so count calls Collection.size().
> In theory, some user-provided ISeq which didn't implement List would
> not respond to count.
>
> ------
>
> That is just completely untrue:
>
> https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L536
> https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L826

Thanks for the correction.

I had read this code before and I read it again and couldn't see any
mistake, until I looked at ISeq and realized it implements
IPersistentCollection. That came as a surprise to me.

I guess I'm used to treating seqs and colls as very separate ideas
that I simply didn't expect that ISeq would implement
IPersistentCollection.

Phil

> Timothy
>
>
>
> On Mon, May 13, 2013 at 10:17 AM, Philip Potter <philip.g.pot...@gmail.com>
> wrote:
>>
>> In fact, the way that count works on ISeqs is rather roundabout -- it
>> only works because all implementations of ISeq in clojure.jar also
>> happen to implement java.util.List, so count calls Collection.size().
>> In theory, some user-provided ISeq which didn't implement List would
>> not respond to count.
>>
>> It's probably a good idea for interop reasons to have seqs implement
>> the java collection types, but I don't feel too happy about clojure
>> code which uses the java Collection interface on seqs.
>>
>> Phil
>>
>> On 13 May 2013 15:48, Meikel Brandmeyer (kotarak) <m...@kotka.de> wrote:
>> > Hi,
>> >
>> > Am Montag, 13. Mai 2013 16:16:57 UTC+2 schrieb Sean Corfield:
>> >>
>> >>
>> >> So you think (count (map inc [1 2 3])) should be illegal?
>> >>
>> >> (I'm just trying to understand your logic here)
>> >>
>> >
>> > In the hardcore version, yes. In the practical version, probably not. I
>> > never had to call count on a seq. (Various versions of partition-by or
>> > split
>> > being a notable exception.) (Still a promised O(1) count would be nice
>> > for
>> > reasoning as we have it for contains?. What is clojure.lang.Counted good
>> > for
>> > anyway?)
>> >
>> > Meikel
>> >
>> > --
>> > --
>> > 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/groups/opt_out.
>> >
>> >
>>
>> --
>> --
>> 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/groups/opt_out.
>>
>>
>
>
>
> --
> “One of the main causes of the fall of the Roman Empire was that–lacking
> zero–they had no way to indicate successful termination of their C
> programs.”
> (Robert Firth)
>
> --
> --
> 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/groups/opt_out.
>
>

-- 
-- 
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/groups/opt_out.


Reply via email to