see.mlw 498 Bytes
Newer Older
1
module M
2

3
use import int.Int
4
use import module ref.Ref
5

6 7
(* Side effect in expressions (Bart Jacobs' tricky example) *)

8 9 10
parameter b  : ref int
parameter b1 : ref int
parameter b2 : ref int
11

12 13
let f () =
  {} b := 1 - !b; !b { result = !b and !b = 1 - old !b }
14

15 16
let k () =
  {}
17 18 19
  begin
    b := 0;
    b1 := (1 - (f ())) + (f ());
20
    b2 := (f ()) * (1 - (f ()))
21
  end
22
  { !b1 = 0 and !b2 = 1 }
23

24 25
end

26
(*
27
Local Variables:
28
compile-command: "unset LANG; make -C ../../.. bench/programs/good/see"
29
End:
30
*)