Clojure compiles all functions, anonymous or named, in the same way. Then it stores a pointer to this function in the namespace (contained in var) so that others can find it later.
There is no difference in compilation time between functions that are compiled and used as anonymous functions, as well as functions that are compiled and then have a pointer to them, stored in var, which is part of the namespace.
When anonymous functions are used at run time, most of the time (probably always) they are created by creating closures (objects), so the cost of creating them is some memory and a little time.
If you call eval in temporary critical loops, you can create the same problems in Clojure that you can do in any other language.
Arthur ulfeldt
source share