kris at sitepen.com
Wed Jan 14 16:44:26 PST 2009
-----BEGIN PGP SIGNED MESSAGE-----
Brendan Eich wrote:
> On Jan 9, 2009, at 3:08 PM, Kris Zyp wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>> The counter-argument is strong:
>>> typeof x == typeof y => (x == y <=> x === y)
>>> but 1.1 != 1.1m for fundamental reasons.
>> I understand the counter-argument, but with such an overwhelming
>> number of typeof uses having far easier migration with "number",
> Migration how? You'll have to change something to "use decimal" or
> s/1.1/1.1m/. Only once you do that can you be sure about all
> operands being decimal.
And I am sure our users will do that and pass decimals into our
> I'm assuming it would be "bad" in the Dojo code you've looked at if
> 1.1 came in from some standard library that returns doubles, and was
> tested against 1.1m via == or === with false result, where previous
> to decimal being added, the result would be true.
I am not aware of any situations in the Dojo codebase where this would
cause a problem. I can't think of any place where we use an
equivalence test and users would expect that decimal behave in the
same way as a double. Do you have any expected pitfalls that I could
look for in Dojo?
>> I can't possibly see how the desire to preserve this property is more
>> important than better usability for the majority use cases.
> You really need to show some of these use cases from Dojo. I have a
> hard time believing you've ruled out mixed-mode accidents.
Ok, sounds good, I will be glad to be corrected if I misunderstanding
this. Here are some of the places where I believe we would probably
add extra code to handle the case of typeof checks where decimal
values may have been passed in by users, and we would want the
behavior to be the same as a number:
As I have mentioned before, we would need to change our JSON
serializer to handle "decimal":
Our parser function would need to add support for "decimal"
Matrix math handling for our graphics module:
(line 88 is one example)
Actually there are numerous situations in the graphics packages where
a decimal should be acceptable for defining coordinates, scaling, etc.:
Charting also has a number of places where decimals should be an
acceptable form of a number:
Again, I understand there are difficulties with typeof 1.1m returning
"number", but in practice it seems we would experience far more pain
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
More information about the Es-discuss