Consider the runtime stack below. For each activation record, only the name of the function and
the nesting link are shown.
-----------
--------| f5 |
| | |
| -----------
| ---- | f4 |
| | | |
| | -----------
| ---> | f3 |
| ---- | |
| | -----------
| | -- | f2 |
| | | | |
| | | -----------
| | -> | f1 |
| ----> | |
| -- | |
| | -----------
| | | outer |
| ---> | env |
------> | |
Assume the language uses static scoping in answering the questions below.
- From the stack you can tell some things about the nesting levels of the functions. What do you know about the relationship (be as specific as possible)
between
- level(f1) and level(f2)
- level(f1) and level(f3)
- level(f1) and level(f4)
- level(f1) and level(f5)
- Some of these functions could have been passed as parameters. Given
the nesting links shown, did any of them have to be passed as a parameter?
Explain.
- Write a program in ML that would produce this stack at some point during its execution. The program need not
be meaningful (e.g., each function can just call another function without "doing" anything).