On Sun, Feb 12, 2023 at 6:47 PM Rowan Tommins <rowan.coll...@gmail.com> wrote: > > On 12 February 2023 11:11:31 GMT, Lydia de Jongh <flexj...@gmail.com> wrote: > >The features of a programming-language should not be about preventing > >mistakes, imho. > > > What is the point of marking the type of a property, other than to prevent > mistakes? > > > >For me it is about the cluttering in an otherwise clean property list. > > > It's only "clutter" if you don't think it conveys useful information, and > that's obviously a matter of opinion. > > > >And I think that implicit null on nullable properties could fit nicely > >here. For null is a valid value for a nullable. > > > 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? > > > Regards, > > -- > Rowan Tommins > [IMSoP] > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php >
> 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 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. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php