Re: [RFC] Strict type hints (parameter and return value)
| From: | Stanislav Malyshev | Date: | Sun, 25 May 2008 08:57:00 +0000 |
| Subject: | Re: [RFC] Strict type hints (parameter and return value) | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-37856@lists.php.net to get a copy of this message | ||
Hi!
as this seems to be your only argument throughout the discussion, I suggest we implement is_numeric() and alike or allow a second parameter that to 'is_*($vaue, $strict=true)' that allows to switch to non strict mocde. We then could easily allow 'numeric' as another type hint. Or inI see absolutely no use in "strict" mode. Moreover, I consider it harmful as it teaches people not to use dynamic nature of PHP but instead pepper their code with unnecessary checks and irrelevant errors. As I said, I see no difference that could matter to PHP programmer between '1' and 1, and I don't see why we should encourage making this difference. I know there could be very special cases when it could matter, but importance and frequency of such cases do not warrant, in my opinion, their support by the syntax and the standard library of the language.
other words I see this as a completely separate discussion. There are two discussions: a) do we want native type hints b) do we want an easy ability to deal with compatible types in type hintingJust for the record: a) I think the whole idea of type hints, especially with primitive types, goes to a wrong direction - PHP is not a strictly typed language, and shouldn't be. b) However, on practical grounds, since we already have type conversion for internal functions, it won't be too much trouble for a user functions to do the same. On the other hand, making strict types for PHP functions is nothing but trouble, IMO. This is why I think it is not as separate as you think. -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com