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

SYMBOL-MACROFLET



   Date: Tue, 13 Sep 88 15:05 EDT
   From: Kent M Pitman <KMP@STONY-BROOK.SCRC.Symbolics.COM>

       Date: Tue, 13 Sep 88 11:27:10 pdt
       From: Eric Benson <eb@lucid.com>

       Doesn't this do what you want?

       (defmacro fsymbolf-fmacrofletf (renamings &body body)
	 `(macrolet ,(mapcar #'(lambda (renaming)
				 `(,(first renaming) (&rest args)
				     `(,',(second renaming) ,@args)))
			     renamings)
	    ,@body))

   No: think about #' .

   In my experience, a common reason to use DEFUN-IN-FLAVOR (rather than
   DEFMETHOD) is to make the name suitable for MAPCAR. That is, to be
   able to do (MAPCAR #'local-function things) rather than
   (MAPCAR #'method-name (CIRCULAR-LIST SELF) things).


Sorry about the premature posting; my fingers slipped.

This will work:

(defmacro fsymbolf-fmacrofletf (renamings &body body)
  `(flet ,(mapcar #'(lambda (renaming)
			  `(,(first renaming) (&rest args)
			      (apply #',(second renaming) args)))
		      renamings)
     (declare (inline ,@(mapcar #'first renamings)))
     ,@body))

Of course you won't be happy with the result unless your compiler
optimizes (APPLY x (LIST a b c)) into (FUNCALL x a b c).