CSC302 2006S, Class 15: Scheme Semantics, Concluded Admin: * "Reading" Homework for Monday (please submit by 8 p.m. Sunday) * Find or write a good definition of "object-oriented programming" * Explain the diffence between polymorphism and overloading * Semantics homework coming soon * Issues of upcoming schedule * Next Friday: Sam at SIGCSE - Video * Following Friday: Freda turns 75 - Guest * Following Monday: Returning from Friday - Guest * Late: Dave, Mark Overview: * Notation and related issues * Hold, revisited * Function application * Lambda definitions * Other? Some issues in reading the semantics: * Makes a lot of use of continuations * What does it mean that we're building continuations, given a continuation as one of our parameters? * It means we're building things *backwards* - We have the continuation for the current expression (or statement) and are generating the continuation for the previous expression * "Obvious" from the last equation on p. 41 The joy of currying single takes a (E->C) as a parameter and returns a K K is a function \ psi . (\epsilon* . (something that computes a C)) \ psi epsilon* . (something that computes a C) Type of single single: (E->C) -> K single: (E->C) -> E* -> C If you provide single with one parameter, you get back a function that expects a sequence of expressed values If you provide single with two parameters, you get back a command continuation. Let's consider hold. * hold is used in the definition of the value of an identifier * We would expect to * Verify that the identifier is defined (conditioanl) * Find the location of the identifier (lookup) * Find the value stored in that location (hold) * Call that continuation on the value (maybe in the send?) * Shove it all into a continuation (extra baggage, eg. single) * How do we find the value stored in a location? * With a store * Where does the store come from? * From the expression continuation (E* -> S -> C) * hold must therefore help us get that store * hold receives: * a location * an expression continuation (what to do with the value we look up) * hold returns * a command continuation * hold : L -> K -> C * hold : L -> K -> S -> A * hold will need to look up the value in that store and call K on it hold = \ alpha kappa sigma -> send ((sigma alpha) select 1) kappa sigma Procedure call Form: (E0 E*) * Evaluate E0 and all of the other expressions (scriptE*) * Apply the function (applicate) * "Call" the continuation on the result * Build a new continuation Lambda: * Hidden assumption: Every call to (new sigma) returns the same value * We begin by attempting to allocate memory (for the return value?, for the function?) Expectation for a function call * Evaluate all the expressions (done in "procedure call") * Allocate memory locations for each formal (update the symbol table and the store) * Copy actuals into those memory locations * Evaluate the body using that new store and symbol table