David Simmons <shortlypor...@gmail.com> writes:

Hi David,

> Presumably this only applies to functions?

No, not really.

> If I replace (defn foo [] "hello") with (def foo "hello") I don't get
> the same results. Is this because functions are handled differently?

--8<---------------cut here---------------start------------->8---
user> (def foo "hello")
#'user/foo
user> (def a foo)   ;; a has the current value of foo
#'user/a
user> (def b #'foo) ;; b's value is the Var foo
#'user/b
user> (def foo "goodbye")
#'user/foo
user> a
"hello"
user> b
#'user/foo
user> @b
"goodbye"
--8<---------------cut here---------------end--------------->8---

Please note that you have to dereference b explicitly to get the value
currently bound to foo.  That's because b's value is again a Var.  It
seems that Clojure dereferences Var's automatically, possibly multiple
times, in case of function calls.  So in Stuard's example, both (b) and
(@b) call the function currently bound to foo.

Bye,
Tassilo

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

Reply via email to