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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!