val [mutable] x = expr with (reader|writer|accessor)
x
and a
set_x
method, like in ruby.
obj#x <- expr
set_x
method.
{| [mutable] f1 = expr1; ...; [mutable]
fn = exprn |}
$ ocaml camlp4o.cma pa_polymap.cmo polymap.cmo # let m = `{x=1; y=true};; val m : [> `x of int | `y of bool ] Polymap.t =# let m = `{m with z = "hello"};; val m : [> `x of int | `y of bool | `z of string ] Polymap.t = # m.`y;; - : bool = true # `{m with x = "a"};; ^ Types for tag `x are incompatible # m.`u;; Exception: Not_found.