Question: Extend the Funclang programming language from problem 6.9.1 to implement a substitution-based variation of the call expression (say [ ] expression). Recall that a substitution-based

Extend the Funclang programming language from problem 6.9.1 to implement a substitution-based variation of the call expression (say [ ] expression). Recall that a substitution-based semantics works as follows. The value of [ (lambda (x y) (+ x y)) 3 4] is the value of a new expression created from the original function body (+ x y) by replacing x with 3 and y with 4. According to substitution-based semantics, the value of the call expression is the value of (+ 3 4), which is 7.

The grammar of this new language feature should be exactly the same as the grammar of the call expression in the Funclang language, except for the syntax [ ].

Implement substitution as a subst method for each AST node, such that given a list of variable names and a list of values, the subst method returns a copy of the current AST node with each free variable name substituted for the corresponding value.


Problem 6.9.1

Optimize the function call semantics by reducing the size of the environment saved in FunVal so that it contains only mappings from free variables in the function body to their bindings in the current environment.

Step by Step Solution

3.30 Rating (144 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To extend the Funclang programming language to implement a substitutionbased variation of the call e... View full answer

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 An Experiential Introduction To Principles Of Programming Languages Questions!