Re: 'Uninitialized' creates a lot of cluttering
| From: | Andreas Heigl | Date: | Mon, 13 Feb 2023 12:31:34 +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-119544@lists.php.net to get a copy of this message | ||
Hey all.
On 13.02.23 13:12, Robert Landers wrote:
[...]
Attachment: [application/pgp-signature] OpenPGP digital signature OpenPGP_signature.asc
Perhaps we need to think about introducing "undefined" to make that clearer? But what is actually clearer than throwing an error when trying to access something that is undefined... https://stackoverflow.com/questions/5076944/what-is-the-difference-between-null-and-undefined-in-javascript So how complicated would it be to throw that same error when assigning the return type of a void function to a variable? Cheers Andreas -- ,,, (o o) +---------------------------------------------------------ooO-(_)-Ooo-+ | Andreas Heigl | | mailto:andreas@heigl.org N 50°22'59.5" E 08°23'58" | | https://andreas.heigl.org | +---------------------------------------------------------------------+ | https://hei.gl/appointmentwithandreas | +---------------------------------------------------------------------+ | GPG-Key: https://hei.gl/keyandreasheiglorg | +---------------------------------------------------------------------+What is the point of marking the type of a property, other than to prevent mistakes?In non-strict mode, it coerces quite nicely. For example, a string to an integer or an integer to a string. These aren't "mistakes" but making use of the language features.For a type of ?int, null is indeed a valid value; but so is 0, and -1, and so on. Why should the language assume that one default, among all the possibilities, if you don't specify any?I hope we can all agree thatnullis the absence of a value. Now we currently have two different meanings of "absence of a value" which is super annoying sometimes. We have two different "things" that currently return a NULL value. Similar to a function with a void returntype still returning NULL.
Attachment: [application/pgp-signature] OpenPGP digital signature OpenPGP_signature.asc