Hi Stuart

fantastic - it is starting to make sense now. One follow on question.

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

many thanks (again)

Dave

On Apr 23, 2:48 am, Stuart Campbell <stu...@harto.org> wrote:
> Hi Dave,
>
> If you write
>
>   (run-jetty routes ...)
>
> then the current value of "routes" is looked-up and passed to run-jetty.
> You won't see any change if you subsequently redefine "routes", because the
> original definition is what was passed to run-jetty.
>
> On the other hand,
>
>   (run-jetty #'routes ...)
>
> passes a var (seehttp://clojure.org/vars) to run-jetty. Now whenever
> run-jetty invokes your handler function, the currently-bound value of
> "routes" is invoked.
>
> Here's a simplified example:
>
>   user> (defn foo [] "hello")
>   #'user/foo
>   user> (def a foo)
>   #'user/a
>   user> (def b #'foo)
>   #'user/b
>   user> (defn foo [] "goodbye")
>   #'user/foo
>   user> (a)
>   "hello"
>   user> (b)
>   "goodbye"
>
> Cheers,
> Stuart
>
> On 23 April 2012 06:01, David Simmons <shortlypor...@gmail.com> wrote:
>
>
>
> > Hi
>
> > I'm new to Clojure but very keen to learn. I'm following Web
> > Development with Clojure (http://www.vijaykiran.com/2012/01/11/web-
> > application-development-with-clojure-part-1/) and came across the
> > following code:
>
> >  (run-jetty #'routes {:port (or port 8080) :join? false}))
>
> > I know that #'routes is the same as (var routes) and that it is
> > passing the "object" rather than the actual value BUT I don't
> > understand why this is used. Specifically if I replace #'route with
> > route the code works fine. I've read somewhere this is something to do
> > with autoloading changes to code when developing for the web. Does
> > anyone have a simple explanaition for #' and why it is used here. If
> > you have some simple clojure code to illustrate its use I'd be really
> > grateful.
>
> > many thanks in advance for any help.
>
> > Dave
>
> > --
> > 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- Hide quoted text -
>
> - Show quoted text -

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