0
votes

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?

1
stackoverflow.com/questions/19327654/… has your answer in the last paragraph of the answer. - Mat
rigaux.org/language-study/syntax-across-languages-per-language/… has your answer in this site for each function.. - Dharma

1 Answers

2
votes

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.