-
Notifications
You must be signed in to change notification settings - Fork 133
Description
I'm considering a rather drastic step, after having written https://source-academy.github.io/chapters/3.2.4.html#p2
I think this is an unnecessary complication. It would be cleaner to treat the body of functions simply as blocks. Then the issue in 3.2.4 shifts in the right direction: What is the semantics of a block? This way, we would not have to revise the core of the environment model in 3.2.4. This would also simplify 4.1 quite a bit and would eliminate the issue addressed by https://source-academy.github.io/chapters/4.1.7.html#ex_4.22
This would be a significant change, and I would tackle the writing first.
To illustrate the issue:
In this proposal, E1 would be split into two frames: one for x and one for the body block (good_enough etc).
Strictly speaking, this would be a deviation from JavaScript: JavaScript clearly distinguishes the body of functions from regular blocks. For example, it prevents a re-declaration of a parameter in the body. Such a re-declaration would be perfectly fine if the body of functions would be blocks. In this proposal, I'm suggesting to simply add a footnote that adds the restriction that function bodies may not redeclare parameters. Or we could just ignore the issue in the textbook and just include it in the Source specifications.
What do you think @TobiasWrigstad ?
