Setting this to null instead of throwing ReferenceError in a derived class' constructor
Andreas Rossberg
rossberg at google.com
Wed Jan 21 01:43:32 PST 2015
On 20 January 2015 at 23:25, Brendan Eich <brendan at mozilla.org> wrote:
> Ryosuke Niwa wrote:
>
>> Having said that, TDZ was introduced to give "let", "const", and alike a
>> sensible behavior as I understand it. Since "this" was never defined by
>> "let" or "const", it seems a little arbitrary and inconsistent to make
>> "this" TDZ only inside a derived class's constructor.
>>
>
> It's not arbitrary as in a fair coin toss -- it's intentionally biased to
> catch errors. Using null or undefined would find fewer errors.
>
> I'm wondering whether other implementors feel the same pain. I mailed a
> few V8 folks asking them, maybe they'll weigh in.
Like with other occurrences of temporal dead zones, for the vast majority
of cases you should typically be able to tell statically (and easily) that
you don't need runtime checks.
But Dmitry is the one currently updating the implementation in V8, so he
might know more concretely.
/Andreas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150121/99fe7b42/attachment.html>
More information about the es-discuss
mailing list