On 27.02.2009, at 14:46, Mark Volkmann wrote:

> Is it correct to say that each loaded function is represented by an
> AFn object in memory?

Each compiled function becomes a class that extends AFn. When the  
function is created in the Clojure code, an object is generated from  
this class. If you have a function returning a function (typically a  
closure), there is only one class for the returned function, but  
there will be several instances of that class.

> Are macros represented in memory in the same way?

Yes. Macros are strictly the same as functions. The only difference  
is that the var that stores the reference has a "macro" flag set, so  
that the compiler knows to call it correctly.

In fact, you can obtain a plain function version of a macro:

        (def and-as-a-function @(var and))

Of course, this is still a function that expects being called with  
unevaluated forms and returns a modified form. It's just called  
explicitly, rather than implicitly by the compiler.

Konrad.


--~--~---------~--~----~------------~-------~--~----~
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 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to