Re: [RFC] Safe Casting Functions

From: Date: Wed, 22 Oct 2014 08:07:54 +0000
Subject: Re: [RFC] Safe Casting Functions
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-78218@lists.php.net to get a copy of this message
On 21/10/14 23:51, Andrea Faulds wrote: > I am gradually warming to throwing an exception. An interesting idea I’ve had suggested on > Twitter was by Matt Parker, who suggested that I add an optional 2nd argument. Without the argument, > it throws an exception. With an argument, it returns that value (as a default) instead of throwing > an exception. Now that sounds like a nice compromise in a few places where exceptions have been introduced, but I still think this is still a little chicken and egg. If it is going to 'fail' then the reason for the failure is more important than simply producing no answer. Especially if it is going to fail in different inputs to other methods. Again forcing an exception only solution sidesteps that debate! -- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

« previous php.internals (#78218) next »