constructors for objects in ocaml

Hendrik Tews (tews@tcs.inf.tu-dresden.de)
Tue, 23 Jul 1996 17:12:40 +0200

Date: Tue, 23 Jul 1996 17:12:40 +0200
Message-Id: <9607231512.AA02896@ithif02.ithi>
From: Hendrik Tews <tews@tcs.inf.tu-dresden.de>
To: caml-list@margaux.inria.fr
Subject: constructors for objects in ocaml

Hi everybody,

it is possible to define something like a constructor in ocaml,
ie to add an expression to a class which is evaluated every time
an object is created?

I tried something like

class top arg as self =
method create x = let _ = print_x
in x
val x = self#create arg
end;;

but got an error saying, that self is unbound.

Bye,

Hendrik Tews