On 07.06.2011, at 12:09, Jordi Boggiano wrote:

> 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.

Precisely.

I'd love to see a "callable" type hint too. And a "scalar" one while we're at 
it ;)

David

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to