I agree with Waldemar. Classes aside, since code like
{
//...foo...
let x = 3;
function foo() { return x; }
//...
}
is statically legal, and is only wrong if foo is called before x is
initialized, the dynamic dead zone is very valuable. Otherwise, the call to
foo() silently proceeds with a meaningless result.
If you'd really rather have silent meaninglessness, use "var" instead of
"let".
On Fri, Mar 16, 2012 at 3:50 PM, Brendan Eich <[email protected]> wrote:
> 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
> ______________________________**_________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/**listinfo/es-discuss<https://mail.mozilla.org/listinfo/es-discuss>
>
--
Cheers,
--MarkM
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss