Com S 641 meeting -*- Outline -*- * parameter lists (3.8) ** as tuples ------------------------------------------ PARAMETER LISTS (3.8) Traditional syntax: D ::= ... | define I(FL) = U FL ::= I:t | I:t , FL U ::= ... | invoke I(AL) AL ::= A | A , AL A ::= N | E | C | L Claim this is cumbersome to write type rules for. Let's see... ------------------------------------------ try it! (and no tricks like translating to records :-) ** using the correspondence principle ------------------------------------------ KEYWORD PARAMETERS By the correspondence principle, multiple arguments correspond to Keyword parameter syntax: D ::= ... | define I(F) = U F ::= I:t | F1 , F2 U ::= ... | invoke I( Example: var A: newint; proc P(W:int exp, X: int loc, Y: comm, Z: comm -> comm) = (X := W; call Z(Y)); proc Q = A := 0; in call P(fun W = @A+2, proc Y = call Q, alias X = A, proc Z(C:comm) = call C) ------------------------------------------ ... compound declarations ... D) Q: Why the use of alias to bind X? ------------------------------------------ TYPING RULES FOR KEYWORD PARAMETERS ------------------------------------------ ... pi' |- U:t ___________________ pi |- define I(F) = U {I:pi1 -> t} dec where pi' = pi unionMinus pi1 pi1 = typeAttrs(F) we define typeAttrs(I:t) = {I:t} typeAttrs(F1,F2) = typeAttrs(F1) unionDot typeAttrs(F2) pi |- D: pi1 dec ___________________ where (I:pi1 -> t) in pi pi |- invoke I(D): t ------------------------------------------ SEMANTICS FOR KEYWORD PARAMETERS ------------------------------------------ ... [[pi |- define I(F) = U: {I:pi1 -> t} dec]] e s = ({(I,p)}, s) where p e1 s1 = [[pi unionMinus pi1 |- U:t]](e unionMinus e1) s1 pi1 = typeAttrs(F) [[invoke I(D):t]]e s = p e1 s1 where (e1, s1) = [[pi |- D: pi1 dec]] (I,p) in e Q: How can we tell if parameters are done lazily or not? by the semantics of the declarations Q: Does this make the correspondence principle hold? yes, it forces it ** another alternative: product types ------------------------------------------ PRODUCT OR TUPLE TYPES As in ML, Haskell, ... D ::= ... | define I(F) = U F ::= I:t U ::= ... | invoke I(A) A ::= N | E | C | L t ::= ... | () | (TL) TL ::= t | t , TL ------------------------------------------ ... E ::= ... | () | EL EL ::= E | E , EL Q: What would the typing rules be? Q: How is this different than passing records? Q: What's the relation between passing records and keyword parameters? Also discuss the syntactic ambiguity between the tuple (1) and the number (1) in parentheses. In Haskell and ML, only allow tuples with 0, or 2 or more elements.