On dropping @names
rossberg at google.com
Fri Dec 28 11:47:01 PST 2012
On 28 December 2012 19:54, David Herman <dherman at mozilla.com> wrote:
> On Dec 28, 2012, at 2:29 AM, Andreas Rossberg <rossberg at google.com> wrote:
> >> Can these "plenty" be enumerated? Apart from const, which ones have
> > All declarations whose initialization cannot be hoisted. My
> understanding is that that would be 'const', 'class' and 'private',
> although we have just dropped the latter from ES6. There might potentially
> be additional ones in future versions.
> Wait, can you specify which meaning of "hoist" you mean here? All of
> const, class, and private would still be scoped to their entire containing
> block, right? They just wouldn't be pre-initialized before the block starts
Yes, sorry for using the confusing term again. Maybe we should just ban it.
I think we all agree that all lexical declarations should have the same
lexical visibility -- which is the entire block. But there will be
differences in life time, i.e. when initialization takes place.
We can identify two classes of lexical declarations:
1. Those where initialization can be performed at the start of the scope
(which is what I meant by "hoisted" above), and the bound variable can
safely be accessed throughout the entire scope.
2. Those where the initialization cannot happen before the respective
declaration has been reached (because it may depend on effectful
For the first group (function, module), there is no problem. For the second
(let, const, class, private -- although TBH, I forgot the reason why
'class' is in this group), we have temporal dead zone, where accessing a
variable before its initialization is an error.
That seems clean, useful, consistent, and fairly easy to understand.
Introducing extra rules for 'let'? Not so much.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss