On Thu, Nov 5, 2009 at 7:24 PM, MarkSwanson <mark.swanson...@gmail.com>wrote:

> On Nov 5, 7:00 pm, MarkSwanson <mark.swanson...@gmail.com> wrote:
> > (def
> >  #^{:arglists '([coll])
> >     :tag clojure.lang.ISeq
> >     :doc "Returns a seq of the items after the first. Calls seq on its
> >   argument.  If there are no more items, returns nil."}
> >  next (fn next [x] (. clojure.lang.RT (next x))))
> >
> > PROBLEM: seq is not called on its argument.
>
> Ok, I see RT.next(x) is called and the implementation is:
>
> static public ISeq next(Object x){
>    if(x instanceof ISeq)
>        return ((ISeq) x).next();
>    ISeq seq = seq(x);
>    if(seq == null)
>        return null;
>    return seq.next();
> }
>
> 1. if ISeq, return the next item in the sequence.
> 2. else, (seq coll)
> I propose the docs should read something like this:
>
> (next coll)
>     :doc "If coll is not a seq, turn coll into a seq. Returns a seq
> of the coll after the first item.
>    If coll has no more items, returns nil."}


I wouldn't bother. The semantics are essentially what the present docs say;
it's just that where calling seq on its argument would just call a method
whose body is "return this;" it skips that no-op for efficiency. (At least,
the body of ASeq.seq() is "return this;"; are there any ISeq implementations
where it isn't?)

--~--~---------~--~----~------------~-------~--~----~
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