On Mon, Feb 16, 2009 at 12:05 PM, Perry Trolard <trol...@gmail.com> wrote:
>
> I agree with the majority of posters that the breaking changes in the
> service of optimal names is the right way to go.
>
> I found the explanation & recipe for porting at clojure.org/lazier
> clear & easy to follow. I didn't do full ports of any projects, but I
> did some selective porting & found it to be straightforward.
>
> That said, the only problem I see is with the names. Like Mibu, I
> think "next" isn't ideal -- it connotes an item in an iteration to me.
> If you think "next *seq*" when you see "next" (how Rich explains it
> at /lazier), it helps, but it's still not exactly right; or it
> requires a different mental model from the non-lazy-branch "rest": the
> cursor moving to the "next" item rather than the abstracted "rest of
> the coll" (where you think about a cursor).
>
> I think the issue is that "rest" is the right name for both rest &
> next. The only difference between them, from the perspective of users,
> is how empty rests are represented ('() or nil), & that's a hard
> distinction to make manifest in a short name.
>
> If it's the case that rest will almost exclusively appear in the
> context of constructing lazy-seqs
>
>  (lazy-seq
>   (cons [something] (rest [something]))
>
> & next will appear all over, it makes sense to me to sacrifice brevity
> in the case of rest, & give next the right name: "rest" (that's
> tortuous, I know).
>
> rest* isn't quite right, but you get the idea: make the fully-lazy
> rest the special-kind-of-rest, & the consumer-code rest the
> transparent one. This way, people's concepts about recursing through
> seqs of colls & testing for the end won't have to change; they'll only
> have to change their understanding of how to make lazy sequences. I
> know in my code I do a lot more of the former.
>
> Anyone who's on board with this line of thought have ideas for the
> right name of fully-lazy rest?
>

I am fully on board with this idea. 'next' seems unfit to me exactly
as a few people have pointed out, it connotes an item rather than the
rest of a seq.

That said, I really have no grounds to be confident either way that
rest will almost exclusively appear in the context of constructing
lazy-seqs. Can any other more experienced folks can offer some
thoughts on this conjecture?

Someone suggested 'next-seq' earlier. I would also suggest rest-seq,
which is almost a literal translation of the invariant:

 (rest-seq x) === (seq (rest x))

I like this, but as you point out Perry, there is a typing penalty to
be paid here; however, I think it is a small one and completely
justified.

Jim asked above why seq-on-the-next-item-if-any-else-nil is needed at
all, and clearly as Rich stated, there is a large number of uses of
rest right now proving its usefulness.

For me, this highlights the fact that in the new fully lazy seq model,
the function 'seq-on-the-next-item-if-any-else-nil" is not core to the
abstraction. As a result, having a "second class' hyphenated name such
as rest-seq (or next-seq), almost confers the "exists for convenience"
nature of this function that we are trying to name.

/mike.

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