Re:One Reason That MIT Should Reinstate Scheme and 6.001 (2009)
by serialdev on Tuesday November 06, 2018 @09:02AM
(#18390997)
One difference is flow control. When you call a function, all the arguments are evaluated before being passed into the function. If you want to delay evaluation, you have to wrap the argument values in a function. When you call a macro, the text forms get passed with no evaluation.
Say Clojure forgot to ship with the boolean "or". "or" should evaluate its arguments one at a time (to allow for short circuiting) and return the first non-false value. You could do this with functions, but you have the source-level overhead of manually wrapping everything, and performance overhead of defining and passing an anonymous function for each argument. With a macro, at compile time you just translate the "or" macro into a simpler form that uses "if". This is how Clojure actually implements "or":
Also check this http://lists.warhead.org.uk/pipermail/iwe/2005-July/000130.h...
[ Parent
| on HN ]
There are no comments on this comment yet.