On 4 Mag, 16:29, "Marshall T. Vandegrift" <llas...@gmail.com> wrote:
> André Thieme <splendidl...@googlemail.com> writes:
> > Please try this minimal example in your REPL:
> > (defn f [x] (fn [] x)) ; the closure factory
> > (def foo (f 0)) ; a useful instance
> > (defmacro bar [] `(let [a# ~foo]))
> > and then call (bar)
>
> I'm new to Clojure and don't have much experience with Lisps in general,
> but trying to do this seems weird to me.  My understanding is that
> macros are, well, macros -- code which is expanded at compile-time to
> other code.  In which case the interface the macro facility provides
> isn't a set of compiler hooks, but just the ability to factor and
> abstract the same code you could write without the macro facility.  What
> ultimate code-expansion are you trying to achieve?  Perhaps there's a
> different way to do it which works within the confines of pure code
> re-writing.

The key point is that in Lisp "code" does not mean "text" [1]. Code is
made of data structures - lists, symbols, vectors, numbers, ... - and
macros are just functions that operate on those data structures. In
other words, valid code is no longer determined by the reader (i.e.
the parser), but by the compiler and/or the interpreter, that take a
rich data structure as input. The reader is "only" useful to us humans
to enter code into the system.

Alessio

[1] actually this is matter of debate, for example in the Common Lisp
standard "code" is defined with both meanings, but without
complicating things too much, my point is that the canonical form of
the code - the one that is fed to the compiler - is not 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