On Sep 17, 2008, at 6:22 PM, Mark S. Miller wrote:
On Wed, Sep 17, 2008 at 2:18 PM, Sam Ruby <[EMAIL PROTECTED]>
wrote:
On Wed, Sep 17, 2008 at 12:49 PM, Brendan Eich wrote:
> On Sep 17, 2008, at 6:54 PM, Douglas Crockford wrote:
>
> > It requires that a === b produce the same result as
> > typeof a == typeof b && a == b.
Agreed.
> Without "use decimal", typeof 1.1m must not be "number" to preserve
> this same invariant. Otherwise (without "use decimal") 1.5m == 1.5
> but 1.1m != 1.1, so without making typeof 1.5m != typeof 1.1m, we
> cannot have typeof 1.5m == "number".
>
> I do not believe anyone wants typeof 1.5m != typeof 1.1m.
I agree that typeof 1.5m == typeof 1.1m. However, I do not agree
that 1.1m == 1.1. These should be !=, since they represent distinct
real numbers.
It seems to me that Brendan said 1.1m != 1.1 and did not question this.
I do agree that 1.5m == 1.5, but only because they represent the
same real number, not because they look the same. This extends the
notion of cohort across the decimal/binary divide.
-0, 0, -0m, 0m, 0.000m
may all be computationally distinct values. (Is 0.00m distinct from
0m?) If they are, then they should therefore be distinguished by any
Object.identical() and Object.indentityHash() operations. But they
all represent the same real number, so they should be ==. If we
agree that they should also all be typeof 'number', then they should
also all be === and be considered generalized cohorts.
Brendan's premise is that 1.5m has different operational behavior from
1.5 and therefore it would be wrong to make them '==='. I tend to
agree. Making '===' treat distinct values the same and then
introducing a new Object.identical to tell the difference seems
inelegant.
If typeof all these were 'number', then binary and decimal could
share a single NaN, Infinity, and -Infinity. Only the remaining
finite numeric values would be distinctly either binary or decimal.
I agree with Sam and apparently Crock and everyone else that mixed
mode should coerce to decimal. Or, at least, I have no objection to
that position.
If that is the case then 1.5m / 10.0 != 1.5 / 10.0, and thus it seems
wrong for 1.5m and 1.5 to be '==='.
Were we to adopt this, then I think "use decimal" should condition
only whether an unqualified numeric literal be interpreted as binary
or decimal floating point. We should then have a suffix which means
binary floating point, so you can say it explicitly. Nothing else
about the numerics should be conditioned by the pragma.
Perhaps that suffix could be 'f' as in C/C++.
Regards,
Maciej
_______________________________________________
Es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss