Kevin Livingston <kevinlivingston.pub...@gmail.com> writes:

>> Not at all. next is basically #(seq (rest %)); you might want to use
>> it when the extra bit of strictness is beneficial to your code and you
>> shouldn't use it when it isn't.
>
> oh, ok.  I saw some posts on using the new super-lazy lists / code and
> it implied that next was necessary over rest, but I didn't quite read
> it in excruciating detail.

Likely what you were reading was referring to nil-punning.  In very
early versions of Clojure, empty seqs were nil, so you could do:

(when some-seq
   ...)

Of course this has the problem that you can't have a completely lazy
seq, the first element is always evaluated (to see whether the seq is
empty or not in order to return nil).  They were made fully lazy by
introducing empty seqs, thus you now need to explicitly check with one
is empty use 'seq.  So next is a shorthand for doing this on rest and
replacing instances of rest with next in old code that relied on
nil-punning was a simple way to upgrade.

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