Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
constructors for objects in ocaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Hendrik Tews <tews@t...>
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

but got an error saying, that self is unbound.


Hendrik Tews