Hi!

> It'd be a BC break if we changed untyped properties' behaviour, yeah. We

It's not that simple. Lots of code operates on sets of properties or
dynamic properties, not one specific property. That code now assumes
properties default to null. If there's another default, then all that
code will have to be changed in case somebody somewhere defines a typed
property.
The impact is that as soon as one typed property appears anywhere in the
code, pretty much all the code that deals with properties (within
affected property set) has to be changed to accommodate it. Unlike
parameters, which are local to function, properties are important across
big chunks of the code.

> wouldn't be inventing a new null, though, we'd be leaving the property
> undefined until it's initialised, which we already have support for
> (properties, and indeed all variables can be unset()).

unset() now causes the property to disappear - as if it were never
defined. But you probably expect something different? So what isset()
would return for such property? What would is_null() return? What would
gettype() return?

>>> A simple example might be a Lisp-style linked list cell:
>>>
>>>      class LinkedList
>>>      {
>>>          public int $head;
>>>          public ?LinkedList $tail;
>>>      }
>>>
>>> In a properly initialised LinkedList, the $head is some value, and the
>>> $tail is either another linked list (the remainder of the list), or null
>>> (we're at the end of the list).
>>
>> This is a very weird list, as it can't be empty.
> 
> The empty list is represented by null in this arrangement.

null and empty list are very different thing. null is nothing, empty
list is an object of type LinkedList which just happens to not contain
any values. You can call methods on empty list - e.g. add elements to it
or check if it's empty or compare or concatenate with other list, etc. -
but you can't do it on null. Making assumption that null and an empty
container is the same is not a good idea usually.

-- 
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