[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Screw with DEFVST (which otherwise works fine)
- To: bug-lisp at MIT-MC
- Subject: Screw with DEFVST (which otherwise works fine)
- From: Guy Steele <GLS at SU-AI>
- Date: Tue, 19 Jun 79 08:12:00 GMT
- Cc: GLS at SU-AI
- Original-date: 19 Jun 1979 0112-PDT
(DEFVST GRUNT FOO BAR BAZ)
(DEFMACRO CLOBBER (FROB)
(COND ((EQ (CAR FROB) 'CAR)
`(RPLACA ,(CADR FROB) (CLOBBERIFIER ,FROB)))
((EQ (CAR FROB) 'CDR)
`(RPLACD ,(CADR FROB) (CLOBBERIFIER ,FROB)))
(T `(SETF ,FROB (CLOBBERIFIER ,FROB)))))
(CLOBBER (GRUNT-BAR MY-FAVORITE-GRUNT))
This fails to work because the two occurrences of FROB (i.e. of
(GRUNT-BAR MY-FAVORITE-GRUNT)) in the generated SETF
form will be EQ. The second occurrence is evaluated first,
and macro-expanded in the process. As a result, the SETF
(i.e. SETVST) sees a form as its first argument whose car
is MACROEXPANDED rather than GRUNT-BAR, so it gets very unhappy.
I am fixing this by writing instead
...
(T `(SETF ,(APPEND FROB '()) (CLOBBERIFIER ,FROB)))))
but this seems to be a crock. Is there any hope of a reasonable
general solution to this problem?