Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105134 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 94714 invoked from network); 7 Apr 2019 20:19:27 -0000 Received: from unknown (HELO mail-wr1-f46.google.com) (209.85.221.46) by pb1.pair.com with SMTP; 7 Apr 2019 20:19:27 -0000 Received: by mail-wr1-f46.google.com with SMTP id w1so13593347wrp.2 for ; Sun, 07 Apr 2019 10:15:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=N4AheIy48lfEjQ3LheKffJuwSa8Mxq/jQ4UJso4rFXM=; b=QymxtvFhwZ5cDytMs0xizPN3va8fxOsgSziXbALkws+qJXOXMp9TiXSIMZphFiBENY um+1MAWj5REGDb4F+uoiG6SRdvbCdzZN8Xu0wGMhTMlh2s4pE95LIg5mZdRKDS+R7JVz CzDvJoaUxooHkXyvb2H6x6b8EaTxzKEW/wj5Eqz8da+sfqekXcdp0RIcqdnlb3W3vhGe e37G3x4VcufXGIUCC3+eyNhXbZgmfJRUbBO1cFdVJybswBiFIv31XoLDdOuhl4zvhky3 f9WmyS3H30gHmdOhbQoK3O8EmB4K3rERrSy6ygow3eEq9JPhR8ZHxEWvuLClun9nhgVx Ptvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=N4AheIy48lfEjQ3LheKffJuwSa8Mxq/jQ4UJso4rFXM=; b=AEpo3vA/48Hada6PFxT9uSTmtM/nhOAaq6bSYesUf6L9xTQ/HNucL4gosOgDgj2OFL uYtmeiBypOPKVtRgoRvNQX+elPuZt6fGBrmhXelj3j3bN3RXyTBdbqV7tQuX2zuA2k4S CrftKX7lhoIzxb4yc95mNqcpnxutXfgxvuXlU+yf/2bPw0vXE6grP6hwo5JJN2nrw510 TKC+c0b29Euvv5Bp431eO1X3JPXxMmYfpgSCg3cwQ/sGA1uPQ4n/zhO8zYnsaQ0xgD4J 0ZUFCczt8x0UCqc1kFUboNaY/TgsFNv9om3/dtOjtMLxCENyh/o7MuTO+evfDgIijAQV lEEw== X-Gm-Message-State: APjAAAXvvvsA/J2hgQaahMg0zmreN95U9a9W06W6OfcSd3rshNtTD9wk 7FQi2qZkiGQ6V1vEoDMIEQ92Zj9d X-Google-Smtp-Source: APXvYqwYScyfVVpUCExyLkJfhEHL1/Fg+sIoRsy/mPxXaMYv1yv9B9rGxH2ebY2g8Frz0n3FYszLLg== X-Received: by 2002:adf:cf0e:: with SMTP id o14mr15057691wrj.182.1554657352819; Sun, 07 Apr 2019 10:15:52 -0700 (PDT) Received: from [192.168.0.16] (cpc84253-brig22-2-0-cust114.3-3.cable.virginm.net. [81.108.141.115]) by smtp.googlemail.com with ESMTPSA id f11sm31763609wrm.30.2019.04.07.10.15.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 07 Apr 2019 10:15:51 -0700 (PDT) To: internals@lists.php.net References: <00b701d4ed5c$27f77550$77e65ff0$@jhdxr.com> Message-ID: Date: Sun, 7 Apr 2019 18:15:51 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <00b701d4ed5c$27f77550$77e65ff0$@jhdxr.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-GB Subject: Re: [PHP-DEV] bool values and increment operators? From: rowan.collins@gmail.com (Rowan Collins) On 07/04/2019 17:08, CHU Zhaowei wrote: > In addition, I'm thinking whether it's possible and necessary to add a global strict mode (like "use strict" in js) in PHP 8 to deal with this kind of unexpected surprise. I know we have declare(strict_types=1) but it only works for functions and it's limited to call from current file. I'm not a fan of a generic "strict mode" the way JS has it, because it only works once: if you add more behaviours later, the BC break is just as bad as if the switch wasn't there. I wonder if in 10 years time, someone will propose a "use stricter" mode. Perl's "pragma" system is more flexible, and notably works at the file or block level, like PHP's declare statements. The most common pragmas are "strict", "warnings", and "feature", each of which has a set of sub-categories which can be individually enabled and disabled. You can also opt into all features as of a particular version (and require that version), again within a single lexical scope. The downside is that this leads to a lot of different combinations, in keeping with the Perl motto of There More Than One Way To Do It. The big downside of all this is that even if the compiler understands what all the combinations of flags will do, the human reading the code won't necessarily, so having declare(increment_warnings=1) probably doesn't add much over just documenting the change somewhere. Regards, -- Rowan Collins [IMSoP]