Reading (for next class): PLP, Sections 3.5 and 3.6.1
For this homework, you should refer to (and download) the
C program ob.c
and the Scheme program ob.scm.
Draw the scope tree for the
Scheme program ob.scm. You don't have
to draw any empty scopes (i.e., scopes with no bindings in them).
(Hint: scoping is by parentheses, and local name declarations
all use the define keyword.)
Run the Scheme program ob.scm in DrScheme. What value is produced?
Download and compile the C program ob.c,
either by typing make ob (no Makefile required!!)
or, more directly, with gcc -o ob ob.c. Then run the
program by typing ./ob. What value is produced?
These programs seem to be identical in their semantics, although
of course the syntax of C and Scheme are different. Both of these languages
also use lexical scope. So why do you think they produce different
values? (Hint: think about declaration order.)
Material contained above is made available
for the purpose of peer review and discussion and does not
necessarily reflect the views of the Department of the Navy or the
Department of Defense.
Some links above are to sites that are not
located at the United States Naval Academy. The USNA is not
responsible for the content found on these sites. In addition, the
content of these sites does not reflect the opinions, standards,
policy or endorsement of the Naval Academy or the United States