Finding a "safety syntax" for classes

Allen Wirfs-Brock allen at wirfs-brock.com
Fri Mar 23 12:40:52 PDT 2012


On Mar 23, 2012, at 11:33 AM, Russell Leggett wrote:

> On Fri, Mar 23, 2012 at 2:06 PM, Brendan Eich <brendan at mozilla.org> wrote:
> Brendan Eich wrote:
> We need to overcome at least one TC39er who values 
> "requiring an error for"
> 
> use-before-init for instance properties, perhaps only if const or guarded, so (I hope) we can defer those without being hostile to them in the future. 
> Hope it was clear the first time...
> 
I think that   the current "maximal minimal" proposal is quite future friendly WRT any future hoisting variants .  Presumably any new alternative hoisting semantics for class declarations would only be observable in that some things that had been a runtime (or possible early) error under the current proposal might no longer be errors.  Defining a new non-error semantics for what was perviously an error condition is usually a safe change.

> I'll admit I was a little confused. Makes sense now. To be clear, you would be referring to:
> 
>     let foo = new Foo();
under the current proposal the above is also an error, because Foo is not yet initialized. You would never get to the next statment.

>     foo.fail(); //this should be an error
>     
>     class Foo {
>         fail(){
>             alert("This alert won't happen.");
>         }
>         
>         success(){
>             alert("This should be fine");
>         }
>     }
>     
>     let foo2 = new Foo();
>     foo2.success(); //would work fine
> 
> and by error you mean before the code is actually evaluated?
> 
> - Russ
> 
>  
> 
> 
> /be
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
> 
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120323/f6810f84/attachment.html>


More information about the es-discuss mailing list