I am not talking about defining implicit properties or such things,
neither having undeclared stuff looking declared, but just changing the
behavior of retrieving a property when base is undefined, which will
then be undefined.
If am I reading correctly the specs, doing this change will work for
a.b.c.d, because undefined is returned first and nothing is set
anywhere, unless I am wrong :
console.log(a); //reference error
var a;//undefined
console.log(a.b);//reference error
will become :
console.log(a); //undefined
var a;//undefined
console.log(a.b);//undefined
Le 15/06/2012 15:52, T.J. Crowder a écrit :
On 15 June 2012 14:34, Aymeric Vitte <[email protected]
<mailto:[email protected]>> wrote:
Example :
console.log(a);//Reference error, GetBase returns undefined
console.log(window.a);//undefined
--> does not seem very logical, no ?
To me this would be a big step backward, after the very large stride
forward this group made in ES's strict mode of making _assigning_ to
an unresolvable reference an error rather than an implicit creation of
a property on the global object.
For one thing, how is the engine to know that the `a` in question was
meant to be `window.a`? Maybe I just forgot to put `var a` in the
current scope. (In fact, that's usually what it is when I get this error.)
Scope is not the same as an object (although of course, the scope
chain is conceptually made up of binding objects). If I refer to `a`
in my code and `a` has never been declared, that's a bug, and as I
haven't told it, the engine has no way of knowing what level in the
scope chain I intended `a` to be in. If I access the `a` property of
an object, and the property has never been defined, that could just be
lazy initialization; the engine knows that I'm talking about that
specific object (or its prototypes), because I've told it what object
to look at.
Separately:
(ie a way that this works : if (a.b.c.d) {} when a,a.b, etc are
not set)
Making the initial `a` evaluate to `undefined` wouldn't make that
work: Instead of the ReferenceError, you'd get a TypeError (cannot
read property `b` of undefined).
-- T.J.
--
jCore
Email : [email protected]
Web : www.jcore.fr
Webble : www.webble.it
Extract Widget Mobile : www.extractwidget.com
BlimpMe! : www.blimpme.com
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss