Swap by name
Ben Cranston
zben at umd5.UUCP
Mon Jul 7 08:49:08 AEST 1986
In article <1964 at brl-smoke.ARPA> rbj at icst-cmr.ARPA (Root Boy Jim) writes:
...
> I was thinking of the caller squirrelling away the value in a temporary
> location, passing it by reference (thus allowing modification by the
> callee) and then copying the result to the real variable.
Of course the difference between this and real call-by-name comes when
the subroutine has an alternate access to the global in question - perhaps
because of scoping rules, or access to a pointer-to-it or something.
In real call-by-name the data item would change as soon as the parameter
is modified by the subroutine. In the proposed scheme the transfer does
not take place until the subroutine returns.
> ... Univac's PLUS compiler. It stored its arguments directly
> into the callee's statically declared variables and grabbed the results
> after the callee returned. Ask zben at umd[25] about this if you care.
Well, since Plus was to be written in Plus there was the old bootstrap
problem. The solution taken was to hack beat and fiddle an existing
Jovial [1] compiler to be the Plus compiler. The stuff-into-callee's
static-data-area scheme Jim refers to was inherited from the old code.
He's also been away from things awhile - Plus Plus (the second generation
compiler) has been here for years now, and it uses a slightly more
conventional scheme - the arguments are built on the end of the data stack
and in the process of calling the subroutine the stack pointer is pushed
just enough to make the arguments the first N locals of the called routine.
Perhaps my usage of "stack pointer" is unusual here - the 1100 does not
have any builtin stack so stacks must be implemented with index registers.
What I called "stack pointer" here is what many people call "frame pointer".
[1] Jules schwartz's Own Version of the International Algebraic Language
Or some YABA [2] like that...
[2] Yet Another (questioned parentage) ALGOL...
Cheers
--
umd5.UUCP <= {seismo!umcp-cs,ihnp4!rlgvax}!cvl!umd5!zben
Ben Cranston zben @ umd2.UMD.EDU Kingdom of Merryland Sperrows 1100/92
umd2.BITNET "via HASP with RSCS"
More information about the Comp.lang.c
mailing list