Hi!

      function age_check($age)
      {
          if (!is_int($age)) {
              throw new InvalidArgumentException;
          }
      }

  With the above code, the caller needs to cast and the writer of the
  age_check() function has to copy/paste/adapt these checks to all the
  correct places ...

That's because you should be using is_numeric in this context ;) And have an answer on the question "what happens if it's not" that does not involve "throwing exception that nobody is going to catch". Of course, you can't design proper library in one line. The idea is that strict typing doesn't make such design easier, since it does not lead to less work.
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to