Skip to content

Commit 0809867

Browse files
committed
Fix call-by-need mentions, add another example
1 parent 2d65148 commit 0809867

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

www/midterms/2.scrbl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ Consider the following example:
168168

169169
In standard call-by-value, this will read a byte from standard input,
170170
and proceed to call @tt{f} with that read value, ignore it, and return
171-
42. In call-by-need, this program will not read any value from the
171+
42. In call-by-name, this program will not read any value from the
172172
standard input - the @tt{read-byte} will never be evaluated, as the body
173173
of @tt{f} does not make use of @tt{x}.
174174

@@ -183,7 +183,7 @@ On the other hand, consider the following program:
183183

184184
Again, in standard call-by-value, this will read a byte from standard
185185
input, and proceed to call @tt{f} with that read value, doubling it.
186-
In call-by-need, this program will result to two different calls to
186+
In call-by-name, this program will result to two different calls to
187187
@tt{read-byte}, whose results will then be added together: when
188188
calling @tt{(f (read-byte))}, the argument will be substituted into
189189
the body of @tt{f}, yielding @tt{(+ (read-byte) (read-byte))}.
@@ -220,6 +220,15 @@ each occurence of @tt{y} in the body of f.
220220

221221
This program should yield an error - we're still using static scoping!
222222

223+
@#reader scribble/comment-reader
224+
(racketblock
225+
(begin
226+
(define (f x) (let ((y 42)) x))
227+
(let ((y 17)) (f y)))
228+
)
229+
230+
This program should yield 17, in both evaluation methods.
231+
223232
@#reader scribble/comment-reader
224233
(racketblock
225234
(begin

0 commit comments

Comments
 (0)