On Wed, Feb 18, 2009 at 8:02 PM, Rich Hickey <richhic...@gmail.com> wrote:
>
>
>
> On Feb 18, 12:20 pm, Frantisek Sodomka <fsodo...@gmail.com> wrote:
>> How should I say it... It just didn't look "symmetrical" to me.
>>
>> So, basically, there is a difference between functions returning
>> sequences - depending on if they are lazy or eager. Hmm...
>>
>> user=> (reverse [])
>> nil
>> user=> (if (reverse []) true false)
>> false
>> user=> (if (seq (reverse [])) true false)
>> false
>>
>> user=> (lazy-seq nil)
>> ()
>> user=> (seq (lazy-seq nil))
>> nil
>> user=> (if (lazy-seq nil) true false)
>> true
>> user=> (if (seq (lazy-seq nil)) true false)
>> false
>>
>> As long as I remember which function is lazy and which one is eager, I
>> should be fine then.
>>
>> Just wanted to really understand it.
>>
>
> It shouldn't be that subtle. Sequence functions shouldn't return nil
> unless they are variants of seq/next. I've fixed reverse and sort to
> return () when passed empty colls - SVN 1294.
>
> Rich.
>

Wouldn't it make more sense to to return an empty version of the same
collection type? That way the following would work more like someone
would expect.

(conj (rest [1]) 2) -> [2] instead of (2)

--Stefan

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