You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lexicalscoping.md
+13-10Lines changed: 13 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -146,19 +146,22 @@ x <<- 42 # assigns the value 42 to variable `x` in the containing environme
146
146
Perhaps the crude graphic can illuminate the effects of lexical scoping on variables a better than mere words.
147
147
```
148
148
+———————————+
149
-
| (1a) x <- 0 becomes 42 | outer function / by default the global lexical scope is an anonymous function
150
-
| (1b) x <- 42 by |
151
-
| (3b) x <<- 42 |
152
-
| +—————————–+ |
153
-
| | (2) x <- 3.14 | | inner function
154
-
| | (3a) x <<- 42 does | |
155
-
| | not affect | |
156
-
| | (2) | |
157
-
| +—————————–+ |
149
+
| (1a) x <- 0 becomes 42
150
+
| outer function / by default the global lexical scope is an anonymous function
151
+
| (1b) x <- 42 by
152
+
|
153
+
| (3b) x <<- 42
154
+
|
155
+
| +—————————–+
156
+
| | (2) x <- 3.14
157
+
| | inner function
158
+
| | (3a) x <<- 42 does not affect (2)
159
+
| |
160
+
| +—————————–+
158
161
+———————————+
159
162
```
160
163
161
-
Flow of execution is (1a) -> [(2) & (3a)] -> [(3b) & (1b)] -> (1a). I used the labels “inner function” and “outer function” because the same rules apply to nested functions.
164
+
Flow of execution is `(1a) -> [(2) & (3a)] -> [(3b) & (1b)] -> (1a)`. I used the labels “inner function” and “outer function” because the same rules apply to nested functions.
162
165
163
166
## Unit tests (with expected output) for Programming Assignment 2
0 commit comments