>> .huh? I'm not talking about exceptions the object itself throws. In PHP 7, 
>> if Nikita's RFC passes, trying to call a method on
>> NULL will throw an exception. That largely negates the need for a special 
>> operator, since you can just catch the exception.
>> 
>> Thanks.
>> --
>> Andrea Faulds
>> 
> 
> I think it is a matter of taste whether you use try/catch as control 
> structure or only as exception handling. I for
> myself usually try to avoid using it as control structure and thus would 
> write something like:
> if($a !== null){
>   $a->foo(bar());
> }
> 
> And for this case the ?-> operator seems perfect for me

Yeah, this is exactly the point I was trying to make, sorry it wasn't clear: 
that when to use exceptions are up to taste, and in my taste (and others'), 
catching exceptions here aren't appropriate in the slightest. (Not that 
*throwing* them is wrong -- if you expect that object to be non-null, then 
throwing one is great -- my problem is with dealing with that failure by 
immediately catching it. See my original post for the extended explanation.)

So I find this operator really useful here.

Josh


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

Reply via email to