No subject


Sun Jan 18 01:12:33 PST 2009


conversations), can we agree that FF's current behavior violates both what
ES3.1 does and should specify?


-- 
   Cheers,
   --MarkM

--0016366975601e005b0460cfdfb3
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

On Sun, Jan 18, 2009 at 8:47 PM, Brendan Eich <span dir=3D"ltr">&lt;<a href=
=3D"mailto:brendan at mozilla.com">brendan at mozilla.com</a>&gt;</span> wrote:<b=
r><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"bor=
der-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-=
left: 1ex;">
<div class=3D"Ih2E3d">On Jan 18, 2009, at 6:03 PM, Mark S. Miller wrote:<br=
>
<br>
<blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, =
204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
A related difficulty, not addressed by the above spec, is shadowing. Does t=
he following program contain a direct call to eval (i.e., a use of the &quo=
t;eval operator&quot;)?<br>
<br>
 &nbsp;function foo(eval, str) {<br>
 &nbsp; &nbsp;return eval(str);<br>
 &nbsp;}<br>
</blockquote>
<br></div>
<br>[...]&nbsp;
The standard approach is to check for a callee named &#39;eval&#39; and emi=
t a distinguished instruction which acts like the generic call instruction.=
 [...] checking for a known identifer when parsing call expressions, [...]
So the above eval call would be &quot;apparently-direct&quot;, [...]<br>
<br>
Note that there&#39;s no way at runtime to change an apparently-direct eval=
 into an indirect eval call. But an apparently-direct eval can turn into a =
plain old call.</blockquote><div><br>Good. <br><br>
</div><blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid rgb=
(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class=
=3D"Ih2E3d"><blockquote class=3D"gmail_quote" style=3D"border-left: 1px sol=
id rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

The eval variable being called here is not an alias for the &quot;eval&quot=
; property of the global object, though it may or may not have the same val=
ue. If the answer is that this is not a direct call,<br>
</blockquote>
<br></div>
That&#39;s the wrong answer -- it should be direct purely because the calle=
e name is &#39;eval&#39;.<br><div class=3D"Ih2E3d"></div></blockquote><div =
class=3D"Ih2E3d"><br>So the use of &quot;property&quot; in the spec:<br><br=
>
<blockquote style=3D"border-left: 1px solid rgb(204, 204, 204); margin: 0pt=
 0pt 0pt 0.8ex; padding-left: 1ex;" class=3D"gmail_quote">If
strict mode code uses the value of the eval property any way other than
as a direct call (that is, other than by the explicit use of its name
as an Identifier which is the MemberExpression in a CallExpression), or
if the eval property is assigned to, an EvalError exception is thrown.<br><=
/blockquote>
<br>means the original *value* of the global eval property (in which case t=
he statement of the assignment constraint is wrong)? And &quot;its name&quo=
t; above means specifically &quot;eval&quot;, whether referring to a proper=
ty or a local variable?<br>
<br><br>
<blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, =
204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
since the defining occurrence is local, then what about the second &quot;ev=
al&quot; in the following code?<br>
<br>
 &nbsp;function foo(str1, str2) {<br>
 &nbsp; &nbsp;eval(str1);<br>
 &nbsp; &nbsp;eval(str2);<br>
 &nbsp;}<br>
</blockquote>
<br></div><blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid=
 rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Same answer -- these are two &quot;direct&quot; eval calls by the compiler&=
#39;s lights.<div class=3D"Ih2E3d"></div></blockquote><div><br>Good.<br>&nb=
sp;</div><blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid =
rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class=3D"Ih2E3d"><br>
<blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, =
204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Since foo may be called as foo(&#39;var eval =3D f&#39;, ..), the second ev=
al may refer to a local or to a global eval. These ambiguities defeat the g=
oal of distinguishing direct from indirect calls.<br>
</blockquote>
<br></div>
Not in practical implementations that nevertheless do no expensive analyasi=
s, as sketched above.<div class=3D"Ih2E3d"></div></blockquote><div><br>Give=
n your other answers, I don&#39;t think we have a problem here.<br>&nbsp;<b=
r>
<br></div><blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid=
 rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div cl=
ass=3D"Ih2E3d"><br>
<blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, =
204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Though the above specific problem cannot occur if foo is strict, I propose =
that, for all code, one may not define a local variable named &quot;eval&qu=
ot;.<br>
</blockquote>
<br></div>
This is unnecessary, and I&#39;m not sure it&#39;s sufficient given your as=
sumptions.</blockquote><div><br>I think I&#39;m happy with your earlier ass=
umptions above; in which case it would be sufficient to prohibit defining l=
ocal variables named &quot;eval&quot;.<br>
&nbsp;</div><blockquote class=3D"gmail_quote" style=3D"border-left: 1px sol=
id rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> But =
we shouldn&#39;t have to worry about any shadowing or rebinding issues if w=
e can specify what popular implementations do.<br>
<font color=3D"#888888">
</font></blockquote><div>&nbsp;</div></div><br>What Firefox current does (3=
.0.5):<br><br><div class=3D"input">&nbsp;&nbsp;&nbsp; function foo(a, b, c)=
 {
  return a(b);
}</div><div class=3D"input">&nbsp;&nbsp;&nbsp; foo(eval, &#39;c&#39;, 42); =
// returns 42<br></div><br>From my understanding of your statements above (=
as well as previous
conversations), can we agree that FF&#39;s current behavior violates both w=
hat ES3.1 does and should specify?<br><br><br>-- <br> &nbsp; &nbsp;Cheers,<=
br> &nbsp; &nbsp;--MarkM<br>

--0016366975601e005b0460cfdfb3--


More information about the Es-discuss mailing list