Re: [VOTE] Stricter implicit boolean coercions
| From: | Guilliam Xavier | Date: | Fri, 24 Jun 2022 11:05:15 +0000 |
| Subject: | Re: [VOTE] Stricter implicit boolean coercions | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-118079@lists.php.net to get a copy of this message | ||
> It would have been interesting to get some more feedback on why people
> voted No - some took part in the discussion, but most didn't.
Indeed... Of those who did, I have retained the following arguments
(sorry in advance for any omission, approximation or
misinterpretation):
- no impact analysis (but seems difficult...)
- it would increase the discrepancy between e.g.
if ($x) and
takes_bool($x) (already existing for non-scalar $x [okay VS
TypeError], but now for scalar $x too [okay VS deprecation notice])
- the deprecation should apply to all floats (even 0.0 and 1.0)
because floating-point equality is risky
- the deprecation should include the string "0" (VS empty "")
because it's a recurrent WTF (and maybe even in all implicit boolean
evaluations [e.g. if, && etc.] too)
- we should rather deprecate takes_bool($string) and
takes_bool($float) totally (i.e. all strings and floats), and also
takes_string($bool) and takes_float($bool) (but maybe don't need
to change takes_bool($int) at all)
Note: I think that generally there can be arguments in both ways...
> I think the RFC would have helped
> identify obvious bugs
I agree ;(
> thanks to everybody who took part in the discussion, it was an
> interesting experience.
Thank you ;)
> If anybody still wants to give some insight on these reasons or a way to
> improve boolean coercions in another way, I would be happy to hear it.
Sorry I don't have better ideas... Maybe others will?
--
Guilliam Xavier