Monday, January 19, 2009

Ch2, Ex7

Translating given program to closer to kernel code
declare Max3 Max5
proc {SpecialMax Value ?SMax}
proc {SMax X ?R}
if X>Value then R=X else R=Value end
end
end
% *value = 3* in contextual environment of this
% resulting proc
{SpecialMax 3 Max3}
% *value = 5* in contextual environment of this
% resulting proc
{SpecialMax 5 Max5}


Ans: [4 5] will be printed, its trivial to figure out now why (Hint: lexical scoping)

No comments:

Post a Comment