call by name call by value and the calculus
play

Call-by-name, call-by-value, and the -calculus G.D. Plotkin - PowerPoint PPT Presentation

Call-by-name, call-by-value, and the -calculus G.D. Plotkin Presented by Dietrich Geisler Call-by-name vs call-by-value Define square = xy.x*x Evaluate square(2+2, 2+3) Call-by-name (CBN) Call-by-value (CBV) square(2+2, 2+3)


  1. Call-by-name, call-by-value, and the λ-calculus G.D. Plotkin Presented by Dietrich Geisler

  2. Call-by-name vs call-by-value Define square = λxy.x*x Evaluate square(2+2, 2+3) Call-by-name (CBN) Call-by-value (CBV) square(2+2, 2+3) square(2+2, 2+3) (2+2)*(2+2) square(4, 2+3) 4*(2+2) square(4, 5) 4*4 4*4 16 16

  3. Termination under CBN but not CBV Ω = (λx.xx) (λx.xx) CBN CBV (λxy.y) Ω z (λxy.y) Ω z λy.y z (λxy.y) Ω z z ...

  4. Objective ● Transformation between CBV and CBN semantics ● A CBV evaluation of a program P should terminate if and only if the CBN evaluation of the translated P also terminates

  5. Some Context Published in 1975 Previous Papers: Higher-level languages: Recursive Functions (1960) C 1972 Axiomatic Basis (1969) Scheme 1973 ML 1975 Abstraction (1983) Expressive Power of PLs (1990)

  6. Practicalities <S, E, C, D> machine Machine for evaluating lambda expressions Constapply(a, b) Mechanism for syntactic sugar

  7. The λ v Calculus

  8. Equality of terms M=N iff M is equivalent to N

  9. Reduction of terms M≥N iff M reduces to something equal to N

  10. The λ n Calculus No requirement that N is a value

  11. Translating from CBN to CBV (λxy.y) Ω z

  12. Translating from CBN to CBV (λxy.y Ω) z

Recommend


More recommend