[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Desirable macro
- Subject: Re: Desirable macro
- From: Guy.Steele at CMU-10A
- Date: Tue ,13 Jan 81 15:14:00 EDT
I have often wanted a macro (call it FROTZ for now) that would do:
(FROTZ + (CAR FIZZLEBLORT) TOOTSNOOTER)
==> (SETF (CAR FIZZLEBLORT) (+ (CAR FIZZLEBLORT) TOOTSNOOTER))
(Actually, I would rather write
((FROTZ +) (CAR FIZZLEBLORT) TOOTSNOOTER)
but such is life.)
People will readily see that FROTZ FOO is similar to the
"gets-foo" operator of Algol-like languages:
A +:= B means A := A + B
A *:= B means A := A * B
Of course, the combination FROTZ CONS already exists, and is
called PUSH. But FROTZ is also useful with + and also with
ADJOIN or ADJQ:
(DEFUN ADJOIN (X Y) (IF (MEMBER X Y) Y (CONS X Y)))
(DEFUN ADJQ (X Y) (IF (MEMQ X Y) Y (CONS X Y)))
These are the "add-unique" or "add-to-set" operations.
(DEFUN ADJPROP (X V Y) (FROTZ ADJQ (GET X Y) V))
(although there are more efficient ways to implement this
particular case).
So how about it? And what to call it? Actually, one could
compatibly call it PUSH (the three-arg case)! But it would be wrong.
I can't think of anything else to call it.
--Guy