caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* porté des définitions des variables de classe
@ 1998-10-05 15:10 Serge Fantino
  1998-10-06 12:35 ` port des d finitions " Sylvain BOULM'E
  0 siblings, 1 reply; 10+ messages in thread
From: Serge Fantino @ 1998-10-05 15:10 UTC (permalink / raw)
  To: caml-list; +Cc: Vyskocil Vladimir, caml-light

Ocaml-2.0 autorise la déclaration de classe suivante:

class test =
object
    val v = [|Random.int 1000|]
    method get = v.(1)
    method set x = v.(1)<-x
end

Bizarrement, les objets créés à partir de cette définition semblent
tous partager la meme variable v:

let a = new test;;
let b = new test;;

a#get;;
b#get;;
(* retourne la meme valeur *)

a#set (Random.int 1000);;
a#get;;
b#get;;
(* a et b sont tous les 2 modifiés *)

Si l'on déclare la classe différement:

class test () =
...

alors tout redevient "normal".

Est-ce que c'est un bug ? Ou est-ce une nouvelle fonctionnalitée ?


Serge Fantino






^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~1998-10-09 15:29 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-10-05 15:10 porté des définitions des variables de classe Serge Fantino
1998-10-06 12:35 ` port des d finitions " Sylvain BOULM'E
1998-10-06 16:12   ` porte des definitions " Serge Fantino
1998-10-07  7:30     ` Pierre Weis
1998-10-07 13:03       ` porte des definitions / initialisation " Serge Fantino
1998-10-07 21:25         ` Jerome Vouillon
1998-10-08 13:42           ` Serge Fantino
1998-10-09 13:12             ` Sylvain BOULM'E
1998-10-07 10:16     ` porte des definitions " Sylvain BOULM'E
1998-10-08  7:33       ` Jacques GARRIGUE

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).