An alternative to static binding is dynamic binding, in which the function body is evaluated in an

Question:

An alternative to static binding is dynamic binding, in which the function body is evaluated in an environment obtained by extending the environment at the function call point (instead of the environment at the function declaration point that is used for static binding).
Extend FungLang with a dynamic call expression that has the syntax ’(’ ’dynamic’ expr expr* ’)’. A dynamic call expression is evaluated using dynamic binding.
The following examples illustrate the difference between dynamic and static bindings during function calls. Consider the program here:image

The value of this program is 0. In the expression given here, variable a is bound to 3.
Now consider another version of the program that uses dynamic call expression:image

The value of this program is 2. Here, variable a is bound to 5.

Consider another program that uses static binding only:image

The value of this program is 6. Here, variable a is bound to 3.image

If the program used dynamic binding, since the variable a will be bound to 5, the value of this program will be 8.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: