Given the following (arbitrary language, although I think it is close to Algol 60) 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 trace the values of variables throughout the program when it is interpreted using Dynamic scoping of free variables, when the arguments appearing in expressions  are evaluated left to right, and when they are evaluated right to left, so that the user can watch what happensI have created a JS plnkr for Static Scoping with Left to Right evaluation and another for Static Scoping with Right to Left evaluation.Feel free to adapt these answers (if possible) for Dynamic Scoping, with L->R and R->L evaluation.I chose plnkrs because I knew I could get the Static/lexical side using JS, but am unsure of how to make it happen dynamically or in another interactive environment (preferably not one I have to install).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, as the book examples are really bad.  In the code above, it also gets challenging, because it appears that the variable i in line 2 is allocated, but would be undefined.   But that may be my imperative/functional brain making it more complicated than it is...
Interactive example of Dynamic scoping and evaluation order of expressions
programming languages;programming paradigms;variable binding