I’m writing a simple parser/interpreter for a language. The instructions keep mentioning ‘deferred substitution’, as in
Extend the
funlanguage feature described so that functions
can accept a list of zero or more arguments instead of just one. All
arguments to the function must evaluate with the same deferred
substitutions.
I don’t need any help with implementing this, I’m just confused about what ‘deferred substitution’ means. Any thoughts?
Deferred substitution refers to the practice of substituting the values of variables at the latest step possible. By doing so, you are deferring the substitution of it!
Here’s an example that might help you understand what it means:
Suppose that you have the following function:
f(x) = 500 + 300 + 2x + 45x
Let’s say that x = 1
If you want to defer the substitution of x, you would probably do:
Notice that we have substituted the values of x at the latest step possible, after simplifying everything that is not a variable in this function.