Imperative monadic form [YI0W]

藉由分析ANF跟monadic form的機器表示的意圖,Bowman提出了Imperative monadic form。只要我們讓

let x := a
in b

等於

set! x := a
b

的別稱。在語意上commuting conversion就不再是困擾了

set! y := {
  set! x := t
  t
}
t

等於

set! x := t
set! y := t
t

箝套的if也不再是問題

set! y := if v t1 t2
t

等於

if v
  set! y := t1
  set! y := t2
t

注意到右邊幾乎已經是指令語言可以處理的形式了

Definition Syntax [local-0]

注意到為了支援對if expression的轉換,需要加入if statement

t::=(begin s⃗ t)∣v∣(if0 v t t)∣(call v v)∣(op v⃗)s::=(begin s⃗)∣(set! x v)∣(if0 v s s)∣(set! x t)∣(set! x (op v⃗))∣(set! x (call v v))v::=(λ (x) t)∣ι\begin{aligned} t &::= (\text{begin}\ \vec{s}\ t) \mid v \mid (\text{if0}\ v\ t\ t) \mid (\text{call}\ v\ v) \mid (op\ \vec{v}) \\ s &::= (\text{begin}\ \vec{s}) \mid (\text{set!}\ x\ v) \mid (\text{if0}\ v\ s\ s) \mid (\text{set!}\ x\ t) \mid (\text{set!}\ x\ (op\ \vec{v})) \mid (\text{set!}\ x\ (\text{call}\ v\ v)) \\ v &::= (\lambda\ (x)\ t) \mid \iota \end{aligned}