Re: Object identity
- From: "David Barrett-Lennard" <davidbl@xxxxxxxxxxxx>
- Date: 25 Jun 2006 19:23:44 -0700
Gabriel Claramunt wrote:
[snip]
Object identity is defined completely in the computing space, and intrinsic
to the object instance: two object instances have different indentity even
if they have the same properties.
In your code:
Employee* a = new Employee;
a->SetName("Albert Einstein");
a->SetSalary(25000);
Employee* b = new Employee;
b->SetName("Albert Einstein");
b->SetSalary(25000);
But a and b have different identity.
[snip]
In the code example you have I(A)=a and I(A)=b but a <> b.
I previously said I agree with this, but that's because I glossed over
it much too quickly.
Let entity A stand for the human named Albert Einstein.
What you should say is: I(a) = A and I(b) = A. ie both object
instances a and b map under the interpretation to the same human
entity.
Your example shows that the interpretation is not 1-1, rather than it
not being a function! You seem to have swapped domain and codomain!
I have no problem at all with an interpretation not being 1-1. IMO it
is implicit in the nature of object identity (as distinct from value
semantics). However you will find lots of OO programmers who think
your code above is evil.
Cheers,
David Barrett-Lennard
.
- Follow-Ups:
- Re: Object identity
- From: Gabriel Claramunt
- Re: Object identity
- References:
- Object identity
- From: David Barrett-Lennard
- Re: Object identity
- From: Gabriel Claramunt
- Object identity
- Prev by Date: 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
|