Macro ENSURE
From: Nicolas Neuss (my.name_at_iwr.uni-heidelberg.de)
Date: 07/30/04
- Next message: Albert Reiner: "Re: lambda returning lambda"
- Previous message: Eli Bendersky: "lambda returning lambda"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 30 Jul 2004 13:51:03 +0200
Hello.
Relatively often I happen to write
(unless x (setf x y))
or
(setf x (or x y))
and I want to replace this with a macro ENSURE as
(ensure x y)
Since the macro
(defmacro ensure (x y)
`(setf ,x (or ,x ,y)))
has problems with multiple evaluation (e.g. (ensure (aref x (incf i)) 1)),
the best solution should be something like
(define-modify-macro ensure (&rest args) or)
Question 1: Is this allowed by the spec, i.e. is the macro OR allowed to
appear at this place?
Question 2: Is this macro a good idea?
Question 3: Since such a macro might be rather common: is there another
name for it?
Thanks, Nicolas.
- Next message: Albert Reiner: "Re: lambda returning lambda"
- Previous message: Eli Bendersky: "lambda returning lambda"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|