Re: [RFC] Scalar Type Hinting With Casts (re-opening)
| From: | Andrea Faulds | Date: | Mon, 14 Jul 2014 16:12:27 +0000 |
| Subject: | Re: [RFC] Scalar Type Hinting With Casts (re-opening) | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-75481@lists.php.net to get a copy of this message | ||
On 14 Jul 2014, at 17:04, Zeev Suraski <zeev@zend.com> wrote:
> 1. It saves a bit of code and improves readability for a *very* common use
> case.
Sure.
> 2. It encourages developers to get the types straight instead of relying
> on implicit casts.
Your proposal is to just use implicit casts with no real failure cases; isn’t that encouraging
developers not to care about using the correct types? This RFC’s proposal is quite strict, what
you are suggesting is very loose and will not encourage anyone to use the correct types, as it is
very tolerant.
> 3. It reuses syntax we already use for type hinting so it doesn't drive
> complexity up significantly.
As does this RFC.
> 4. It allows people to go extra strict very easily, by turning E_CASE into
> errors. My guesstimate is that the majority of people won't, but it'll be
> possible and easy to do nonetheless.
I really don’t like that idea. If someone writes a function with type hints, people shouldn’t be
able to make those type hints go away or become more or less strict. They should be consistent
across environments and contexts.
--
Andrea Faulds
http://ajf.me/