Hi!

> I agree with you. If someone really wants to have an "uninitialized" field
> on purpose, they should do that using the correct type declaration, i.e.:
> 
> ?MyType $myNullable = null;
> 
> When this was started I asked if it was possible to check types right after
> object has been constructed, but they said it was inefficient to do so.
> If this is still true, then I'm ok with checking on first access instead. I
> don't want even more overhead from runtime type checking.
> This is definitely not as bad as the "billion dollar mistake" though. The
> error still happens, but in a different place.

In Java, avoiding these kinds of errors - when the property is not
initialized - is almost trivial, and that's not what "billion dollar
mistake" is about. Lack of initialization for a final value (which is a
frequent case with property values) is detected by the compiler, and
most IDEs/analysis tools would alert of lack of initialization for
non-final value too. The problem is with usage on null as a substitution
for no value/error/unknown value and this value bleeding out into parts
of the code that don't know how to handle this situation.

-- 
Stas Malyshev
smalys...@gmail.com

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to