CSC302 2011S, Class 30: Interpreting Procedure Calls Overview: * A Bit About Procedures. * Parameter Passing. * An Operatational Approach. * Jensen's Device. Admin: * Missing: AC, SA * We'll use about fifteen minutes at the start of class to talk about presentations. * Readings for Monday (links on the Web) Graham, Paul (2002). Revenge of the Nerds. Graham, Paul (2002). What Made Lisp Different. * Post questions on Piazzza! * EC for today's CS Table - Wolfram TED Talk [academic] * EC for tonight's Bob's Benefit Bash [peer] Presentations: * ARS - (Aaron, Russel, Shitanshu) Potential Topic: CPS * CAD - (Charles, Aditi, Dylan) Potential Topic: Software Transactional Memory (a model for concurrency) * JAC - (Jeff, Andy, Chase) Potential Topic: GC * Consanants (aka There weren't enough vowels to go around) (Terian, Denny, Josh) Potential Topic: Programming languages for beginners (Alice, Scratch, Hypercard, Kodu) - a design issue; * Nyah (Jesse, David, Xin) Potential Topic: Monads and similar abstraction The person who skipped class will decide what group it will join. Dates: * Fri week 12 (2011.04.29): JAC * Mon week 13 (2011.05.02): CAD * Wed week 13 (2011.05.04): ARS * Fri week 13 (2011.05.06): Nyah * Mon week 14 (2011.05.09): Consonants --- Procedures (aka Subroutines, Functions, Methods, Handlers) * "Encapsulated and parameterized code" * Four aspects that we normally look at * Signature / Declaration Gives name/parameters (types?)a * Definition / Implementation / Body * Call * Execution * Reminder: Use procedures for * Clarity * Concision * Checking * Calls, Recursive Issue: Relationship between actual parameters (in the call) and formal parameters (in the definition) Considerations: * When do actuals get evaluated? * Eager: Before control is passed to the procedure * Lazy: Only when the "value" is used within the procedure * do_something_with (sqrt(sqrt(sqrt(4)))) int do_something_with (x) return x + x/2 + x/4 + x/8 + x/16; * Do we copy over the value of the actual or do we pass a reference/pointer to the actual? * Do modifications to the formal affect the actual? Calling Strategy Value/Reference Affect? Eager/Lazy Call-by-value Value No Eager Call-by-reference Reference Yes Eager Call-by-sharing Value Yes Eager Call-by-value-return Value yes Eager Call-by-text (macro) ??? yes (if variable) Lazy Call-by-name (call-by-text with environment passing)