[squeak-dev] a==b "true" but a=b "false"

Bert Freudenberg bert at freudenbergs.de
Thu Sep 4 09:30:59 UTC 2014


On 04.09.2014, at 01:11, Chris Muller <ma.chris.m at gmail.com> wrote:

> When could it happen?
> 
> A:  With Float nan.
> 
>   Float nan == Float nan   "true"
> 
>   Float nan = Float nan   "false"
> 
> It violates what I have long considered an invariant that if a==b, then a=b.

Yep. We might want to fix that.

> Real world context:  When two DB clients change the same object in the
> exact same way, it's not a conflict.  If they change it differently,
> it is.
> 
> They've both made the same reference to Float nan, but just asking if
> they made equivalent changes still reports false.  So I have to put in
> a complicated special check for NaN first..??

If you want your code to work in old or current images, yes.

> Okay, I actually wrote:  (a==b or: [a=b]) but who would ever write
> that or not "simplify it" in teh future if they saw it?

Put a comment on it ;)

> Comments?  Why shouldn't Float nan = Float nan?

As the others wrote, that's defined in the IEEE standard.

We cannot change that. But we could change it so that

	Float nan ~~ Float nan

simply by returning a clone in #nan. There should be no downside to that. Except it breaks your test. You would still need to rewrite your test as

	a = b or: [a isNaN = b isNaN]

because NaN is special. And if you do that, then the change is not necessary.

- Bert -

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4142 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20140904/7378202f/smime.bin


More information about the Squeak-dev mailing list