v3 Semantics: Nested Functions
Lesson, slides, and applied problem sets.
View SlidesLesson
v3 Semantics: Closures and Const Function Bindings
Why this module exists
With nested functions and new data structures, we still need clear, predictable rules. The analyzer enforces scoping and const rules while allowing lexical capture.
1) Scopes and closures
Nested functions can reference variables from outer scopes. The analyzer should allow this and treat it as valid lexical capture.
2) Core rules
We enforce:
- No duplicate declarations in the same scope
- Names must be declared before use
constmust have an initializer- Assignment to
constis an error returnonly inside a function- Function declarations behave like const bindings
Calls remain dynamic; only direct identifier calls are checked for existence and arity.
3) Dynamic types
The language is dynamically typed. The analyzer does not check types.