ES4 draft: strict mode

Waldemar Horwat waldemar at google.com
Wed Apr 16 16:09:27 PDT 2008


Compatibility syntax:

For ES3 compatibility it would be simpler to just use:
  use
  strict
which parses as two expression statements in ES3.


>       |this| never captures the global object
> 
> In ES3, when a function is called "as a function" (that is, not as a 
> method on some receiver object -- the notion is not syntactic, but can 
> depend on the binding of the function) the value of |this| passed to the 
> function is *null*. The callee (or the call protocol) substitutes the 
> callee's global object for the *null* value, so the value of |this| 
> observed in the callee is the callee's global object.
> 
> If the callee is strict, however, the *null* is not converted to the 
> callee's global object. Instead, if the callee evaluates the expression 
> |this| when the value of |this| is *null* then a *ReferenceError* is 
> thrown.
> 
> *FIXME*   We want to make that more precise but the current prose 
> captures the intent well enough.

ES3 also special-cases <undefined>.

If I do
Foo.call(undefiend, x, y)

and Foo tries to get the value of <this>, then it will throw an error instead of returning <undefined>?


1.5.1:  I prefer the lightweight variant.


1.5.2:  This can lead to trouble.  For example, is the statement
x && f();
provably effect-free?  What if the compiler discovers that x is a constant with the value false?

What about the following?
...
globaleval("make x have a getter with a side effect");
...
x;


> *NOTE*   It's daring of us to standardize restrictions on the behavior 
> of a feature that's not itself specified by the Standard.

I agree.  This does not belong in the standard.  If we have a non-normative appendix, it might go there.

    Waldemar



More information about the Es4-discuss mailing list