Reputation: 11588
The ocaml objects tutorial contains this piece of code, but does not explain it.
# class c0 = object method m = {< >} method n = 0 end;;
class c0 : object ('a) method m : 'a method n : int end
What does {< >} mean and where is it documented?
Upvotes: 0
Views: 98
Reputation: 66818
There is an informal definition of this construct in Section 3.1.3 of the OCaml manual. It says:
The override construct {< ... >} returns a copy of “self” (that is, the current object), possibly changing the value of some instance variables.
A more formal definition is given in Section 6.9.2.
The expression {< >}
contains no changes to instance variables, so it simply returns a copy of “self,” the current object.
Upvotes: 2