In comp.lang.javascript message said:
Dr J R Stockton said the following on 1/2/2008 7:14 AM:
Define "supplied from outside".
See FAQ 4.40.
The string is supplied as the value of a select element.
If that's the displayed value, it is essentially outside.
If that value is to be sent to a server, it is headed for outside.
Otherwise, a string is not a good representation; just a simple-minded
one. I should of course have written "from/to outside".
It is when it is the value of a select element.
That is designed for external use, and does not make it a good internal
representation.
Analogy : numbers are always I/O as strings, but internally represented
as Doubles. Having internal Doubles was a language design choice. The
language would have been much better for idiot coders, but slower to run
and much worse for implementors, if numbers were held internally as
full-accuracy decimal strings.
Or a simple string. KISS.
Things should be as simple as is efficient, but no simpler. It's better
to be right than to be simple.
Analogy : the initial choice of getYear() giving a value in 0..99.
Given that the internal workings must handle more than one century, it
would have been no harder for the implementors to have given the full
year. Coders wanting 0..99 would have merely needed to use %100 (and
would have been reminded of Y2k thereby); coders wanting the proper year
would have been saved much inconvenience.
That's been compounded by an idiotic choice, for getYear outside years
1900-1999, of returning the full year (ISO16262 calls for, and Opera &
Firefox give, Year-1900 always).
It isn't bad data design at all. When you need a number in two forms -
both decimal and fraction - and you choose which one to use where, the
best way is to keep the fraction as a string and convert it to decimal
when needed.
Wrong, unless the amount of decimal is very small. A rational fraction
is an ordered pair of numbers (as a complex number is), and should be
held as such.
But remember : my aim is not to make you understand, but to give
everyone else no reason to be deceived.