From: Steve Haflich

Subject: Re: Global GC performance

Date: 1996-8-27 21:57

   Date: Sun, 25 Aug 1996 13:26:18 -0400
   From: "Donald H. Mitchell" <pgh.net at dhm>

   #2) what is the correct way to declare dynamic-extent for lambda
   expressions?  (i.e., #'(lambda (i) ...)) or will the compiler assume
   dynamic-extent when the lambda is an arg to such functions as some,
   funcall, etc. (from which the lambda is not returned).

The language provides no way directly to declare dynamic-extent the
value returned by the FUNCTION special form, just as it provides no
way to declare dynamic-extent the value returned by any other form.
What you can do is to bind or set a declared dynamic-extent variable
to that value.  See the convoluted first paragraph of CLtL2 p.233.
In this context, it means something like:

     (let ((foo #'(lambda (...) ...)))
       (declare (dynamic-extent foo))
       ...)

   #3) what is the correct way to declare dynamic-extent for flet or labels
   defined functions?  In mcl, you must use #' but I don't know about other
   compilers.  That is,
   
   (flet ((my-fun (i) ...))
     (declare (dynamic-extent #'my-fun))
     ...)
   works but (... (dynamic-extent my-fun) ...) does not.
   
This is not dependent on the particular implementation.  CL is a "Lisp
2", meaning that symbols implement two entirely separate namespaces
for values and for functions.  Although the CLtL-era language
specification for declarations was muddled, the ANS is unambiguous.

Mentioning SYM in a declaration refers to the binding of SYM in the
value namespace.  Mentioning (FUNCTION SYM) in a declaration refers to
the binding of SYM in the function namespace.  These namespaces have
absolutely nothing to do with one another and there is no confusion so
far as the ANS is concerned.