Hi Joe,

> Accessing the property before it was unset though, as it always did,
> attempts to read the default value (null).
>
> We haven't changed any of that ...
>


Yes, you're right, this is exactly how it currently behaves :
https://3v4l.org/YpfYe (apologies for not checking this first).
Still seems inconsistent, but that's now outside the scope of the RFC.


> The most you can say about this, is that it's strange that the same
> exception is raised for both cases, which we're aware of; Right now, it's
> impossible to distinguish between the two states.
>

Makes sense. AccessTypeError, WriteTypeError to both extend TypeError?


>
> The things you can be sure of:
>
>  -  If you get a value from an access of a typed property, it is the
> correct type.
>  -  If you get exceptions, you have logical errors in your code.
>

Perfect. I'd still prefer the TypeError to only occur on setting rather
than on access as well (along with a fair amount of others:
https://twitter.com/leedavis81/status/710872866556874753), this would then
have the RFC only concerned itself with the WHAT rather than the WHEN, but
as long as that promise can be upheld then it's a great feature to have.

I think adding in rules at the language level to dictate when it should be
set (i.e after construct) is a bad move, so I'd be in favour of leaving it
as it stands at the moment. Property accessors could solve the problem of
uninitialised properties later on.

Cheers for all your hard work guys,

Lee
/@leedavis81

Reply via email to