RE: [PHP-DEV] [RFC] Scalar Type Hinting With Casts (re-opening)
| From: | Zeev Suraski | Date: | Sun, 13 Jul 2014 11:35:43 +0000 |
| Subject: | RE: [PHP-DEV] [RFC] Scalar Type Hinting With Casts (re-opening) | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-75389@lists.php.net to get a copy of this message | ||
> I don't see the current PHP type juggling as 'formal programming'. It
makes
> things easy but can also lead to bugs where unexpected values (& so
types)
> end up being inappropriately used.
I haven't yet reviewed the conversion table in detail, but unless I'm
missing something, this RFC is in fact much more in the spirit of PHP -
and implements type juggling - unlike the previous incarnation of strict
typing that almost made it into PHP. It's a bit too strict to my liking
(especially around conversion of floating point to int, which should pass
and perhaps generate a notice IMHO), but this is a big step towards the
spirit of what I proposed together with Lukas back in 2010
(https://wiki.php.net/rfc/typecheckingstrictandweak) - which was an
alternative to the strong typing suggested by several others.
Type juggling is an *inherent* feature of PHP. Paraphrasing what Rasmus
said several years ago(*), 'if you implement this [strong typing], please
don't call it PHP'.
Again, luckily, what Andrea proposes isn't strong typing. It still
maintains the most important properties of type juggling - e.g. the
ability to work with strings coming in as input (GET/POST/etc.) without
having to worry about typing.
Zeev
(*) I couldn't find that email quickly enough so apologies if I'm not
completely accurate on this.