Re: Special forms vs. Macros

From: Adrian Kubala (adrian_at_sixfingeredman.net)
Date: 01/07/05


Date: Fri, 7 Jan 2005 13:56:35 -0600

Rob Warnock <rpw3@rpw3.org> schrieb:
> You can even do away with IF (or COND) if you have a primitive function,
> say, TRUTH-NUMBER, that takes a Lisp value and returns the fixnum 0 for
> true and 1 for false [or vice-versa, it doesn't matter, either can be
> made to work] and arrays and accessors [as above], like so:
>
> (defmacro if (boolean consequent alternate)
> `(funcall (aref (load-time-value
> (make-array 2 :initial-contents
> (list (lambda () ,consequent)
> (lambda () ,alternate)))))
> (truth-number ,boolean)))

It looks to me like the key part here isn't truth-number, but using
lambda to delay evaluation. I think that's how smalltalk does it in
fact: "if" is a function which takes a boolean and two thunks.