basic quoting question

2012-10-08 Thread Brian Craft
user= (X Y)
ClassCastException java.lang.String cannot be cast to clojure.lang.IFn 
 user/eval116 (NO_SOURCE_FILE:32)
user= '(X Y)
(X Y)
user= ['X 'Y]
[X Y]
user= '[X Y]
[X Y]
user= ('X 'Y)
nil


All of these are as I expected except the last, which I thought would throw 
something like the 1st case. What's going on there?

-- 
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: basic quoting question

2012-10-08 Thread Jay Fields
symbol, 'X in the last case, implements IFn, and you're calling it
with the symbol 'Y as an argument.

On Mon, Oct 8, 2012 at 9:43 AM, Brian Craft craft.br...@gmail.com wrote:
 user= (X Y)
 ClassCastException java.lang.String cannot be cast to clojure.lang.IFn
 user/eval116 (NO_SOURCE_FILE:32)
 user= '(X Y)
 (X Y)
 user= ['X 'Y]
 [X Y]
 user= '[X Y]
 [X Y]
 user= ('X 'Y)
 nil


 All of these are as I expected except the last, which I thought would throw
 something like the 1st case. What's going on there?

 --
 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: basic quoting question

2012-10-08 Thread Jack Moffitt
 user= ('X 'Y)
 nil

 All of these are as I expected except the last, which I thought would throw
 something like the 1st case. What's going on there?

You've prevented X from being evaluated (it will be seen as the symbol
X), but you haven't prevented evaluation of the function call. Symbols
happen to be functions that look themselves up in collections. 'Y is
not a collection, so it returns nil.

Had you had something else in function position that wasn't actually a
valid function, you would have gotten a ClassCastException.

jack.

-- 
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: basic quoting question

2012-10-08 Thread Brian Craft
Thanks!

Is the string vs symbol distinction peculiar to clojure, among lisps?

On Monday, October 8, 2012 8:03:00 AM UTC-7, Jack Moffitt wrote:

  user= ('X 'Y) 
  nil 
  
  All of these are as I expected except the last, which I thought would 
 throw 
  something like the 1st case. What's going on there? 

 You've prevented X from being evaluated (it will be seen as the symbol 
 X), but you haven't prevented evaluation of the function call. Symbols 
 happen to be functions that look themselves up in collections. 'Y is 
 not a collection, so it returns nil. 

 Had you had something else in function position that wasn't actually a 
 valid function, you would have gotten a ClassCastException. 

 jack. 


-- 
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: basic quoting question

2012-10-08 Thread Ben Smith-Mannschott
On Mon, Oct 8, 2012 at 5:06 PM, Brian Craft craft.br...@gmail.com wrote:
 Thanks!

 Is the string vs symbol distinction peculiar to clojure, among lisps?


Yes, strings are distinct from symbols in every reputable lisp.

That symbol and keyword know how to look themselves up in an
associative collection is, as far as i know, unique to Clojure.

// Ben

 On Monday, October 8, 2012 8:03:00 AM UTC-7, Jack Moffitt wrote:

  user= ('X 'Y)
  nil
 
  All of these are as I expected except the last, which I thought would
  throw
  something like the 1st case. What's going on there?

 You've prevented X from being evaluated (it will be seen as the symbol
 X), but you haven't prevented evaluation of the function call. Symbols
 happen to be functions that look themselves up in collections. 'Y is
 not a collection, so it returns nil.

 Had you had something else in function position that wasn't actually a
 valid function, you would have gotten a ClassCastException.

 jack.

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