[Instructions] [Search] [Current] [Syllabus] [Links] [Handouts] [Outlines] [Assignments] [Labs]
In the Scheme semantics, there is a formal definition for the meaning of a standard lambda expression. Explain what that definition says (including any helper functions).
The standard lambda expression reads
E[[(lambda (I*) C* E0 ]] =
\ u k .
\ s
new s is in L then
send
(<
new s | L,
\ e* k' .
#e* = #I* then
tievals
(\ a* .
(\ u' . C[[C]] u' (E [[E0 ]] u' k'))
(extends u I* a*)
e*,
wrong ``wrong number of arugments''
> in E)
k
(update (new s | L) unspecified s),
wrong ``out of memory'' k
Taking it from the top:
Looking at it another way: the meaning of a lambda is a function. That function requires a space in memory. When executed the function verifies the number of arguments (with the comparison), maps its actual parameters to its formal parameters (thereby updating the environment with extends and the store with tievals), excecutes all the statements in its body (with C[[C*]]), executes the final expression (with E[[E0 ]]), and returns the value of that expression (calling the continuation on that expression).
As you may have noted, the definition of lambda relies on five helper functions:
It may help us to consider these last two methods.
Answer forthcoming.
The Scheme semantics provides a definition for E*, which provides a meaning for sequences of expressions. Explain the equations that define E* and note any interesting implications.
What do we learn from all this?
A number of the helper functions from the Scheme semantics, such as cwcc, don't seem to appear in the definitions of the various meaning functions. List as many of these helper functions as you can, and explain why the semantics includes them.
Here are some of them: list, cons, less, add, car, cdr, setcar, eqv, apply, valueslist, cwcc, values, cwv
You will note that all of them have type E*
-> K -> C, which
is pretty close to the form of ``procedure values'' used in the
report. In fact, these are definitions for the built-in
procedures! cons
, car
, and the rest are
so fundamental to Scheme that there definitions are given formally.
The equation that gives the meaning of conditional (if) expressions uses a helper called truish. Explain the name and purpose of truish.
The truish function returns true if its argument is not false. This permits us to use a wide variety of values as arguments to conditionals, and tells us what happens in every case (``if it's not false, it's true''). Since this is an approximate true, and not a true true, we use ``trueish'' to make it clear that it's approximate.
Describe how the meaning of cond
statements is given by the Scheme
semantics, and what that meaning is.
The Scheme report uses macros to define cond
; eventually, it
is defined in terms of the core operations (lambda, if, and that ilk).
More details forthcoming.
[Instructions] [Search] [Current] [Syllabus] [Links] [Handouts] [Outlines] [Assignments] [Labs]
Disclaimer Often, these pages were created ``on the fly'' with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.
This page may be found at http://www.math.grin.edu/~rebelsky/Courses/CS302/99S/Assignments/notes.04.html
Source text last modified Wed Apr 7 16:37:30 1999.
This page generated on Wed Apr 7 16:43:38 1999 by SiteWeaver. Validate this page's HTML.
Contact our webmaster at [email protected]