On Tue, Dec 16, 2008 at 11:59 AM, Mon Key <[email protected]> wrote: > >> This is why flatten's behavior was considered a bug. In Clojure, an >> empty sequence is equivalent to nil, not to '(nil). > > This does not comport with the various differences enumerated @ > http://clojure.org/lisps > Perhaps they need to be changed. RH care to weigh in on this? > > which says: > "() is not the same as nil"
I didn't say () was the same as nil, I said an empty sequence was and that you should be comparing (seq? nil) to (seq? ()), not (seq? '(nil)). > and this one: > "In Clojure nil means 'nothing'. It signifies the absence of a value, > of any type, and is not specific to lists or sequences." > > and probably this one too: > "Empty collections are distinct from nil. Clojure does not equate nil > and '()." These docs are all correct and consistent. Also, I did not equate nil and '(), I equated (seq? nil) and (seq? '()), and only to illustrate why (flatten nil) should not return '(nil). > and this one as well: > "...There is no such thing as an empty sequence. Either there is a > sequence (with elements) or there isn't (nil)..." This is exactly the point. As Randall pointed out, flattening nothing should not create something (since '(nil)) is something. Remember, you don't expect a list out of (flatten), you expect a sequence and an empty sequence is nil. > add this to the pile: > "...The Clojure return values differ in not returning empty > collections, but rather a sequence or not...." Again, this is exactly why flatten should return nil in this case. It should return "a sequence or not" and flattening nothing should give you nothing. I don't see any inconsistencies here. - J. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---
