No subject
Thu Feb 11 18:09:36 PST 2010
responding value on the object being enumerated (e.g., "obj[k]" above), I t=
hink that the more useful interpretation is the one currently employed by T=
raceMonkey and SES5/3.
I think a clarification of this issue be added to the ES5 errata. I propose=
that this clarification adopt the more useful suppression behavior, and su=
ggest that ES5 implementations in progress switch to that behavior. Whichev=
er disambiguation is adopted, I'll be happy to file bugs against the implem=
entations with the non-conforming behavior. We should also add a test for t=
his to es5conform.
--
Cheers,
--MarkM
--_000_90EDC335A511F2479C63F7337D3CE7DB41DEFDE2TK5EX14MBXC116r_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:x=3D"urn:schemas-microsoft-com:office:excel" xmlns:m=3D"http://schema=
s.microsoft.com/office/2004/12/omml" xmlns=3D"http://www.w3.org/TR/REC-html=
40">
<head>
<meta http-equiv=3DContent-Type content=3D"text/html; charset=3Dus-ascii">
<meta name=3DGenerator content=3D"Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3DEN-US link=3Dblue vlink=3Dpurple>
<div class=3DSection1>
<p class=3DMsoNormal><span style=3D'font-size:11.0pt;font-family:"Calibri",=
"sans-serif";
color:#1F497D'>While 12.6.4 is does not explicitly talk about this case I t=
hink
it implicitly covers it. <o:p></o:p></span></p>
<p class=3DMsoNormal><span style=3D'font-size:11.0pt;font-family:"Calibri",=
"sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=3DMsoNormal><span style=3D'font-size:11.0pt;font-family:"Calibri",=
"sans-serif";
color:#1F497D'>Line 6.a (of the first algorithm, 7.a of the second) says &#=
8220;Let
P be the name of the next property of obj whose [[Enumerable]] property is =
true”.
<o:p></o:p></span></p>
<p class=3DMsoNormal><span style=3D'font-size:11.0pt;font-family:"Calibri",=
"sans-serif";
color:#1F497D'>I don’t believe that there is any other operatio=
n or
function in ES5 that when doing a property access by-passes a own property
based upon some condition and instead accesses as shadowed inherited proper=
ty.
Given that it’s pretty clear that the quoted sentence should be read =
as
if it said “Let P be the name of the next property accessible via the
[[Get]] internal method of obj whose [[Enumerable]] property is true”=
<o:p></o:p></span></p>
<p class=3DMsoNormal><span style=3D'font-size:11.0pt;font-family:"Calibri",=
"sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=3DMsoNormal><span style=3D'font-size:11.0pt;font-family:"Calibri",=
"sans-serif";
color:#1F497D'>Also note that the final paragraph says “a property of=
a
prototype is not enumerated if it is “shadowed” because some
previous object in the prototype chain has a property with the same name=
221;.
Note this just says “shadowed” which I believe (I probabl=
y
wrote it :-) show be interpreted in the accessible via [[Get]] sense. =
In
particular, it does not say something like ‘has the same name of a en=
umerated
property of some previous object in the prototype chain”<o:p></o:p></=
span></p>
<p class=3DMsoNormal><span style=3D'font-size:11.0pt;font-family:"Calibri",=
"sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=3DMsoNormal><span style=3D'font-size:11.0pt;font-family:"Calibri",=
"sans-serif";
color:#1F497D'>Given these two points of the specification, I think it take=
s
some pretty creative interpretation to arrive at the Webkit/V8
interpretation. I suspect, that their behavior is probably an
implementation artifact rather than something intentional. I can ente=
r
the more explicit formulation of (6.a/7.a) into the errata if there i=
s a
consensus that it is really needed, but I think we are also fine without it=
.<o:p></o:p></span></p>
<p class=3DMsoNormal><span style=3D'font-size:11.0pt;font-family:"Calibri",=
"sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=3DMsoNormal><span style=3D'font-size:11.0pt;font-family:"Calibri",=
"sans-serif";
color:#1F497D'>Allen<o:p></o:p></span></p>
<p class=3DMsoNormal><span style=3D'font-size:11.0pt;font-family:"Calibri",=
"sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<div style=3D'border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in =
4.0pt'>
<div>
<div style=3D'border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in =
0in 0in'>
<p class=3DMsoNormal><b><span style=3D'font-size:10.0pt;font-family:"Tahoma=
","sans-serif"'>From:</span></b><span
style=3D'font-size:10.0pt;font-family:"Tahoma","sans-serif"'> es-discuss-bo=
unces at mozilla.org
[mailto:es-discuss-bounces at mozilla.org] <b>On Behalf Of </b>Mark S. Miller<=
br>
<b>Sent:</b> Friday, April 23, 2010 9:01 AM<br>
<b>To:</b> es5-discuss at mozilla.org; es-discuss<br>
<b>Cc:</b> Mike Stay<br>
<b>Subject:</b> Yet more ambiguities in property enumeration<o:p></o:p></sp=
an></p>
</div>
</div>
<p class=3DMsoNormal><o:p> </o:p></p>
<div>
<div>
<p class=3DMsoNormal>Mike Stay (cc'ed) noticed the following ambiguity:<o:p=
></o:p></p>
</div>
<div>
<p class=3DMsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=3DMsoNormal>What should the following print?<o:p></o:p></p>
</div>
<div>
<p class=3DMsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=3DMsoNormal> var base =3D {x:8};<o:p></o:p></p>
</div>
<div>
<p class=3DMsoNormal> function showProps(obj) { <o:p=
></o:p></p>
</div>
<div>
<p class=3DMsoNormal> var result =3D []; <o:p=
></o:p></p>
</div>
<div>
<p class=3DMsoNormal> for (var k in obj) { <o=
:p></o:p></p>
</div>
<div>
<p class=3DMsoNormal> result.push(k, ': ',
''+obj[k], '\n'); <o:p></o:p></p>
</div>
<div>
<p class=3DMsoNormal> } <o:p></o:p></p>
</div>
<div>
<p class=3DMsoNormal> return result.join(''); =
;<o:p></o:p></p>
</div>
<div>
<p class=3DMsoNormal> }<o:p></o:p></p>
</div>
<div>
<p class=3DMsoNormal> var derived =3D Object.create(base,=
{x:
{value: 9, enumerable: false}});<o:p></o:p></p>
</div>
<div>
<p class=3DMsoNormal> showProps(derived);<o:p></o:p></p>
</div>
</div>
<div>
<p class=3DMsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=3DMsoNormal>Of current ES5 implementations in progress,<o:p></o:p>=
</p>
</div>
<div>
<p class=3DMsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=3DMsoNormal>* TraceMonkey and SES5/3 (Mike Stay's emulation of the
Secure subset of EcmaScript 5 strict on current ES3R browsers) currently gi=
ves<o:p></o:p></p>
</div>
<div>
<p class=3DMsoNormal> the empty string, <o:p></o:p>=
</p>
</div>
<div>
<p class=3DMsoNormal> meaning that the non-enumerable "x&qu=
ot; in
derived shadows the enumerable "x" from base.<o:p></o:p></p>
</div>
<div>
<p class=3DMsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=3DMsoNormal>* WebKit nightly and V8 currently gives<o:p></o:p></p>
</div>
<div>
<p class=3DMsoNormal> "x: 9"<o:p></o:p></p>
</div>
<div>
<p class=3DMsoNormal> meaning that the enumerable "x" =
from
base shows through, causing the above loop to look up the value of the
unenumerable shadowing "x" property.<o:p></o:p></p>
</div>
<div>
<p class=3DMsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=3DMsoNormal>I have not tested any other partial ES5 implementation=
s
(Rhino, ObjectPascal, ??).<o:p></o:p></p>
</div>
<div>
<p class=3DMsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=3DMsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=3DMsoNormal>The relevant test seems to be ES5 section 12.6.4 step =
6.a
(and likewise 7.a for the next production):<o:p></o:p></p>
</div>
<div>
<p class=3DMsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=3DMsoNormal> Let P be the name of the nex=
t
property of obj whose [[Enumerable]] attribute is true.<o:p></o:p></p>
</div>
<div>
<p class=3DMsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=3DMsoNormal>From this text, I think either interpretation is possi=
ble.
However, since a common pattern for using for-in uses the enumerated key to
look up the corresponding value on the object being enumerated (e.g.,
"obj[k]" above), I think that the more useful interpretation is t=
he
one currently employed by TraceMonkey and SES5/3. <o:p></o:p></p>
</div>
<div>
<p class=3DMsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=3DMsoNormal>I think a clarification of this issue be added to the =
ES5
errata. I propose that this clarification adopt the more useful suppression
behavior, and suggest that ES5 implementations in progress switch to that
behavior. Whichever disambiguation is adopted, I'll be happy to file bugs
against the implementations with the non-conforming behavior. We should als=
o
add a test for this to es5conform.<o:p></o:p></p>
</div>
<p class=3DMsoNormal><br>
-- <br>
Cheers,<br>
--MarkM<o:p></o:p></p>
</div>
</div>
</body>
</html>
--_000_90EDC335A511F2479C63F7337D3CE7DB41DEFDE2TK5EX14MBXC116r_--
More information about the es-discuss
mailing list