Question: Consider the following program fragment, written in a language with dynamic scoping. var tag = span; function block(s){ return [ + tag + ] +
Consider the following program fragment, written in a language with dynamic scoping.
var tag = "span"; function block(s){ return "[" + tag + "]" + s + "[/" + tag + "]"; } function print_string(s, func){ var tag = "pre"; console.log(func(s)); //Prints the returned value of func(s) } function page(){ var tag = "div"; print_string("t-rex", block); } page();
What does this program print if the language uses:
a) Deep binding.
b) Shallow binding.
c) Ad-hoc binding.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
