Welcome! Please see the About page for a little more info on how this works.

0 votes
ago in Clojure by
retagged ago by

When the eval function in Clojure is called with an argument that is an instance of IPersistentCollection which likely isn't a special def-like form (the first element isn't a symbol at all or it does not start with "def"), the form is first wrapped in an anonymous function which then gets compiled and invoked, which indirectly evaluates the original form.

There aren't any extra checks performed and it makes forms like these 2 valid, which should normally be rejected and a compiler exception should be thrown:


(recur)

or

(let []
(print "Hello")
(Thread/sleep 1000)
(recur))

where the 2nd form keeps printing "Hello" and loops infinitely over the outer wrapper function.

Please log in or register to answer this question.

...