Information Technology Reference
In-Depth Information
with its associated (linear) formal execution tree generated by successive appli-
cations of the static scope copy rule:
|
{
{
}
proc q'(r', s')
print(true)
}
p(q', false)
|
|
{ proc q''(r'',s'') { print(false) }
q'(q'', false) }
|
|
{ print(true) }
We use primes ' , '' , ... to indicate the necessary renamings of identifiers. This
formal execution tree consists of four incarnations constituting the nodes of the
tree (the main program's incarnation is contributing also). The final call q'(q'',
false) which generates the fourth incarnation is bound to the procedure declara-
tion q' in the second incarnation; the primes of q' , q'' are indicating static point-
ers SV . If program π 2 would really satisfy the “most recent” -property, as Dijkstra
claims, then q' should be bound to procedure q'' in the third incarnation.
If we would apply the copy rule without any renamings we would perform so
called dynamic binding or scoping. Then in fact the final call q(q, false) would
be bound to the most recent procedure declaration q in the third incarnation.
Then false would be printed, which is quite different from the static scope
result true .
The type τ p q f and τ r of p , q , f and r is an infinite procedure type, solves
thetypeequation
τ = proc ( τ, bool )
and is equal to
proc(proc(...,bool),bool)
whereas τ q and τ s are equal to bool . But infinity of procedure types is by no
means the source of the “most recent” -error. Look at the following Pascal-like
program π 3
{
proc q(s)
proc p(f,g)
{
print(g)
}
if g
then p(q, false)
else f(false)
fi
}
proc h(i)
{}
p(h, true)
Search WWH ::




Custom Search