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

UNLESS -- or something like it.

I find myself writing expressions of this form often:

(IF VAL VAL (DO-IT))  ; VAL evaluated once, of course

This is almost like UNLESS (the Common Lisp one-armed conditional), except
UNLESS returns () if VAL is non-(), so it's useless as an EXPRESSION (UNLESS
is still pretty good for side-effecting code, though).

The above code fragment can also be written as

(OR VAL (DO-IT)) ; VAL CAN only evaluate once anyway.

Is there some macro FOO that does this ?

(DEFMACRO FOO (VAL &BODY ELSE) ; not the real definition, it
  (OR ,VAL (PROGN ,@BODY))     ; should be smart about (FOO (INCF X) -1)
			       ; or the like

It seems like a fairly useful construction.  Anybody seen a form (macro) that
does this ?