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

call by name call by value and the calculus
SMART_READER_LITE
LIVE PREVIEW

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)


slide-1
SLIDE 1

Call-by-name, call-by-value, and the λ-calculus

G.D. Plotkin Presented by Dietrich Geisler

slide-2
SLIDE 2

Call-by-name vs call-by-value

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

slide-3
SLIDE 3

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

slide-4
SLIDE 4

Objective

  • Transformation between CBV and CBN semantics
  • A CBV evaluation of a program P should terminate if and
  • nly if the CBN evaluation of the translated P also

terminates

slide-5
SLIDE 5

Previous Papers: Recursive Functions (1960) Axiomatic Basis (1969) Abstraction (1983) Expressive Power of PLs (1990)

Some Context

Published in 1975

Higher-level languages: C 1972 Scheme 1973 ML 1975

slide-6
SLIDE 6

Practicalities

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

slide-7
SLIDE 7

The λv Calculus

slide-8
SLIDE 8

Equality of terms

M=N iff M is equivalent to N

slide-9
SLIDE 9

Reduction of terms

M≥N iff M reduces to something equal to N

slide-10
SLIDE 10

The λn Calculus

No requirement that N is a value

slide-11
SLIDE 11

Translating from CBN to CBV

(λxy.y) Ω z

slide-12
SLIDE 12

Translating from CBN to CBV

(λxy.y Ω) z