Browse thread
[Caml-list] Strange physical equality behavior
[
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: | William Lovas <wlovas@s...> |
| Subject: | Re: [Caml-list] Strange physical equality behavior |
On Tue, Nov 11, 2003 at 08:46:56AM -0800, David Brown wrote:
> On Tue, Nov 11, 2003 at 01:48:22AM -0500, Oleg Trott wrote:
> > On Sunday 09 November 2003 08:33 pm, Jacques Garrigue wrote:
> > > On mutable structures, [e1 == e2] is true if and only if
> > > physical modification of [e1] also affects [e2].
> >
> > By the way, either "mutable structures" or "physical modification" need
> > to be clarified, because if (int ref list) is "mutable" then the above
> > is wrong:
>
> If you take structure to mean a single data type, rather than a more
> complicated data structure, then it is true.
Well, what do you mean by "a single data type", then? Surely a record is a
single data type, but ...
type r = { mutable a: int; mutable r: r }
let rec r1 = { a = 5; r = r2 }
and r2 = { a = 7; r = r1 }
Surely you wouldn't argue that this is an immutable data structure, either
-- it contains nothing *but* mutable fields! And yet,
r1.a <- 6
also "affects" r2, but r1 != r2. (Admittedly, though, the ambiguity may
lie in the usage of the word "affects".)
*shrug* Maybe it's a bit contrived, but i would err on the side of caution
and say that the documentation should be made clearer.
William
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners