Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Serge Fantino <fantino@math.unice.fr>
To: caml-list@inria.fr
Cc: Vyskocil Vladimir <vyskocil@math.unice.fr>, caml-light@inria.fr
Subject: porté des définitions des variables de classe
Date: Mon, 05 Oct 1998 16:10:07 +0100	[thread overview]
Message-ID: <3618E14F.217B0EE1@math.unice.fr> (raw)

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






             reply	other threads:[~1998-10-05 15:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-10-05 15:10 Serge Fantino [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3618E14F.217B0EE1@math.unice.fr \
    --to=fantino@math.unice.fr \
    --cc=caml-light@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=vyskocil@math.unice.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox