Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Sorin Stratulat <Sorin.Stratulat@loria.fr>
To: caml-list@inria.fr
Subject: operational semantics of = for objects
Date: Thu, 26 Mar 1998 18:32:49 +0100	[thread overview]
Message-ID: <351A9141.3D52@loria.fr> (raw)

Hello !

After comparing the results of the code (see below) executed on
different versions of OCAML (1.05 and 1.07), I would like to know if
anybody can explain me how the equality operator works for objects (if
it is possible in both versions). As I understood from a previous
message, overloading the operators is not supported yet.

Here you have two examples where I mainly created a class and some
instances that are further compared:

example 1 ------------
        Objective Caml version 1.07

# class point x_init =
  val mutable x = x_init
  method get_x = x
  	method move d = x <- x + d
  end;;
class point (int) =
  val mutable x : int
  method get_x : int
  method move : int -> unit
end
# let p = new point 7;;
val p : point = <obj>
# let q = new point 7;;
val q : point = <obj>
# p=q;;
- : bool = false
# List.mem (new point 7) [p;q];;
- : bool = false
#  let r = p;;
val r : point = <obj>
# p=r;;
- : bool = true
# 

example 2 -----------------
	Objective Caml version 1.05

# class point x_init =
  val mutable x = x_init
  method get_x = x
  	method move d = x <- x + d
  end;;
        class point (int) =
  val mutable x : int
  method get_x : int
  method move : int -> unit
end
# let p = new point 7;;
val p : point = <obj>
# let q = new point 7;;
val q : point = <obj>
# p=q;;
- : bool = true
#  List.mem (new point 7) [p;q];;
- : bool = true
# let r = p;;
val r : point = <obj>
# p = r;;
- : bool = true
# 

Thank you,

Sorin


-- 
e-mail : Sorin.Stratulat@loria.fr
Project: PROTHEO
Office : A201                             | Home:
------                                    | ------
tel:  03.83.59.30.02                      | C.U. du Placieux, ch. 1128
LORIA - BP 239                            | Bd. Mare'chal Lyautey
F-54506 VANDOEUVRE-les-NANCY Cedex FRANCE | 54600 Villers-le`s-Nancy





             reply	other threads:[~1998-03-27 11:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-03-26 17:32 Sorin Stratulat [this message]
1998-03-27 12:14 ` Jacques GARRIGUE
1998-03-27 14:33 ` Jerome Vouillon

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=351A9141.3D52@loria.fr \
    --to=sorin.stratulat@loria.fr \
    --cc=caml-list@inria.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