= Solution
Continue the instruction convention above. The current <stack frame> is now `s`'s. Its <static chain> passes through `r` to `p`; `q` is declared directly inside `p`, so the new `q` activation must receive a <static link> to that same `p` <stack frame>. Let `T` be the offset of `p`'s parameter `t`.
Define `CALL q,1` to expect, above the pre-existing evaluation <stack>, the <static link> for `q` followed by its one argument. It consumes these, creates `q`'s <stack frame> with its <dynamic link> pointing to the current `s` activation, and leaves one return value when `q` returns. This explicit convention avoids dependence on a particular real <instruction set architecture>.
``
PUSHFP ; s
LOAD SL ; r
LOAD SL ; p, the required static parent of q
DUP ; preserve p for CALL while also using it to read t
LOAD T ; replace the duplicate p address by p.t
CALL q,1 ; q(p.t), with static parent p and dynamic caller s
RETVAL ; return q's result from s to r
``
Immediately before `CALL`, the evaluation <stack> ends in `p-frame, 3`. \b[Two <static link> traversals find both the argument's environment and the environment to pass to `q`.] In terms of the hidden argument and ordinary argument,
$$
\boxed{\mathrm{SL}_{q}=\mathrm{frame}_{p},\qquad y=t=3.}
$$
An implementation that places the hidden <static link> after the ordinary argument could use a different ordering of these same operations.
Back to article page