Previous Up Next

8.6  Object copy short notations

(Introduced in OCaml 4.03)

expr::= ...  
  { < expr with  field  [= expr]  { ; field  [= expr] }  [;> }

In an object copy expression, a single identifier id stands for id =  id, and a qualified identifier module-path .  id stands for module-path .  id =  id. For example, all following methods are equivalent:

object val x=0. val y=0. val z=0. method f_0 x y = {< x; y >} method f_1 x y = {< x = x; y >} method f_2 x y = {< x=x ; y = y >} end

Previous Up Next