Troubles with truthiness

2012-05-14 Thread Jamie Brandon
I ran across this behaviour today: shackles.examples= (import '[clojure.lang Seqable]) clojure.lang.Seqable shackles.examples= (deftype Foo [] Seqable (seq [this] ())) shackles.examples.Foo shackles.examples= (empty? (Foo.)) false shackles.examples= (deftype Bar [] Seqable (seq [this] nil))

Re: Troubles with truthiness

2012-05-14 Thread Stuart Sierra
The empty list () is an object, and objects are truthy. `seq` on any empty collection is defined to return nil. So your definition: (deftype Foo [] Seqable (seq [this] ())) should return nil instead of the empty list. `(next x)` is equivalent to `(seq (rest x))` -S -- You received