Re: [RFC] Scalar Type Hints
| From: | Andrea Faulds | Date: | Thu, 01 Jan 2015 17:23:16 +0000 |
| Subject: | Re: [RFC] Scalar Type Hints | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-80065@lists.php.net to get a copy of this message | ||
Hey Levi,
> On 1 Jan 2015, at 17:19, Levi Morrison <levim@php.net> wrote:
>
> On Thu, Jan 1, 2015 at 9:44 AM, Thomas Bley <mails@thomasbley.de> wrote:
>> I think it is no problem to add strict parameter type hints with another rfc (if this rfc
>> gets accepted), e.g. function foobar(string! $str, int! $str){} or any other syntax.
>>
>
> I would rather have it the other way around.
string $str is
> strict
> and some other syntax (notably (string) $str or
> @string $str) can
> be loose.
Rather than having it on a function-by-function basis, meaning different APIs would have different
rules, I am warming to the idea of having a per-file strict mode. That is, if you used something
like “use strict;” at the top of your code, functions you called would have strict parameter
type checking. But if you didn’t, they’d be loose. This way all APIs would be consistent, but
you’d have the choice of strictness or non-strictness as you see fit.
This would be similar to Hack’s Strict and Decl modes.
I’m not necessarily saying it’s the best idea, but it’s certainly an option. The syntax is
already reserved! ;)
Thanks.
--
Andrea Faulds
http://ajf.me/