the meaning of multilanguage programsjacobm/papers/multilang/earth-vs-m… · the meaning of...
TRANSCRIPT
![Page 1: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/1.jpg)
The Meaning of Multilanguage Programs
Jacob [email protected]
University of Chicago
Robby [email protected]
University of Chicago
1
![Page 2: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/2.jpg)
2
![Page 3: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/3.jpg)
3
![Page 4: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/4.jpg)
4
![Page 5: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/5.jpg)
5
![Page 6: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/6.jpg)
6
![Page 7: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/7.jpg)
7
![Page 8: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/8.jpg)
8
![Page 9: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/9.jpg)
9
![Page 10: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/10.jpg)
10
![Page 11: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/11.jpg)
11
![Page 12: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/12.jpg)
12
![Page 13: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/13.jpg)
13
![Page 14: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/14.jpg)
How do languages vary?
14
![Page 15: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/15.jpg)
How do languages vary?
differing type systems15
![Page 16: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/16.jpg)
How do languages vary?
differing evaluation rules16
![Page 17: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/17.jpg)
How do languages vary?
differing values17
![Page 18: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/18.jpg)
How do languages vary?
This talk: differing type systems18
![Page 19: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/19.jpg)
How do languages vary?
This talk: differing evaluation rules (a little)19
![Page 20: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/20.jpg)
How do languages vary?
This talk: differing values (a very little)20
![Page 21: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/21.jpg)
e := v | (e e) | (+ e e)v := (! (x) e) | number
C := [] | (v C) | (e C)
C[((! (x) e) v)]"C[e [x := v]]C[(+ n1 n2)]"C[n1+n2]
Scheme
21
![Page 22: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/22.jpg)
e := v | (e e) | (+ e e)v := (! (x : #) e) | number# := int | (# " #)
C := [] | (v C) | (C e)
C[((! (x : #) e) v)]"C[e [x := v]]C[(+ n1 n2)]"C[n1+n2]
ML
22
![Page 23: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/23.jpg)
n $ {0 1 2 ...}% n : int MLNUM
x : # $ %
% x : # MLVAR
[x := #A] + % e : #B
% (! (x : #A) e) : #BMLFUN
% e1 : #1"#2 % e2 : #1
% (e1 e2) : #2MLAPP
% e1 : int % e2 : int% (+ e1 e2) : int MLSUM
ML type system
23
![Page 24: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/24.jpg)
n $ {0 1 2 ...}% n : TST SNUM
x : TST $ %
% x : TST SVAR
[x := TST] + % e : TST% (! (x) e) : TST SFUN
% e1 : TST % e2 : TST% (e1 e2) : TST SAPP
% e1 : TST % e2 : TST% (+ e1 e2) : TST SSUM
Scheme type system
24
![Page 25: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/25.jpg)
The big question:How do we put them together?
25
![Page 26: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/26.jpg)
The big question:How do we put them together?
26
![Page 27: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/27.jpg)
The big question:How do we put them together?
Method 1: lump embedding
27
![Page 28: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/28.jpg)
28
![Page 29: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/29.jpg)
29
![Page 30: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/30.jpg)
30
![Page 31: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/31.jpg)
Anatomy of a Boundary
(MS # TST e)An ML boundary
31
![Page 32: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/32.jpg)
Anatomy of a Boundary
(MS # TST e)"ML outside, Scheme inside"
32
![Page 33: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/33.jpg)
Anatomy of a Boundary
(MS # TST e)The Scheme expression to run
33
![Page 34: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/34.jpg)
Anatomy of a Boundary
(MS # TST e)The ML side's type
34
![Page 35: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/35.jpg)
Anatomy of a Boundary
(MS # TST e)The Scheme side's type
35
![Page 36: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/36.jpg)
Anatomy of a Boundary
(MS # e)... which isn't necessary to write down
36
![Page 37: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/37.jpg)
Anatomy of a Boundary
(SM TST # e)A Scheme boundary
37
![Page 38: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/38.jpg)
Anatomy of a Boundary
(SM TST # e)The Scheme side's type
38
![Page 39: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/39.jpg)
Anatomy of a Boundary
(SM # e)... which isn't necessary to write down
39
![Page 40: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/40.jpg)
Anatomy of a Boundary
(SM # e)The ML side's type
40
![Page 41: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/41.jpg)
e := v | (e e) | (+ e e) | (SM # e)v := (! (x) e) | number
New Scheme grammar
41
![Page 42: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/42.jpg)
e := v | (e e) | (+ e e) | (MS # e)v := (! (x : #) e) | number# := int | (# " #) | TST
New ML grammar
42
![Page 43: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/43.jpg)
(+ (MS int 3) 4)'shouldbe error
43
![Page 44: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/44.jpg)
(+ (MS int 3) 4)'shouldbe error
(+ (MS int (SM int 3)) 4)'shouldbe 7
44
![Page 45: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/45.jpg)
(+ (MS int 3) 4)'shouldbe error
(+ (MS int (SM int 3)) 4)'shouldbe 7
(+ (MS int ((! (x) x) (SM int 3))) 4)'shouldbe 7
45
![Page 46: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/46.jpg)
(+ (MS int 3) 4)'shouldbe error
(+ (MS int (SM int 3)) 4)'shouldbe 7
(+ (MS int ((! (x) x) (SM int 3))) 4)'shouldbe 7
(+ (MS int ((! (x) x) (SM (int " int) F))) 4)'shouldbe error
46
![Page 47: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/47.jpg)
(+ (MS int 3) 4)'shouldbe error
(+ (MS int (SM int 3)) 4)'shouldbe 7
(+ (MS int ((! (x) x) (SM int 3))) 4)'shouldbe 7
(+ (MS int ((! (x) x) (SM (int " int) F))) 4)'shouldbe error
(+ (MS int ((! (x) x) (SM int (! (x : int) x)))) 4)'shouldbe Type error!
47
![Page 48: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/48.jpg)
C := [] | (v C) | (C e) | (MS # C)
C[((! (x : #) e) v)]"C[e [x := v]]C[(+ n1 n2)]"C[n1+n2]
New ML reductions
48
![Page 49: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/49.jpg)
C := [] | (v C) | (C e) | (SM # C)
C[((! (x) e) v)]"C[e [x := v]]C[(+ n1 n2)]"C[n1+n2]
New Scheme reductions
49
![Page 50: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/50.jpg)
How do we know what reduction to use?
C[(+ 1 2)]
C[(+ n1 n2)]"C[n1+n2]C[(+ n1 n2)]"C[n1+n2]
50
![Page 51: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/51.jpg)
How do we know what reduction to use?
C[(+ 1 2)]
C[(+ n1 n2)]"C[n1+n2]C[(+ n1 n2)]"C[n1+n2]
51
![Page 52: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/52.jpg)
How do we know what reduction to use?
C[(+ 1 2)]
C := [] | (v C) | (C e) | (SM # C)C := [] | (v C) | (C e) | (MS # C)
C[(+ n1 n2)]"C[n1+n2]C[(+ n1 n2)]"C[n1+n2]
52
![Page 53: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/53.jpg)
n $ {0 1 2 ...}% n : int MLNUM
x : # $ %
% x : # MLVAR
[x := #A] + % e : #B
% (! (x : #A) e) : #BMLFUN
% e1 : #1"#2 % e2 : #1
% (e1 e2) : #2MLAPP
% e1 : int % e2 : int% (+ e1 e2) : int MLSUM
% e : TST% (MS # e) : # MLBOUNDARY
New ML type system
53
![Page 54: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/54.jpg)
n $ {0 1 2 ...}% n : TST SNUM
x : TST $ %
% x : TST SVAR
[x := TST] + % e : TST% (! (x) e) : TST SFUN
% e1 : TST % e2 : TST% (e1 e2) : TST SAPP
% e1 : TST % e2 : TST% (+ e1 e2) : TST SSUM
% e : #% (SM # e) : TST SBOUNDARY
New Scheme type system
54
![Page 55: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/55.jpg)
Packing and unpacking values
v := (! (x) e) | number | (SM #' v)v := (! (x : #) e) | number | (MS TST v)Where #' = #- {TST}
C[(MS #' (SM #' v))] " C[v]C[(MS #' v)] " Error
55
![Page 56: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/56.jpg)
Packing and unpacking values
v := (! (x) e) | number | (SM #' v)v := (! (x : #) e) | number | (MS TST v)Where #' = #- {TST}
C[(MS #' (SM #' v))] " C[v]C[(MS #' v)] " Error
C[(SM TST (MS TST v))] " C[v]
56
![Page 57: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/57.jpg)
Packing and unpacking values
v := (! (x) e) | number | (SM #' v)v := (! (x : #) e) | number | (MS TST v)Where #' = #- {TST}
C[(MS #' (SM #' v))] " C[v]C[(MS #' v)] " Error
C[(SM TST (MS TST v))] " C[v]C[(SM TST v)] " Won't typecheck!
57
![Page 58: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/58.jpg)
(+ (MS int ((! (x) x) (SM int 3)))4)
58
![Page 59: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/59.jpg)
(+ (MS int ((! (x) (x x))
(! (x) (x x))))4)
59
![Page 60: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/60.jpg)
Aside (#1):What if there were no Earth?
60
![Page 61: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/61.jpg)
61
![Page 62: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/62.jpg)
62
![Page 63: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/63.jpg)
63
![Page 64: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/64.jpg)
; H (hide) : (TST -> TST) -> TST(define H (! (a : (TST -> TST))
(MS TST (! (x) (SM (TST -> TST) a))))); U (unhide) : TST -> (TST -> TST)(define U (! (a : TST)
(MS (TST -> TST) ((SM TST a) 1))))
( (! (x : TST) ((U x) x)) (H (! (x : TST) ((U x) x))))
64
![Page 65: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/65.jpg)
; H (hide) : (TST -> TST) -> TST(define H (! (a : (TST -> TST))
(MS TST (! (x) (SM (TST -> TST) a))))); U (unhide) : TST -> (TST -> TST)(define U (! (a : TST)
(MS (TST -> TST) ((SM TST a) 1))))
( (! (x : TST) ((U x) x)) (H (! (x : TST) ((U x) x))))
65
![Page 66: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/66.jpg)
Theorem:A lump-embedding program that typechecksnever goes wrong
66
![Page 67: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/67.jpg)
Less formal theorem:A lump-embedding program that typechecksnever does anything useful
67
![Page 68: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/68.jpg)
Back to the big question:How else can we put them together?
68
![Page 69: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/69.jpg)
Back to the big question:How else can we put them together?
Method 2: natural embedding
69
![Page 70: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/70.jpg)
70
![Page 71: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/71.jpg)
71
![Page 72: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/72.jpg)
72
![Page 73: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/73.jpg)
Convert equals for equals
(MS int 4)'shouldbe 4
73
![Page 74: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/74.jpg)
Convert equals for equals
(MS int 4)'shouldbe 4
((MS (int -> int) (! (x) x)) 2)'shouldbe 2
74
![Page 75: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/75.jpg)
Convert equals for equals
(MS int 4)'shouldbe 4
((MS (int -> int) (! (x) x)) 2)'shouldbe 2
(MS int (! (x) x))'shouldbe error
75
![Page 76: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/76.jpg)
Convert equals for equals
(MS int 4)'shouldbe 4
((MS (int -> int) (! (x) x)) 2)'shouldbe 2
(MS int (! (x) x))'shouldbe error
(SM int (! (x : int) x))'shouldbe type error
76
![Page 77: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/77.jpg)
How?
(MS int 4)" 4
77
![Page 78: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/78.jpg)
How?
(MS int 4)" 4
(MS (int -> int) (! (x) x))" (! (x : int) x)
78
![Page 79: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/79.jpg)
How?
(MS int 4)" 4
(MS (int -> (! (x) x)))" (! (x : int) x)
79
![Page 80: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/80.jpg)
How?
(MS int 4)" 4
(MS (int -> int) (! (x) x))"
(! (x : int) (MS int ((! (x) x) (SM int x))))
80
![Page 81: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/81.jpg)
How?
(MS int 4)" 4
(MS (int -> int) (! (x) x))"
(! (x : int) (MS int ((! (x) x) (SM int x))))
But what if the Scheme code doesn't produce an int?
81
![Page 82: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/82.jpg)
Even worse:
(! (x : int) (MS (int -> int)
((! (a) (! (b) (! (c) c)))(MS int x))))
What if ML can't immediately tellthat something is wrong?
82
![Page 83: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/83.jpg)
(MS ((int -> int) -> (int -> int)) F)
"
(! (x : (int -> int)) (MS (int -> int)
(F (SM (int -> int) x))))
83
![Page 84: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/84.jpg)
(MS ((int -> int) -> (int -> int)) F)
"
(! (x : (int -> int)) (MS (int -> int)
(G (int -> int)(F (SM (int -> int) x)))))
guard the context from bad Scheme values
84
![Page 85: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/85.jpg)
(MS ((int -> int) -> (int -> int)) F)
"
(! (x : (int -> int)) (MS (int -> int)
(G (int -> int)(F (G (int -> int)
(SM (int -> int) x))))))
guard the ML function from wrong uses
85
![Page 86: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/86.jpg)
(MS ((int -> int) -> (int -> int)) F)
"
(! (x : (int -> int)) (MS (int -> int)
(G+ (int -> int) (F (G- (int -> int)
(SM (int -> int) x))))))
These are two different jobs
86
![Page 87: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/87.jpg)
Anatomy of a Guard
(G+ # v)All guards are projections on values
87
![Page 88: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/88.jpg)
Anatomy of a Guard
(G+ # v)All guards are in Scheme
88
![Page 89: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/89.jpg)
Anatomy of a Guard
(G+ # v)Positive guards (jailors): "Make v behave like a tau"
89
![Page 90: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/90.jpg)
Anatomy of a Guard
(G+ # v)v is the value we're projecting
90
![Page 91: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/91.jpg)
Anatomy of a Guard
(G+ # v)the type v must behave like
91
![Page 92: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/92.jpg)
Anatomy of a Guard
(G- # v)Negative guards (bodyguards): "Make the context treat v like a tau"
92
![Page 93: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/93.jpg)
e := v | (e e) | (+ e e) | (SM # e) | (G+ # e) | (G- # e)
v := (! (x) e) | number
C := [] | (v C) | (C e) | (SM # C) | (G+ # C) | (G- # C)
93
![Page 94: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/94.jpg)
e := v | (e e) | (+ e e) | (MS # e)v := (! (x : #) e) | number# := int | (# " #)
C := [] | (v C) | (C e) | (MS # C)
94
![Page 95: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/95.jpg)
(G+ int n)" nif n is a number, error otherwise
(G+ (#1 -> #2) f)" (! (x) (G+ #1 ((f (G- #2 x)))))
if f is a procedure value, error otherwise
95
![Page 96: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/96.jpg)
(G+ int n)" nif n is a number, error otherwise
(G+ (#1 -> #2) f)" (! (x) (G+ #1 ((f (G- #2 x)))))
if f is a procedure value, error otherwise
(G- int n)" n
(G- (#1 -> #2) f)" (! (x) (G- #1 ((f (G+ #2 x)))))
No direct dynamic checks - negative guards are trusting
96
![Page 97: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/97.jpg)
Aside (#2):What if there were no Mars?
97
![Page 98: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/98.jpg)
98
![Page 99: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/99.jpg)
99
![Page 100: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/100.jpg)
100
![Page 101: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/101.jpg)
• Guards don't care about the type system (only vice versa)
• Scheme embedded in Scheme could use the same technique, anddoes
101
![Page 102: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/102.jpg)
Back to the big question again:How well have we answered it?
102
![Page 103: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/103.jpg)
• A method for modeling multilanguage semantics
• Boundaries, recursive contexts
• Simple but models a lot
• This is an interesting way to talk about language interoperation!
103
![Page 104: The Meaning of Multilanguage Programsjacobm/papers/multilang/earth-vs-m… · The Meaning of Multilanguage Programs Jacob Matthews jacobm@cs.uchicago.edu University of Chicago Robby](https://reader036.vdocuments.net/reader036/viewer/2022071016/5fcf4aca15464f6e49254627/html5/thumbnails/104.jpg)
The End
104