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

Re: SOME (and other mapping



In article <2gg3lk$c79@pan.ics.uci.edu> pazzani@pan.ics.uci.edu (Michael Pazzani) writes:

   In article <9401052311.AA11767@cambridge.apple.com>,
   Bill St. Clair <bill@cambridge.apple.com> wrote:

   >You haven't missed anything. Genera uses a declaration inside each
   >mapping function to implement your idea. Another implementation could
   >enumerate the mapping functions some other way. MCL has no way to identify
   >a mapping function, hence you need to explicitly include the dynamic-extent
   >declaration in every caller.

   Thanks for all the suggestions. Anyway, can't MCL do something like
   this:

   (setf (symbol-function 'saved-some) (symbol-function 'some))
   (defmacro some (fun &rest list)
       (if (and (consp fun)
		(eq (car fun) 'function)
		(consp (second fun))
		(eq (car (second fun)) 'lambda))
	 (let ((args (second (second fun)))
	       (body (cddr (second fun))))
	       `(flet ((not-so-anonymous-lambda ,args ,@body))
		  (declare (dynamic-extent #'not-so-anonymous-lambda))
		  (saved-some #'not-so-anonymous-lambda ,@list))) 
	 `(saved-some ,fun ,@list)))

   With a little work, it could be cleaned up to something like
   (define-downward-funarg some 0).  

DEFINE-COMPILER-MACRO is meant for cases just like this, and has the
advantage of not ruining the use of SOME with APPLY and FUNCALL.
Portably speaking, however, only the CL implementor is allowed to
write a compiler macro for standard functions like SOME.
--
        Lawrence G. Mayka
        AT&T Bell Laboratories
        lgm@iexist.att.com

Standard disclaimer.