On Fri, Mar 16, 2012 at 4:22 PM, Brendan Eich <[email protected]> wrote:
> > And properties can be used before initialization in JS today (and in Dart > -- you Google guys are not all following the same rules :-P). > This is definitely the strangest possible venue for discussing Dart, but... That isn't entirely true. For non-final variable, yes, they can be used before initialization. (Or, maybe more accurately, all variables are implicitly initialized to null at the moment of instantiation before the constructor body is invoked.) However, for final fields (i.e. single-assignment instance properties), they *must* be initialized before the constructor body (in the C++-like constructor initialization list) and the initializer does not have access to this. Final fields cannot be observed before explicit initialization. Honestly, it's kind of a pain. It was designed that way, I think, for performance reasons, but it just ends up making it harder to use final fields. You end up not be able to use them if you want to do non-trivial initialization or circular references. Anyway, back to JS... ;) - bob
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

