[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: DEFMACRO
- To: (BUG LISPM) at MIT-AI
- Subject: Re: DEFMACRO
- From: JONL@MIT-AI
- Date: Tue ,31 Oct 79 11:39:03 EDT
Expansion for &optional arguments fails to set up correct variable
environment, as in standard DEFUNing, so that &optional may be initialized
to same value as some of the requireds. Also, the destructuring for the
&optionals causes multiple-evaluations of the default-value computation
for that &optional. Example of lossage
(DEFMACRO FOO ((A . B) &OPTIONAL
((C . D) (PROG2 (PRINT 'OPTIONALIZING) (CONS 1 B))))
`(LIST ,A ,B ,C ,D))
expands into
(MACRO FOO
(*MACROARG*)
(AND (OR (< (LENGTH *MACROARG*) 2) (> (LENGTH *MACROARG*) 3))
(ERROR '|-- wrong number of args to a macro.|
(LIST '((A . B)
&OPTIONAL
((C . D)
(PROG2 (PRINT 'OPTIONALIZING) (CONS 1 B))))
*MACROARG*)))
((LAMBDA (D C B A) (LIST 'LIST A B C D))
(CDR (COND ((CDR (CDR *MACROARG*)) (CAR (CDR (CDR *MACROARG*))))
(T (PROG2 (PRINT 'OPTIONALIZING) (CONS 1 B)))))
(CAR (COND ((CDR (CDR *MACROARG*)) (CAR (CDR (CDR *MACROARG*))))
(T (PROG2 (PRINT 'OPTIONALIZING) (CONS 1 B)))))
(CDR (CAR (CDR *MACROARG*)))
(CAR (CAR (CDR *MACROARG*)))))
*