The definition of the JSON.stringify function (per 15.12.3) defines
str and JO such that [[Get]] will be called twice for every serialised
property on an object, which may have side effects if the property is
a getter.
My testing shows that json2.js accesses each property only once, which
makes more sense in my opinion as having side effects occur twice for
each serialised getter seems odd in of itself, and has the potential
to be more efficient. Gecko currently matches the spec in this regard
and calls getters twice.
Another issue is the arguments passed to the abstract operation str
when serialising an array when a replacer function is provided. The
definition of the abstract operation JA says that str should be called
with the arguments ToString(index) and value. While technically this
is necessary in order to perform the [[Get]] operation with key on
host in the str, it has the effect of implying that when replacer is
called the key given passed as an argument, the key should be of type
String. Currently no implementation (including json2.js) does this
ToString conversion, so i think the specified algorithm needs to be
corrected to remove the ToString from this point.
--Oliver
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss