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

*applyhook* question (hopefully I'll get it right this time)



    Date: Thu 18 Sep 86 12:04:06-MDT
    From: SANDRA <LOOSEMORE@UTAH-20.ARPA>

I haven't seen any replies to this.  I guess I can try to take a crack at it.

    CLtL says the apply hook function "takes three arguments, a function, a list
    of arguments, and an environment".  Three questions:

    (1) Is the "function" argument already evaluated?  There are no user-
    accessible functions for extracting its definition from the environment, so
    I don't see how the hook function could make much use of an unevaluated
    function.

    (2) Are the arguments in the argument list argument already evaluated, or
    is it the responsibility of the hook function to evaluate them before
    applying the function?

The intent of this ("when a function is about to be applied to arguments",
CLtL p.322) is that the applyhook is called after everything has been evaluated.

    (3) If both the "function" and "argument list" arguments are already
    evaluated, what does the hook function need an environment for?

It's not for anything!  Apparently this was discussed on the mailing list
long ago, because this comment appears in our source code:

;After discussion on the Common Lisp mailing list, the ENV for the apply hook
;is the environment in which the arguments have already been evaluated, not
;the environment of the function to be called, which is of course still inside
;its closure.  Its completely inutile to have the environment as an argument here,
;but it's in the book so I'll accept it and ignore it.

I suspect this env is a mistake, although it's conceivable that it is a hook
for some kind of future feature.