Re: [PHP-DEV] [RFC] Reclassifying engine warnings

  106774
August 28, 2019 20:43 smalyshev@gmail.com (Stanislav Malyshev)
Hi!

> Because it's explicit, and incrementing null is mathematically > unintuitive. After all, null does not exist anywhere in the set of
It is well-established in programming that default value for numeric types is 0 (many Java IDEs, for example, will explicitly tell you if you initialize a numeric value to 0 that it's not necessary). It is also well established that natural conversion of null to numeric is 0. I don't see anything non-intuitive here. Even if you have no idea about programming at all, how do you start counting? You had nothing, than one, then two, etc. You don't count like "did I start counting? No? Then nothing. Did I start again? Oh, now I did, then it's one. Did I start again? Oh yes, I did already, so it's two.". Nobody counts like that. It's completely non-intuitive and that's why I called it a clunker. It's working around language trying to be "helpful" but ending up forcing extra work because it looked "cleaner" to somebody.
> ?? Let's you go "I know this index may not exist, if it doesn't, use 0 > instead". No funky type coercions that are in no way apparent from > looking at the code.
Everybody - I mean literally everybody, I have not seen any exceptions I can think of over my 30+-year career in software - wants to start from 0 if counting wasn't started yet. If they didn't, there would be explicit initialization beforehand, you don't just suddenly forget you want to start counting from 100, it's an unusual thing that you remember. Starting from 0 you don't have to remember because everything starts from 0. There's no case for it being anything else. There's no need to make it explicit - nobody would imagine you mean anything but that, because nobody ever does anything but that ever. Spelling it out is just wasting time for the sake of being "strict". No added value.
> To use the analogy someone posted elsewhere... the training wheels are > coming off. Time to be responsible and type those few extra characters > to be clear on your intent.
Removing training wheels doesn't mean putting a boot on instead. No need to make something harder just for the sake of forcing people to explicitly acknowledge the situation that is obvious for everybody anyway. There can be only one intended way this construct could work, and it should work this way without spelling it out explicitly. -- Stas Malyshev smalyshev@gmail.com