On 27 May 2010 12:14, Zeev Suraski <z...@zend.com> wrote: > BTW - even if strict type checking was implemented, do you truly think > people won't simply cast their inputs to make PHP shutup about "42" not > being a valid int? Let me assure you, they would. You'd gain nothing - as > a matter of fact you'd lose out a bit since "abc" strings or arrays will > happily cast into (int), while with our proposed solution - they won't.
But it would be the user making that choice though. Rather than the developer having to handle the incorrectly typed value. As I see it, it is no difference than interfaces. A class with interface X has to implement whatever methods interface X declares. Failure to do so results in fatal errors. And rightly so. A function with prototype (int $a, bool $b, string $c) has to be supplied the correctly typed data to work. Why is that so wrong? Lazy users are lazy. We know this. How much coding should we (the developers) do to protect the users from themselves. All that type validation code in our function/methods because of the possibility that bool == int == string == float == array can so easily be handled by the engine itself. The so-called big plus of weak/loose typing doesn't seem as big as you are all making it out to be. In any decent course regarding defensive programming, we are told to filter input and escape output. One easy way of filtering input is to cast and verify. Once cast and verified we know we've got the right type and acceptable values. In databases, you can't usefully have a column containing multiple types. Everything would end up as a char/text column to allow you to put a date AND a string AND a number AND a boolean value in the column. Regards, Richard. -- ----- Richard Quadling "Standing on the shoulders of some very clever giants!" EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php