Phillip Helbig asked:
> Can someone (re)state the rationale behind this?
> I am finding this increasingly annoying.
> I have a subroutine which has several dummy arguments, including a
> procedure name. Fine. I have a function which I want to pass as an
> actual argument to another subroutine. Fine. This function uses some
> of the arguments of the initial subroutine. It would seem natural to
> make this function internal to the first subroutine, so that it can
> access the needed arguments through host association. However, if I do
> this, I cannot pass it as an actual argument to the second subroutine....
The problem is that if a procedure that is internal to a recursive host
is passed as an actual argument, which instance of its host is used for
host associated entities when the procedure is invoked by way of the
dummy argument? The instances might be different if the argument is passed
to or through a recursive invocation of its host. The one that's usually
considered to be more useful is the one in effect at the instant the
internal procedure was bound as an actual argument, not the one at the
instant the dummy argument is eventually used to call the procedure.
Unfortunately, the former one (the one usually considered to be more
useful) requires passing extra junk in the calling sequence -- that is,
a pointer to the correct instance of the host environment, as well as
the procedure entry point. This is called "deep binding". The simper
one, called "shallow binding" just requires that each procedure keep
a stack of pointers to its activation records.
The up-link is entirely unnecessary in the non-recursive case, and, in
fact is unnecessary in the case the the host procedure has no dummy
procedure arguments, or even if it has dummy procedure arguments with
explicit interfaces that are incompatible with the internal procedure.
There was a proposal at the February 1997 J3/WG5 meeting, the last meeting
at which proposals for functionality were accepted, to allow internal
procedures of nonrecursive hosts to be passed as actual arguments, but
it didn't make the priority cutoff.
There was, however, a remark inserted in Annex C that if a processor
implements the ability to pass internal procedures as actual arguments,
then deep binding should be used to determine the correct instance of
the host environment.
I hope this answers Phillip's question.
Best regards,
Van Snyder
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|