SNA=Shah Namrata Abhaykumar
SNA Consider the following eg.
SNA
SNA Using the above tanslation ,
SNA
SNA case (1,2) of { ~(a,b) = a + b ; _ -> 0 }
SNA
SNA == let { y = (1,2) }
SNA in
SNA let { x1' = case y of { (a,b) -> a }}
SNA in
SNAlet { x2' = case y of {
Namrata asks...
| So, when x1' + x2' is evaluated,
| Is (1,2) pattern matched against (a,b) twice -- once for x1' and once
| for x2' ??
The translation you give (correctly I think) expresses the required
*semantics*. But the translation is not the required *implementation*. A
compiler can do
The semantics of irrefutable pattern matching is given as,
case e0 of { ~p -> e ; _ -> e' }
= let { y = e0 }
in
let { x1' = case y of { p -> x1 } }
in ...
let { xn' = case y of { p -> xn } }
in
e[x1'