Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* operational semantics of = for objects
@ 1998-03-26 17:32 Sorin Stratulat
  1998-03-27 12:14 ` Jacques GARRIGUE
  1998-03-27 14:33 ` Jerome Vouillon
  0 siblings, 2 replies; 3+ messages in thread
From: Sorin Stratulat @ 1998-03-26 17:32 UTC (permalink / raw)
  To: caml-list

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





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

end of thread, other threads:[~1998-03-27 15:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-03-26 17:32 operational semantics of = for objects Sorin Stratulat
1998-03-27 12:14 ` Jacques GARRIGUE
1998-03-27 14:33 ` Jerome Vouillon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox