Empty list type

2011-11-01 Thread Sebastián Galkin
Can somebody explain the rationale behind this?:

(isa? (type '(:foo :bar)) clojure.lang.PersistentList)  = true

(isa? (type ()) clojure.lang.PersistentList)  = false

(isa? (type (list)) clojure.lang.PersistentList)  = false


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

Re: Empty list type

2011-11-01 Thread David Nolen
(isa? (type '(:foo :bar)) clojure.lang.IPersistentList) = true
(isa? (type ()) clojure.lang.IPersistentList) = true
(isa? (type (list)) clojure.lang.IPersistentList) = true

2011/11/1 Sebastián Galkin paras...@gmail.com

 Can somebody explain the rationale behind this?:

 (isa? (type '(:foo :bar)) clojure.lang.PersistentList)  = true

 (isa? (type ()) clojure.lang.PersistentList)  = false

 (isa? (type (list)) clojure.lang.PersistentList)  = false


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

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

Re: Empty list type

2011-11-01 Thread Mark Rathwell
On Tue, Nov 1, 2011 at 7:33 PM, David Nolen dnolen.li...@gmail.com wrote:
 (isa? (type '(:foo :bar)) clojure.lang.IPersistentList) = true
 (isa? (type ()) clojure.lang.IPersistentList) = true
 (isa? (type (list)) clojure.lang.IPersistentList) = true


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


 2011/11/1 Sebastián Galkin paras...@gmail.com

 Can somebody explain the rationale behind this?:
 (isa? (type '(:foo :bar)) clojure.lang.PersistentList)  = true
 (isa? (type ()) clojure.lang.PersistentList)  = false
 (isa? (type (list)) clojure.lang.PersistentList)  = false


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

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

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


Re: Empty list type

2011-11-01 Thread Sebastián Galkin
On Tuesday, November 1, 2011 9:33:31 PM UTC-2, David Nolen wrote:

 (isa? (type '(:foo :bar)) clojure.lang.IPersistentList) = true
 (isa? (type ()) clojure.lang.IPersistentList) = true
 (isa? (type (list)) clojure.lang.IPersistentList) = true


oh that's right
Thank you!

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

Re: Empty list type

2011-11-01 Thread Chouser
2011/11/1 Sebastián Galkin paras...@gmail.com:
 On Tuesday, November 1, 2011 9:33:31 PM UTC-2, David Nolen wrote:

 (isa? (type '(:foo :bar)) clojure.lang.IPersistentList) = true
 (isa? (type ()) clojure.lang.IPersistentList) = true
 (isa? (type (list)) clojure.lang.IPersistentList) = true

 oh that's right

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

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