5

What is the difference between the evaluation of double and #'double in Clojure/Lisp?

1:2 user=> double
#<core$double__4077 clojure.core$double__4077@1acd47>
1:3 user=> #'double
#'clojure.core/double
unj2
  • 52,135
  • 87
  • 247
  • 375

1 Answers1

6

In Clojure, #'foo is a shorthand for (var foo), which returns the variable object foo refers to, as opposed to its value. Look it up in the reference:

I am not sure if you also want to know the meaning in Lisp: In Common Lisp, #'foo is a shorthand for (function foo), which is used to access the function value bound to the name foo when not in operator position.

Svante
  • 50,694
  • 11
  • 78
  • 122
  • 2
    slightly wrong. (function foo) looks up the functional value, true, but not necessarily from the symbol. A lexical function has no symbols involved, so it looks about the functional value bound to the name (!) foo from the lexical environment. – Rainer Joswig Jul 22 '09 at 11:26
  • 3
    Right, fixed. I really should fix my tendency to say "symbol" when I mean "name". – Svante Jul 22 '09 at 12:55