On Tue, Jun 7, 2011 at 1:02 AM, Stas Malyshev <smalys...@sugarcrm.com> wrote:
> Sure. How about reducing boilterplate code like this:
>
> if(is_readable($foo)) {
>  $var = file_get_contents($foo);
> } else {
>  throw  InvalidArgumentException();
> }
>
> Why won't we make language construct to do that too? I don't think these
> things belong in the language syntax.

The whole point is that callables are generally not constructed from
user input, they're hardcoded in the code somewhere, and so if a fatal
error occurs, the developer notices it, hopefully during development.

With is_readable, a file can be anywhere, anytime, readable or not, it
depends on the environment the code runs on, and not on the code
itself, so it's not deterministic and you should therefore be able to
easily handle this gracefully.

Cheers

-- 
Jordi Boggiano
@seldaek :: http://seld.be/

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

Reply via email to