[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: First Class environments in CL ??
Date: Mon, 12 May 86 15:13 EDT
From: David A. Moon <Moon@SCRC-STONY-BROOK.ARPA>
To: beckerle@MIT-XX.ARPA
Subject: First Class environments in CL ??
I believe the env argument to the function applyhook to be a typographical
error, since there is no meaningful way that that argument could be used.
Our implementation ignores it. I have not investigated, but I expect
every other implementation ignores it too.
Hmmm. Once again the meaning of FUNCTION and the semantics of
function application is ambiguous in CLtL. In the definition of
*applyhook* on pg. 322, it says
"When a function is about to be applied to a list of arguments, no
attempt is made to apply the function. Instead, the hook function is
invoked and is passed the function and the list of arguments as its
first and second arguments."
The naive reader (me) would assume that given a function call such as
(foo 1. 2. 3.)
that the apply hook function's first arg would be FOO and second arg
would be (1. 2. 3.). Such is not the case in VaxLisp (nor in
SCL). Instead, the first arg is FOO's function definition!
I admit that it is not clear from the above definition whether or not
"function" refers to "function name" (i.e., a symbol or a lambda
expression) or function definition (i.e., the thing associated with
the function name). But I do think that it is strongly implied that
the function name should be used, for the following reasons:
An implementation that passed the function definition to the apply
hook function would not be able to handle
(xyttdf 1.2. 3.)
where XYTTDF has no function definition. Instead of passing XYTTDF to
the apply hook function so that it can figure out what to do, it will
signal an error. I thought one of the uses of applyhook was to be
able to experiment with different ways of defining functions, for
example, funcalling an undefined function returns a continuation to be
evaled later when it has a definition.
Also, giving the apply hook function the function definition of a
function makes it useless as a way of overriding the functional
interpretation of a symbol, which I would assume is one of the primary
purposes of the apply hook. All the apply hook function sees is some
functional object (that may well be implementation dependent). It
can't find out the name that was actually used in the function call.
Finally, I believe the whole point of the ENV arg to APPLYHOOK is to
handle
(flet ((frab (a b) (+ a b)))
(frab 1 2))
so that the apply hook function is given three args: FRAB, (1 2), and
an env that contains a definition for FRAB. Without requiring that
the first arg to the apply hook function be the function name, then
the ENV arg to APPLYHOOK IS meaningless. Rather than being a typo., I
think it is more likely that the first arg to APPLYHOOK may be the
NAME of a function like FRAB above.
I think the apply hook stuff is in need of clarification in one
direction or the other, and I vote that it deal with function names as
opposed to function definitions.
-- Nick