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

Re: More on macros in Maclisp



eg, consider the following interaction with Maclisp:

    (DEFMACRO IMMEDIATE-MACRO (&REST X)
      (LET ((FN (COPYSYMBOL '%MACRO NIL))
	    (VAR (GENSYM)))
	(EVAL `(MACRO ,FN (,VAR) (,X ,VAR)))
	(SET FN FN) ; Just in case of multiple EVAL (sigh)
	FN))
=>  IMMEDIATE-MACRO

    (DEFMACRO FIRST () '(IMMEDIATE-MACRO LAMBDA (X) `(CAR ,(CADR X))))
=>  FIRST

    (MACROEXPAND '((FIRST) '(A B))
=>  (CAR (QUOTE (A B)))

    ((FIRST) '(A B))
=>  ;ILLEGAL USE OF MACRO - EVAL		; The (SET FN FN) above
						;  probably wasn't needed since
						;  this loses anyway...

    ;In the compiler:
    (DEFUN DEMO (X) ((FIRST) X))
=>  DEMO

    (CL DEMO)
    (LAP DEMO SUBR) 
    (ARGS DEMO (()  . 1)) 
    (HLRZ 1 0 1) 
    (POPJ P) 
    ()  
=>  (COMMENT DEMO) 

If EVAL were cleaned up to allow macros only in the car of the form, then
((FIRST) '(A B)) could be made to match the other instances here and people
would be able to get the macro operators they desire.