Re: [RFC] Strict operators directive
| From: | Arnold Daniels | Date: | Wed, 26 Jun 2019 07:35:24 +0000 |
| Subject: | Re: [RFC] Strict operators directive | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-106064@lists.php.net to get a copy of this message | ||
Fixed the formatting. Sorry about that. :-s
I really want to have a discussion prior to creating, to make sure there is
consensus on what should be implemented. However, I will create a patch
prior to voting.
The implementation I have in mind is;
1. add a flag to
CG(active_op_array)->fn_flags (similar to
strict_types) *.
2. split function get_binary_op into get_binary_op_standard and a new
function get_binary_op_strict, where get_binary_op calls either based
on the op flag **.
3. add new functions for strict operators to zend_operators.c
*
https://github.com/php/php-src/blob/065559828022b37e88fc8eae4194efafea1b1506/Zend/zend_compile.c#L5127
**
https://github.com/php/php-src/blob/e18c60cd8dfed02311ebb3d11e3543d9a99c7c2a/Zend/zend_opcode.c#L1023
As proof of concept, I've created a test where the strict_types directive
affects the == and != operators, making them do an 'identical',
resp
'not identical' operation.
https://github.com/jasny/php-src/compare/PHP-7.4...jasny:strict_types-affect-operators-test
( to test build branch and run
https://gist.github.com/jasny/eacd187c949459b70d8f8f0818411f0a
)
I've added this information to the RFC. Any suggestions or remarks on the
way to implement this are appreciated.
On Tue, Jun 25, 2019 at 11:32 PM Joe Watkins <krakjoe@gmail.com> wrote:
> Evening,
>
> There doesn't seem to be a patch or implementation.
>
> Aside from the proposed semantics, which I can't really read because the
> document is malformed, the most important questions for me are: How is this
> going to work? Can it be done without significant complexity in the
> compiler or VM?
>
> Without an implementation I can't really consider the ideas proposed,
> because they are just ideas without proof that they are reasonably
> implementable.
>
> While you can technically move forward with an RFC without implementation,
> in this case the implementation should inform our decision at vote time.
>
> Cheers
> Joe
>
>
> On Tue, 25 Jun 2019, 23:19 Benjamin Morel, <benjamin.morel@gmail.com>
> wrote:
>
>> Impressive work indeed, this would be a perfect addition to strict_types
>> that would remove a lot of WTFs while preserving BC with older code.
>>
>> Please note that the formatting of the RFC is broken after the Bitwise
>> Operators section.
>>
>> Ben
>>
>