> On 24 Nov 2014, at 16:08, Patrick ALLAERT <patrickalla...@php.net> wrote:
> 
> 
> Le Wed Nov 19 2014 at 10:57:39 PM, Levi Morrison <le...@php.net> a écrit :
>   - PHP suffers a lot from function bloat and this RFC provides
> multiple functions that do the same thing but differ only in how they
> handle errors. A simple validation of "can this be safely cast to an
> integer without dataloss?" avoid the issue entirely and would be fewer
> functions.
> 
> My "no" is mostly for the reason above, mentioned by Levi and also because of 
> the use of Exception (previously mentioned by Derick as well).
> 
> To improve this RFC, I would:
> - use errors/warnings instead of exceptions (unless there is a more global 
> approach on this aspect for PHP 7).

Errors in PHP are horrible to handle. There’s absolutely no question of this 
RFC being revived using errors, at all. If I must, I’ll wait until exceptions 
are inevitably approved for core in PHP 7. Assuming they actually are. If they 
aren’t, I might actually quit PHP...

> I would personally appreciate a syntax closer to the current casting 
> mechanism, e.g.:
> 
>     $int = (=int) "42"; // result: (int) 42
>     $string = (=string) 42; // result: (string) "42"
>     $int = (=int) "foobar"; // result: E_ERROR: Can not cast (string) 
> "foobar" strictly to an int
> 
>     $int = (~int) "42"; // result: (int) 42
>     $int = (~int) "foobar"; // result: E_WARNING: Can not cast (string) 
> "foobar" strictly to an int

PHP already already has enough bizarre syntaxes, I don’t think it needs even 
more.

--
Andrea Faulds
http://ajf.me/





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

Reply via email to