[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


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)))))

The are similar constructions that conditionally bind dynamic things of
various kinds that are already implemented by taking advantage of
lexical scoping, CONDITION-BIND-IF (conditionally binding error handling)
is one fairly common form:

(condition-bind-if (not *debugging*) (x) (form) (error x)) for example.

Anyway, FLET is an ideal tool for avoiding what you describe as
 "I don't want to have to double the size of the function by having the
  body twice"

Or, as Mr Roberts would say, "can you say... CLOSURE," yes boys and girls...