Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:106064 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 11024 invoked from network); 26 Jun 2019 10:19:15 -0000 Received: from unknown (HELO mail-ot1-f51.google.com) (209.85.210.51) by pb1.pair.com with SMTP; 26 Jun 2019 10:19:15 -0000 Received: by mail-ot1-f51.google.com with SMTP id i8so1535503oth.10 for ; Wed, 26 Jun 2019 00:35:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=JjvqRKguVjObK2h5dGLHMt7OigOdMShzUEvbJcBn8Eo=; b=uUWFM3B59KZWPPu5/+spxIEBsFQ8t/utgLh7rsHN2w/uJtl72Ntj8t6SjJ78BoTOfH FRVxAjOZLuce+gH5Cv7DG/PeTX1+VQY5KHunqZZV8inSx3rGQ/qgjafw3LfCGPJHSAZp 4fwM9sSe/Pbfkhqfix2DuZz9aNKfsMKJtxdHvQuRYKEWKXPV/nDQuoyz9B+7DFaspYo9 UzCmXJ/6iyr2CHcaZ/C+kgdd3D/alV2RiAnEWDlh2np9B7TTPJntgnDPHstdAyEu+LGX BH7X4xBbQbDXZ0W10XVipwY6sDa4gJfe3/dDiiJYeJJ3mPLVDL9t1N8YVSG4quOsyPcl UOsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=JjvqRKguVjObK2h5dGLHMt7OigOdMShzUEvbJcBn8Eo=; b=em77GsyfpO5rz6cuU0l7vvlKYwj8GrVGHr+iOl6zwzfe0tSRkwMum8fzB8wiKH2iw3 E2zCDBItkw8woH2nddJgKeUoKzCD5nszMSbCvhP3fdHwskXkDPm4Fp8Hvp9wKRfbWVuU gzr/diB2vQdCTmJguWGBq5iShIq2EMxk0SR4SCodteLOR5o+OMqwOfNowThGRu6z7wv5 DPjio/EfL+vZlFguxMrS+IBRXVH3dx6emWQGjOBUdfeMyH9Z3Wtbe8bHnNJP1bZ4BBMz gE6zciZEmwwIMeQA0bEtpwJbef8lPeHwbMGZtqWvw5T8K9YQVP95akptggnNVcFVt77E 12hA== X-Gm-Message-State: APjAAAUvYIFC4BPBralVK7BKIO6YBPul5U8h2T8N0nrgAVbt5MNyMZpq 5ua3GFykHIy4PoDAAjT2jqhPHHZSp2e0R9jqlWWXXYPQziM= X-Google-Smtp-Source: APXvYqzM5ImjTmAvXtXG+/D5ZfqiQDHEQo28SeL/+s4vV7PqTlY467KY1IFkbwwnvJ2oKJLZbq7vyiEGcR19V0PxhtI= X-Received: by 2002:a9d:2c41:: with SMTP id f59mr2136085otb.268.1561534535710; Wed, 26 Jun 2019 00:35:35 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 26 Jun 2019 09:35:24 +0200 Message-ID: To: PHP Internals Content-Type: multipart/alternative; boundary="0000000000004e3e73058c3517f3" Subject: Re: [PHP-DEV] [RFC] Strict operators directive From: arnold.adaniels.nl@gmail.com (Arnold Daniels) --0000000000004e3e73058c3517f3 Content-Type: text/plain; charset="UTF-8" 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 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, > 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 >> > --0000000000004e3e73058c3517f3--