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

DYNAMIC-EXTENT



   Date: Fri, 17 Mar 89 13:29 EST
   From: Richard Mlynarik <Mly@ai.ai.mit.edu>

   I don't see any way in the proposal to declare that a closure itself, rather than
   its arguments, has dynamic extent.  My greatest single use for dynamic-extent
   declarations is to ensure stack-consing of closures.

   Symbolics have a declaration SYS:DOWNWARD-FUNCTION for this case.
   Perhaps CL could use DYNAMIC-EXTENT-FUNCTION

   (flet ((test (a b)
	    (declare (dynamic-extent-function))
	    ...))
     (foo #'test))

   (foo (lambda (a b)
	  (declare (dynamic-extent-function))
	  ...))

This is a genuine need.  I suggest

(flet ((test (a b) ...))
  (declare (dynamic-fextent test))	;So pick a better name
  (foo #'test))


   Another feature which I find sorely needed (and which nobody seems
   to support) is a way to declare that the result of a form
   has dynamic extent.  For example,
     (defmacro with-frob (thunk &body body)
       `(let ((*frob-stack* (cons (the dynamic-extent-object ,thunk) *frob-stack*)))
	  (declare (dynamic-extent *frob-stack*))
	  ,@body))
   The idea is to avoid making all users of the with-frob macro
   put in explicit dynamic-extent-function declarations.


This proposal has problems.  It is not enough to say
"foo has dynamic extent extent".  You have to say something
about when it starts and ends.  For executable constructs
we implicitly refer to the time execution enters the
construct and the time execution leaves it.  For objects
it is more difficult, and I claim you need to tie it to
code execution.  How do I know that the "thunk" is supposed
to last for the duration of the LET, rather than just the
duration of the call to CONS, or the duration of the caller
of the macro?
--Guy