[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
LET-IF
- To: George J. Carrette <GJC@MIT-MC.ARPA>, robbins%bach.decnet@HUDSON.DEC.COM
- Subject: LET-IF
- From: Richard Lamson <rsl@RUSSIAN.SPA.Symbolics.COM>
- Date: Mon, 25 Nov 85 14:08 PST
- Cc: common-lisp@SU-AI.ARPA, robbins@HUDSON.DEC.COM
- In-reply-to: <[MIT-MC.ARPA].729508.851122.GJC>
- Reply-to: RSL@SCRC-STONY-BROOK.ARPA
Date: Fri, 22 Nov 85 20:41:51 EST
From: "George J. Carrette" <GJC@MIT-MC.ARPA>
Funny you should mention that, I'm considering flushing quite a few
special forms in the LMI system and replacing them with macros, LET-IF
is one, and the following definition seems right:
(defmacro let-if (pred bindings &body body)
(let ((f (gentemp "f")))
`(flet ((,f () ,@body))
(if ,pred (let ,bindings (,f)) (,f)))))
Unfortunately, this doesn't work if you want the bindings to be lexical
instead of special bindings. Consider:
(defun xor (a b)
(let-if a ((b (not b)))
b))
Unless B is special, this won't work using your scheme.
- Follow-Ups:
- LET-IF
- From: Bernard S. Greenberg <BSG@SCRC-STONY-BROOK.ARPA>
- References:
- LET-IF
- From: "George J. Carrette" <GJC@MIT-MC.ARPA>