On 11 March 2017 13:53:10 GMT+00:00, Andrey Andreev <n...@devilix.net> wrote: >I don't disagree with that in general, but strictly rejecting strings >and other non-integer values would alleviate the problem for a >majority of cases; i.e. would solve the 90% problem.
I guess I just don't see that as 90% at all. The interesting values to detect are the ones that are out of range, not just that somebody wrote '4' instead of 4. >What I strongly disagree on is that I should be happy with coercion, >and the almost religious resistance against (non-overridable) strict >scalar typing. For me, it's about division of responsibility: a library defines a contract, and it's up to me how I meet that contract. If I go through writing (string) everywhere, or use a pre-compiler that does that for me, I'm meeting the contract. It's no more the library's business than whether I use an IDE with dozens of templates, or hand craft my code in notepad. All coercive typing does is turn that pre-compiler on by default. What's more interesting to me is how the library can express the contract it actually wants, and scalar types by their nature make for weak constraints. All of the examples you've given are good illustrations of that, and that's why I've been trying to tease out some things that the language could do to actually help with those cases. Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php