Standard builtins' prototypes and toString
Allen Wirfs-Brock
allen at wirfs-brock.com
Thu Jun 19 11:16:37 PDT 2014
On Jun 19, 2014, at 10:46 AM, C. Scott Ananian wrote:
> While we're on the topic, shall we discuss `valueOf()`? Should it get the same treatment?
> --scott
>
I don't think so. To me, toString is a special case because it is explicitly applied so often, particularly for debugging purposes.
But valueOf is primarily invoked for implicit conversions in expressions.
Like I described earlier in this thread, TC39's assumption when it agreed to this ES design change was that the web did not generally depend upon using these existing ES3 generation (or earlier) prototypes as instance objects. In the case where we know that wasn't true (Function.prototype) we intentionally did not change the prototype to being a non-instance object. We also agreed if we discovered other such dependencies we would change those prototypes back to being instance objects.
Discovering that one of these prototypes objects were being routinely used in expression contexts where valueOf was being implicitly applied would be evidence that that prototype needed to be handled in the legacy manner. But, we don't have any new evidence of that being the case. Until there is some evidence, there isn't any reason to second guess the original analysis and TC39's decision.
Allen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140619/27a4f46e/attachment.html>
More information about the es-discuss
mailing list