* RE: [Caml-list] Semantics of physical equality
@ 2004-02-27 23:16 Kevin S. Millikin
2004-02-27 23:48 ` Michal Moskal
0 siblings, 1 reply; 3+ messages in thread
From: Kevin S. Millikin @ 2004-02-27 23:16 UTC (permalink / raw)
To: 'Basile STARYNKEVITCH', caml-list
On Friday, February 27, 2004 3:32 PM, Basile STARYNKEVITCH
[SMTP:basile@starynkevitch.net] wrote:
>> On Fri, Feb 27, 2004 at 02:29:50PM -0600, Kevin S. Millikin
>> wrote:
>>
>> # V1(0) == V1(0);; - : bool = false
>>
>> V1's are different. Is this guaranteed?
>> What do you mean by guaranteed?
I mean ``guaranteed'' in the sense that separate calls to cons in
Scheme
are guaranteed to produce objects that are distinct (according to eqv?
and eq?), or that a call to malloc in C is guaranteed to never return a
pointer that is the same as any other currently valid pointer in the
program (according to ==).
>> Why would you want a guarantee that V1 0 is not physically equal
>> to V1 0? I tend to think that making such an hypothesis is
>> dangerous and wrong, even if the current implementation
>> demonstrate it.
For the same reason that I occasionally rely on separate cons cells not
being eq? in Scheme ;). In the current problem, it can save me a great
deal of effort involved in generating temporary identifiers that are
guaranteed to be unique, and in wrapping library data structures that I
am unwilling to change in order merely to tag them.
I realize that it would be dangerous and wrong to rely on them being ==
if the semantics of value constructors and == did not guarantee they
would be. So I guess that's my question: "is it dangerous and wrong to
rely on separately constructed values being different according to
==?".
-- Kevin
PS: Anyway, it looks like Michal Moskal has answered in the negative.
Neither behavior is guaranteed, which is an acceptable answer (though
not the one I was looking for).
-------------------
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Semantics of physical equality
2004-02-27 23:16 [Caml-list] Semantics of physical equality Kevin S. Millikin
@ 2004-02-27 23:48 ` Michal Moskal
2004-02-28 6:28 ` [Caml-list] " Jed Davis
0 siblings, 1 reply; 3+ messages in thread
From: Michal Moskal @ 2004-02-27 23:48 UTC (permalink / raw)
To: caml-list
On Fri, Feb 27, 2004 at 05:16:06PM -0600, Kevin S. Millikin wrote:
> In the current problem, it can save me a great
> deal of effort involved in generating temporary identifiers that are
> guaranteed to be unique, and in wrapping library data structures that I
> am unwilling to change in order merely to tag them.
type t = V of int ref
let t1 = V (ref 0)
let t2 = V (ref 0)
In this case you can assume t1 != t2. If it is not a sum type, but
record type, you can use record with at least one mutable field.
--
: Michal Moskal :: http://www.kernel.pl/~malekith :: GCS !tv h e>+++ b++
: When in doubt, use brute force. -- Ken Thompson :: UL++++$ C++ E--- a?
-------------------
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Caml-list] Re: Semantics of physical equality
2004-02-27 23:48 ` Michal Moskal
@ 2004-02-28 6:28 ` Jed Davis
0 siblings, 0 replies; 3+ messages in thread
From: Jed Davis @ 2004-02-28 6:28 UTC (permalink / raw)
To: caml-list
Michal Moskal <malekith@pld-linux.org> writes:
> On Fri, Feb 27, 2004 at 05:16:06PM -0600, Kevin S. Millikin wrote:
>> In the current problem, it can save me a great
>> deal of effort involved in generating temporary identifiers that are
>> guaranteed to be unique, and in wrapping library data structures that I
>> am unwilling to change in order merely to tag them.
>
> type t = V of int ref
>
> let t1 = V (ref 0)
> let t2 = V (ref 0)
>
> In this case you can assume t1 != t2. If it is not a sum type, but
> record type, you can use record with at least one mutable field.
Hm:
type t = unit ref
let t1 : t = ref ()
let t2 : t = ref ()
let mt : _ -> t = ref
--
[Jed Davis] A098 903E 9B9A DEF4 168F AA09 BF07 807E F336 59F9
<jdev@panix.com> 0xF33659F9
"But life wasn't yes-no, on-off. Life was shades of gray, and rainbows
not in the order of the spectrum." -- L. E. Modesitt, Jr., _Adiamante_
-------------------
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-02-29 19:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-27 23:16 [Caml-list] Semantics of physical equality Kevin S. Millikin
2004-02-27 23:48 ` Michal Moskal
2004-02-28 6:28 ` [Caml-list] " Jed Davis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox