Re: Object identity
- From: "Dmitry A. Kazakov" <mailbox@xxxxxxxxxxxxxxxxx>
- Date: Thu, 29 Jun 2006 19:55:55 +0200
On 29 Jun 2006 10:04:54 -0700, David Barrett-Lennard wrote:
Bruno Desthuilliers wrote:
In "pure" 00PLs, this distinction does not exist. Now you have types
with a very straightforward "value" semantic (ie integers, strings etc)
- which in some languages happens to be immutable objects - types with a
more complex "value" semantic (records-like types) but for which (total
or partial) structural equality can still make sens, and types for which
a "value" semantic would be harder to define, like ie class objects or
function objects - in this last case, "value" equality could be defined
as "given same inputs, produces same ouptputs", but this would be nearly
impossible to test in practice AFAICT, at least in most current
programming languages.
I can think of some object types where "value" equality testing (as
distinct from identity testing) doesn't seem to make sense at all.
To me identity is a value of some possibly different type, of which it is
known that these values are comparable (exists =, transitive, reflexive,
commutative). Quite simple, IMO.
For
example, Semaphore, Thread, Window, PrinterProxy. Eg what does it
mean for two different thread instances to have the same value?
It means that they have it same. Consider a redundant system. In such a
system several redundant threads would traverse same states and could be
considered same as long as states don't differ.
Same semaphores: consider two redundant partitions of a distributed system.
In each partition there exists a semaphore used for local interlocking.
These are logically same. One can imagine some global deadlock monitoring
program which would enumerate all semaphores in all partitions and check
their states [=values]
In C++, operator==() is optional. That makes good sense to me.
Right. It is the domain to decide if == has to be defined. It makes a lot
sense to have no == defined, because == or its absence is a part of
behavior.
I wonder if there are also some object types for which there are
multiple candidates for value semantics.
I think it would be wrong to mix semantics [the value of an object] with an
ability to check it. Comparing values might be incomputable, in strict
sense. Because values are outside the language.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
.
- Follow-Ups:
- Re: Object identity
- From: David Barrett-Lennard
- Re: Object identity
- References:
- Object identity
- From: David Barrett-Lennard
- Re: Object identity
- From: Gabriel Claramunt
- Re: Object identity
- From: David Barrett-Lennard
- Re: Object identity
- From: Gabriel Claramunt
- Re: Object identity
- From: David Barrett-Lennard
- Re: Object identity
- From: Bruno Desthuilliers
- Re: Object identity
- From: David Barrett-Lennard
- Re: Object identity
- From: Bruno Desthuilliers
- Re: Object identity
- From: David Barrett-Lennard
- Re: Object identity
- From: Bruno Desthuilliers
- Re: Object identity
- From: David Barrett-Lennard
- Object identity
- Prev by Date: Re: (OT) Re: Object identity
- Next by Date: Re: Object identity
- Previous by thread: Re: Object identity
- Next by thread: Re: Object identity
- Index(es):
Relevant Pages
|