Given the following [arbitrary language, although I think this is ALGOL] program:
program main; // A main parent level
var i : integer; // A 'global' variable
(* Note that all parameters are passed by value here *)
function f1 (j : integer) : integer; // A Child function
begin { f1 }
i := i + 3;
f1 := 2 * j - i;
end; { f1 }
function f2 (k : integer) : integer; // Another Child function, same level as f1
var i : integer; // Here, there is a variable that is declared
begin { f2 } // but no value assigned
i := k / 2;
f2 := f1(i) + f1(k);
end; { f2 }
begin { main } // Running/Calling/Executing the code
i := 8;
i := i + f2(i);
writeln(i);
end. { main }
How would you show the values throughout the program using Dynamic scoping in both directions (evaluating left to right and then evaluating right to left) using javascript, so I can interactively change the values and watch what happens?
I learn a bit slower on some problems like this where the values are asked of the output, but don't show the value states throughout the program, and trying to get a better understanding, especially in an example I can play around with interactively.
I have created a plnkr for Static Scoping Left to Right
and another for Static Scoping Right to Left
feel free to fork them interactive answers :).