Re: 'Uninitialized' creates a lot of cluttering
| From: | Claude Pache | Date: | Mon, 13 Feb 2023 14:57:19 +0000 |
| Subject: | Re: 'Uninitialized' creates a lot of cluttering | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-119546@lists.php.net to get a copy of this message | ||
> Le 13 févr. 2023 à 13:12, Robert Landers <landers.robert@gmail.com> a écrit :
>
> I hope we can all agree that
null is the absence of a value.
> Now we
> currently have two different meanings of "absence of a value" which is
> super annoying sometimes.
>
Although null is often used with that semantics in mind, from a technical point of
view, it is definitely not the same thing as “absence of a value”. For example:
```php
function dump_answer($answer = 42) {
var_dump($answer);
}
// null
dump_answer(null); // NULL
// absence of value
dump_answer(); // int(42)
```
Or:
```php
$a = [ 'foo' => null ];
// has value null
var_dump(array_key_exists('foo', $a)); // true
// is absent
var_dump(array_key_exists('bar', $a)); // false
```
—Claude