Hi Ryan,

In Clojure a var can refer to a function, or something else, and what  
a var refers to can change at runtime.

You can call def with no arguments, or call declare, to def the var  
name with no initial binding:

(declare mysecond)
-> #'user/mysecond
(defn myfirst [] (mysecond))
-> #'user/myfirst
; bind mysecond later...

Since you are reading through PCL anyway you might want to look at the  
chapters I ported to Clojure:

http://blog.thinkrelevance.com/2008/9/16/pcl-clojure

Cheers,
Stu



> I'm reading through Practical Common Lisp as a way to get more
> familiar with Lisp.  In Chapter 4 I came across a stumbling block in
> the section "S-expressions As Lisp Forms."  Towards the end of that
> section it says
>
> "To determine what kind of form a given list is, the evaluator must
> determine whether the symbol that starts the list is the name of a
> function, a macro, or a special operator.  If the symbol hasn't been
> defined yet--as may be the case if you're compiling code that contains
> references to functions that will be defined later--it's assumed to be
> a function name."
>
> If I try to define the following function in the Clojure REPL I will
> get an exception saying it was unable to resolve the symbol, but that
> same method will simply give me a warning in CL stating that the
> method mysecond is undefined.
>
> (defn myfirst [] (mysecond))
>
> At first I thought maybe this has something to do with the fact that
> Clojure is a Lisp-1 vs. a Lisp-2, but the above is legal in MIT
> Scheme.
>
> So why is the above form not legal in Clojure?  I would think it might
> come in handy to define a function that relies on something currently
> not-yet-defined.  Why is this the appropriate behavior?
>
> Excuse my noise if this is already explained in the docs, or is
> obvious.
>
> -Ryan
> >


--~--~---------~--~----~------------~-------~--~----~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to