Re: [RFC] Safe Casting Functions

From: Date: Tue, 21 Oct 2014 22:51:11 +0000
Subject: Re: [RFC] Safe Casting Functions
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-78214@lists.php.net to get a copy of this message
> On 21 Oct 2014, at 10:14, Dmitry Stogov <dmitry@zend.com> wrote: > > some notes: > - it's probably make sense to implement these function as a new opcode(s) in VM That could be an optimisation later, yes. I note that you’ve added function replacement with opcodes for certain commonly-used functions. We could make these functions use that. Then they’d still be usable as callbacks. > - in case of conversion failure it's better to throw exception (to_int() returning FALSE > is a pain). 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. -- Andrea Faulds http://ajf.me/

« previous php.internals (#78214) next »