A macro is a function that's evaluated at compile time rather than at
runtime. Clearly the compiler needs some mechanism to distinguish between
the two, correct?

Clojure already has metadata and functions, so using a metadata flag on the
var introduces no new types. It also has the advantage of being able to
resolve a symbol as a macro before retrieving its content.

It's not the only way Clojure could have distinguished macros from normal
functions, but it's a simple and efficient solution.

- James


On 25 May 2014 23:20, Angel Java Lopez <ajlopez2...@gmail.com> wrote:

> I see that macro are defined with associated metadata :macro true in its
> associated var.
>
> Evaluate:
>
> (meta (var defn))
>
> and you see the :macro true in metadata
>
> Why? In other lisp, macro are the result of evaluate (mlambda ... ) or
> something alike, that is, macro are values that are evaluated in an special
> way, as special forms (no evaluation of arguments) and then, the result is
> evaluated. Normal functions are (lambda .... ) like (fn .... ) in Clojure.
> As macros are values, they can be passed as arguments (map amacro ....)
> could be evaluated (I guess). In Clojure, you must write (map (var amacro)
> ... )
>
> Why in Clojure the macro are defined using metadata, instead of something
> like (mlambda ... ) or (mfn ... )?
>
> My first guess: this way of doing macro was related with compile to Java
>
> Angel "Java" Lopez
> @ajlopez
>
>  --
> 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to