What's so special about IF?

From: David Steuber (david_at_david-steuber.com)
Date: 12/21/04


Date: 21 Dec 2004 00:04:23 -0500

The CLHS states that IF is a Special Operator. But what if there was
no IF? Don't ask my why I was thinking about this. Just for fun, I
decided to see if I could use the Macros AND and OR along with the
function NOT to see if I could emulate IF:

(defmacro my-if (test then &optional (else nil))
  (let ((b (gensym)))
    `(let ((,b ,test))
       (or (and ,b ,then)
           (and (not ,b) ,else)))))

Some of the inspiration came from a digital logic course I once took
which reduced everything in a computer to several fundamental gates.

I know it's trivial, but I find this a rather eloquent answer to what
makes Lisp special.

-- 
An ideal world is left as an excercise to the reader.
   --- Paul Graham, On Lisp 8.1


Relevant Pages

  • Re: Whats so special about IF?
    ... David Steuber wrote: ... > The CLHS states that IF is a Special Operator. ... > which reduced everything in a computer to several fundamental gates. ...
    (comp.lang.lisp)
  • Re: Whats so special about IF?
    ... Artie Gold wrote: ... > David Steuber wrote: ... >> The CLHS states that IF is a Special Operator. ...
    (comp.lang.lisp)
  • Re: Whats so special about IF?
    ... Artie Gold wrote: ... > David Steuber wrote: ... >> The CLHS states that IF is a Special Operator. ...
    (comp.lang.lisp)