Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102687 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66243 invoked from network); 10 Jul 2018 09:01:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Jul 2018 09:01:21 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.48 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.214.48 mail-it0-f48.google.com Received: from [209.85.214.48] ([209.85.214.48:54882] helo=mail-it0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BD/5E-49043-0E5744B5 for ; Tue, 10 Jul 2018 05:01:20 -0400 Received: by mail-it0-f48.google.com with SMTP id s7-v6so29374810itb.4 for ; Tue, 10 Jul 2018 02:01:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=RqyMX802Kqt5Ia5AMj33CeqdVNcnVP9bX9OBzlOJ0Ks=; b=AgTjZ443X5at3TVtbN9dI7Yt7ymrT9k2hHZQSFP71QJ291Dm/fl1/aTdfygrHtUAe+ oLJ1+EJYZ8KVWfJdfVyuSmf0qYb52/WAaowYKnBfWh54RNqJ9p2LdVRQT9NKIa3BHB5t eL2JdRoOAIy5C4x4jlnMgojnM6oxysP/0wNyoV8K7w3NWkdFcOpyQTQ8EMQZzGemdSFh o+5EeUBxjO1UJ+usCcCj8Gx6g5dcthoRKjqJaM5iifpllCgGlZSpXS2EAKqXgAkrguw8 LdPgYvXTPd53GXxW+SKIYjXwcUar4V/Sf9idJt90aUB3UGGSkRQFZg4taTSuptDhVW9m 0T/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=RqyMX802Kqt5Ia5AMj33CeqdVNcnVP9bX9OBzlOJ0Ks=; b=FwgrbS3a0XI+p7vXXFWWqQk+iGy/KLr1mnexHWHr7rbv+YsIJEmJEH49QW2DLWNYgJ GcGT+y4UcINx40XoNkhWQOtRcv7w1eaAWv9gnkKpheOhc89ShiOHhM2fdl+YPmILPcyg PzieKkkMd63PBLZyvPeNPlcXzbbIgjIJ4mAkerdjuSh3GwgL9jlhEwUUObc8tYvnZXQS MLtkYW0a7lGwXKS2MDCzLD56swzQJP1lwIMGU+tZkqw9EtIJyh2vXQWYUf2+GNHNag0I pWUWIWZ2DezVxmY/TTjeAK2WfywETT6xkoBBg369vwDmZWRvIvH1TcYNfgqj4FmZG4Mk yVLQ== X-Gm-Message-State: APt69E26+v2ry9SVH8xYDD6jp7wCRnMj11bqOiAhT12rtiShFjqGgKbc BAbaI/ng3UX3RY2fBjUQVxwB4QVhwyTNUPM39m4= X-Google-Smtp-Source: AAOMgpdP9gd7Is7giIHsPX/wPy7LRedgbclkUOpL80PnqtvjmlR2Qd3BzlZeDaJJ9Fs6xSiHiOCRdJbaFRt6ecr/PKc= X-Received: by 2002:a24:ce81:: with SMTP id v123-v6mr18139175itg.119.1531213276976; Tue, 10 Jul 2018 02:01:16 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a02:95a8:0:0:0:0:0 with HTTP; Tue, 10 Jul 2018 02:01:16 -0700 (PDT) In-Reply-To: References: Date: Tue, 10 Jul 2018 10:01:16 +0100 Message-ID: To: Ryan Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000731c730570a15f13" Subject: Re: [PHP-DEV] Unifying logical operators From: rowan.collins@gmail.com (Rowan Collins) --000000000000731c730570a15f13 Content-Type: text/plain; charset="UTF-8" On 10 July 2018 at 04:02, Ryan wrote: > > defined("SOME_CONSTANT") or die("SOME_CONSTANT was not defined"); > > However, this behaviour has nothing to do with the difference of precedence > - rather this is due to short circuiting. > As your own next example demonstrates, it does rely on the difference in precedence, because without it, you could only use this idiom after carefully checking that the left-hand side would be evaluated in one go, and probably using an extra set of parentheses. > ($gdImage = @imagecreatetruecolor(120, 20)) || die('Cannot Initialize new GD image stream'); This is less readable both because of the extra parentheses, and because the || operator is not as easily read as the English word "or". While I've not seen it used much in PHP code, the "do this or die" idiom is common in Perl (which also has post-fix "if" and "unless" modifiers, so those are a different feature again). IF there is sufficient harm in having the extra operators, I would say removal is the only option - making them behave as aliases for || etc would just lead to even more confusion when they *don't* work the same way as in Perl, and in earlier versions of PHP. I'm not 100% convinced by the harm, though. Finally, a note on the "xor" operator - your draft says that this is equivalent to "!=", but that is not the case, because both can operate on non-boolean values. Consider "1 != 2" (true) vs "1 xor 2" (false). I don't think I've ever had a use for logical xor in PHP code, but there isn't anything to confuse it with, so no reason to remove it. Regards, -- Rowan Collins [IMSoP] --000000000000731c730570a15f13--