Equivalent

SML

The SML equivalent of the imperative block-structured [example]:

let                   --lex level 1
  val v1=...;            --level 1 obj 1
  val v2=...;            --level 1 obj 2

  fun A() =              --level 1 obj 3
    
let               --lex level 2
  val v3=...;        --level 2 obj 1

  fun B() =          --level 2 obj 2
    
let            --lex level 3
  val v4=...;     --level 3 obj 1
in ...
end{B}
in B() --call B end{A};
fun C() = --level 1 obj 4
    
let               --lex level 2
  val v5=...;        --level 2 obj 1

  fun D() =          --level 2 obj 2
    
let            --lex level 3
  val v6=...;     --level 3 obj 1
in A()         --call A
end{D}
in D() --call D end{C}
in C() --call C end
-- LA, CS UWA