On Dec 28, 2012, at 11:47 AM, Andreas Rossberg <rossb...@google.com> wrote:
> 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. Thanks for the clarification. > 2. Those where the initialization cannot happen before the respective > declaration has been reached (because it may depend on effectful > computations). > > 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. The class's `extends` clause has to be evaluated and can have arbitrary user code, side effects, etc. Similar for possible future clauses like computed property value expressions. > That seems clean, useful, consistent, and fairly easy to understand. > Introducing extra rules for 'let'? Not so much. But TDZ does introduce extra rules! Especially with disallowing assignment temporally before initialization. Dave _______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss