On 15 Jul 2014, at 18:39, Rowan Collins <[email protected]> wrote:
> Ooh, skimming that, I see suggestions for prefixes and suffixes to represent
> types of cast (or hint).
>
> That fits nicely with my thoughts on making "strict cast" a first-class
> citizen of the language, rather than isolating it to function signatures,
> e.g.:
>
> $foo = 'abc'; $foo = (int)$foo; // OK, evaluates to int(0)
> $foo = 'abc'; $foo = (int!)$foo; // ERROR
> $foo = '42'; $foo = (int!)$foo; // OK, evaluates to int(42)
It’s a shame Nikita’s Exceptions in the Engine RFC failed, as being able to do
this would be nice:
try {
$foo = (int!)$foo;
} catch (RecoverableError) {
$foo = 1;
}
Perhaps some sort of similar syntax? `(int!)$foo else 0`?
--
Andrea Faulds
http://ajf.me/
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php