Identity vs equality (was Re: [Newbies] Assignment)

Andreas Raab andreas.raab at gmx.de
Mon Aug 13 08:46:38 UTC 2007


Alexander Lazarević wrote:
> Andreas Raab schrieb:
>> Keith Hodges wrote:
>>> Surely the question is one of value versus identity. Which leads to
>>> the question, what 'value' does #hello represent. To me the fact that
>>> it is a symbol is an implementation detail encapsulated inside the
>>> implementation. Its external behaviour is that of a string literal
>>> (i.e. immutable) as is its value.
>>>
>>> I see this as analogous with numbers. Is 1 = 1.0 and 1.0 = 1. I should
>>> hope so. 1.0 is implemented according to the float internal
>>> representation, and 1, is implemented as a literal.
>> Thanks for the example. It's a very good analogy.
> 
> Is it? I think one could argue, that 1 is just an abbreviation of 1.0
> and since N is a subset of R, 1.0 in N is "the same object" as 1.0 in R. No?

Sure.

> Further the values of 1kg and 1km are both numbers like strings and
> symbols are sequences of characters, but I wouldn't say that 1kg=1km.

Sure.

> Nothing forbids literal strings to be immutable, like they are in
> VisualWorks, but literal strings won't become Symbols just because of that.

Err ... so what is your point? Are you claiming that 1 should not equal 
1.0? Or that there is a substantial difference between 'foo' and #foo 
and that they shouldn't compare equal? Or that 'foo' = #foo but #foo ~= 
'foo'? Somewhere you lost me with whatever point you were trying to make.

*My* only point was that comparison should be symmetrical, as 
excemplified by the fact that iff 1 = 1.0 then 1.0 = 1. If you disagree 
with that please explain why there should be a difference in comparing 
either way.

Confused,
   - Andreas



More information about the Squeak-dev mailing list