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

Re: what does (declare (downward-function)) do?



> 
> The subject line says it all. I see no mention in Steele.
> I assume it allows for some optimization.
> -ME
> 

It becomes extinct or obsolete.

It was intended as a way of advertising that an anonymous lexical closure
had dynamic extent; the effect was to treat:

(foo #'(lambda (x y) (declare (downward-function)) ...) ...)

as if it were:

(flet ((#:g1 (x y) ...))
  (declare (dynamic-extent #'#:g1))
  (foo #'#:g1 ...))

i.e., as if the closure's extent "wrapped around" the nearest surrounding
function call.

Aside from being syntactically obscure, the semantics are sometimes a bit
surprising, as in cases like:

(foo (identity #'(lambda (x y) (declare (downward-function)) ...)) ...)

Whoops.

Using some binding form and a DYNAMIC-EXTENT declaration seems preferable;
although one may have to expend some effort in thinking up a name to bind the
function to, one is at least making it clear just which extent it is that's
dynamic ...