[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Vyskocil Vladimir <Vladimir.Vyskocil@s...> |
| Subject: | Re: Constructeurs en O'Caml |
> Vyskocil Vladimir writes:
> > Existe-t'il comme en C++ une fonction qui est appelee a la construction d'un
> > objet (pas seulement pour initialiser des variables d'instances) ?
>
> No, there's nothing such a "constructor" method, but a way to circumvent this
> is to do the job as a side effect, when initializing the members. See the fol-
> lowing sample code :
>
> class my_class name =
> (* MEMBERS *)
>
> val n =
> (* begin constructor *)
> ...;
> (* end constructor *)
> name
>
> (* METHODS *)
> ...
> end
>
Yes, but such contructor can't call a object method because self is
bind only at execution ie I can't do the following :
class my_class name as self =
(* MEMBERS *)
val n =
(* begin constructor *)
self#init;
...;
(* end constructor *)
name
(* METHODS *)
method init =
...
end
--
Vyskocil Vladimir
vvyskoci@sophia.inria.fr
http://www.inria.fr/safir/SAFIR/Vladimir.html