--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@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+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
(type ()) ;=> clojure.lang.PersistentList$EmptyList
EmptyList is an inner class in PesistentList, and is not directly
derived from PersistentList. Though, as David shows, both
PersistentList and PersistentList$EmptyList implement the interface
IPersistentList.
(isa? (type '(:foo :bar)) clojure.lang.IPersistentList) => true(isa? (type ()) clojure.lang.IPersistentList) => true(isa? (type (list)) clojure.lang.IPersistentList) => true
There's a larger point here that I think David was making. It is
important not to rely on the concrete type of anything, but instead to
rely on an interface or protocol that it supports. Choose the right
abstraction to allow concrete details to be adjusted without breaking
your program. The EmptyList class is a perfect example of an
implementation detail that we shouldn't rely on. Nobody promises that
it will be there in the future. However, Clojure does promise that
'(:foo :bar), () and (list) will all return something for which seq?,
list?, coll?, and sequential? will return true, and that () and (list)
will return something for which empty? will return true.
--Chouser