Question: Static vs. dynamic scope Consider the following expression written in a strict, call-by-value language with Haskell-like syntax: let y = let x = 2 in

 Static vs. dynamic scope Consider the following expression written in a

Static vs. dynamic scope Consider the following expression written in a strict, call-by-value language with Haskell-like syntax: let y = let x = 2 in 3 in let foo (\z -> let y = 10 in x + y + z) in let x = y + 2 in let y = x + 3 in let bar foo 20 in let x = 20 in bar = What is the result of evaluating the expression (i.e. the value bar) if the language uses static scoping? What is the result of evaluating the expression (i.e. the value bar) if the language uses dynamic scoping? How many declarations of a variable named "y" are there in this expression? How many references to a variable named "y" are there in this expression? Static vs. dynamic scope Consider the following expression written in a strict, call-by-value language with Haskell-like syntax: let y = let x = 2 in 3 in let foo (\z -> let y = 10 in x + y + z) in let x = y + 2 in let y = x + 3 in let bar foo 20 in let x = 20 in bar = What is the result of evaluating the expression (i.e. the value bar) if the language uses static scoping? What is the result of evaluating the expression (i.e. the value bar) if the language uses dynamic scoping? How many declarations of a variable named "y" are there in this expression? How many references to a variable named "y" are there in this expression

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!