CS 541 Lecture -*- Outline -*- ** Parameter Passing (Schmidt 8.2) advert: fundamental way that languages differ *** changes to domain equations for Naming from FL semantics why? Add more structure to the Expressible-value domain so can describe Denotable-value more easily Expressible-value = Result_{\bot} Result = Value + Error Error = Unit Value = Integer + Boolean + Procedure **** Clause for (proc I E) injects into Value ValE[[(proc I E)]] = \u . (inValue (inProcedure \d . ValE[[E]](extend-env u [[I]] d))) **** what happens to the other clauses? e.g., for ValE[[(A E1 E2)]] = \u . cases ValE[[E1]]u of isValue(v1) -> cases v1 of isInteger(n1) -> ... else isError() end else isError() end *** Pass by value (i.e., call by value): Denotable-value = Value arguments that yield errors must be handled specially *** Pass by name (closure): nonstrict errors and bottom must be nameable by idents Denotable-value = expressible-value recall that ValE is not the operational evaluation operator, just specifies mathematical meaning of program frag. so ident in environment cannot be evaluated before used in a real machine. *** Pass by denotation like pass by name, but use called proc's environment Denotable-value = Environment -> expressible-value gives dynamic scoping! look at: environments, when things get evaluated. Similar mechanisms? e.g., semantics of (value vs. name) (call (proc x 1) (/ 3 0)) by value = \u . cases valE[[(proc x 1)]]u of ... = \u . cases inValue( inProcedure(\d.valE[[1]](extend-env u [[x]] d))) of ... = \u . cases inValue(inProcedure(\d.1)) of isValue(v1) -> ... = \u . cases inProcedure(\d.1) of isProcedure(p) -> ... = \u . cases valE[[(/ 3 0)]] of ... [] isError() -> ... = \u . (inError ()) --- assuming division gives errors by name = \u . cases valE[[(proc x 1)]]u of ... = \u . cases inValue( inProcedure(\d.valE[[1]](extend-env u [[x]] d))) of ... = \u . cases inValue(inProcedure(\d.1)) of isValue(v1) -> ... = \u . cases inProcedure(\d.1) of isProcedure(p) -> ... = \u . ((\d.1) (valE[[(/ 3 0)]]u)) = \u . 1 e.g., work semantics of (name vs. denotation) (bind y 4 (call (proc x (bind y 3 (* y x)) y))) *** quiz (this is too much work... for in class) compute the denotations of (bind y 4 (call (proc x (bind y 3 (* y x))) y)) using (a) pass by name (b) pass by denotation