The "built in" type 'a ref is implemented using a record with a mutable field. This example from the manual is simply showing you how to implement references using an object with a mutable instance variable instead. There is no language construct "class ref", you are just defining a class that happens to be named "ref". Since "ref" is just a normal identifier, not a keyword, this is allowed.

On Tuesday, December 22, 2015, 沈胜宇 <syshen@nudt.edu.cn> wrote:
Dear all:

In ref manual of ocaml "3.10 Parameterized classes", there is a code segment liek this:

class ref (x_init:int) =
object
val mutable x = x_init
method get = x
method set y = x <- y
end;;

so what is the meaning of class ref?


Shen