Questions on labels
Hello,
It's not quite clear to me what the standard usage of labels is/should be. Here are some questions in comments of an example:
module Labels
use int.Int
type r = {mutable f :int}
val z : r
let f1 (x: r) : unit =
z.f <- 5;
label L in
z.f <- 7;
let f2 (x : r) : unit =
x.f <- 8;
(*assert { x at L = x}; (* B1: Should this be: "x not defined at L" ? *)*)
in
f2 x
let f3 (x: r) : unit =
z.f <- 5;
label L in
z.f <- 7;
let f2 (x : r) : unit =
x.f <- 8;
assert { z at L = x} (* B2:Should this be forbidden ? Label is not in the current function *)
in
let f3 (x: r) : unit =
x.f <- 42;
(*assert { z at L1 = x} (* B3: Should this be allowed ? Label is after the definition *)*)
in
label L1 in
f3 x;
f2 x
let f4 (x: r) : unit =
z.f <- 5;
label L in
z.f <- 10;
label L in (* B4: Should there be a warning here because the first label become not accessible ? *)
z.f <- 11;
assert {z at L = z at L}
let f5 (x:r) : unit =
z.f <- 5;
(* assert {z at L = z} (* B5: Should this be allowed ? Label is in another toplevel function *)*)
end