Re: [RFC][Accepted] Scalar Type Declarations V0.5
| From: | Pavel Kouřil | Date: | Wed, 18 Mar 2015 13:12:27 +0000 |
| Subject: | Re: [RFC][Accepted] Scalar Type Declarations V0.5 | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-85192@lists.php.net to get a copy of this message | ||
On Wed, Mar 18, 2015 at 2:02 PM, Nikita Nefedov <inefedor@gmail.com> wrote:
> On 18 Mar 2015 15:52, "Pavel Kouřil" <pajousek@gmail.com> wrote:
>>
>> Hello,
>>
>> I made that conclusion because in the first example, the library kinda
>> forces strict mode rules on the caller, even if he doesn't want to use
>> strict mode - this makes the interoperability of the two modes
>> problematic.
>
> This is incorrect, library force itself to use right types, not you. I don't
> see any problems here. The only thing that for sure lacks in PHP and that
> would make STH better is callable signature types.
>
Well, it forces you to do that, basically. And also forces you to
"care" about the mode of library, adding mental overhead. Look more
closesly at the first example - does the error in that case make sense
to you (from purely user's point of view)? When you call
a(function(int $b) {return $b * 2; }) - should you really be required
to check the context within the a() is declared?
>> Also, the other possible outcome of the scenario (respecting the mode
>> of the place where the callback is declared), is IMHO problematic as
>> well, because it does not respect the strict mode of the place where
>> it is called, making it inconsistent with how the dual mode RFC works
>> in general.
>
> It doesn't matter where the callback or function was declared, it only
> matters where it was called. It pretty much is consistent.
This was just a comment about how it would be (also) wrong to solve it
the other way around.