Class declarations

Brendan Eich brendan at mozilla.org
Fri Mar 16 15:50:42 PDT 2012


Brendan Eich wrote:
> We can defer these by deferring guards and const instance properties, 
> and tried to do so. But IIRC at least Waldemar was not happy leaving 
> writable instance properties usable (with default value undefined) 
> before being initialized.

Of course, Dart allows this and discloses null on use before initialization:

class Foo {
   var a;
   Foo(a) {
     print(this.a);
     this.a = a;
   }
}
main() {
   var foo = new Foo(42);
   print('main: ' + foo.a);
}

Tested at http://dartlang.org/.

/be


More information about the es-discuss mailing list