Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110709 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 45368 invoked from network); 23 Jun 2020 13:22:19 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 Jun 2020 13:22:19 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AF9851804B7 for ; Tue, 23 Jun 2020 05:09:28 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-il1-f173.google.com (mail-il1-f173.google.com [209.85.166.173]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 23 Jun 2020 05:09:28 -0700 (PDT) Received: by mail-il1-f173.google.com with SMTP id t8so19037670ilm.7 for ; Tue, 23 Jun 2020 05:09:28 -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=xmxWdtpLBUhDaXi37HLQ2ejDi4bsbM/fvbeWrAYkj7A=; b=f5dhMRl2KYZq7bI+Qvp+VZe5wFm4Nx8BWe0+ohp1B799NNowAE8xXTKLpdOnM8j+L8 jKZs3koiFBhMvC9Oi3VnICANkd3ybfJiKlzVoX2QJkrWpxpmDKmKNDvz4FPjFHkFW2XT HzpuRy292+M01/NWxcmdOeuaRxpL/u00T9RrhHR2lMMso8SNE+wuq8zCfwy8vzrwQjBH mPAaQVWDHoUjqg1d8VUdeMXlCrmXtxlR1H7oahRl7VX74LJ1QqbBX3TelVDDGc+8tpLz WhggvsebwQ7O3jcfk83LCixHm7Olm/pabRQKWcPZhduswjLF5OxZ9FxPoFle0aNDJCV4 mPzQ== 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=xmxWdtpLBUhDaXi37HLQ2ejDi4bsbM/fvbeWrAYkj7A=; b=PE0nmE/Imk5yqBuy5NwQAHxmCPArrfFozua9C0YWgmdvflQJUXRy/AZwmP0aAKs96m QSq/QmSxdj8xFd8HsrYzJw21KODelFcEdQce1ud1uaO4JHkGvmxq+MEKa9H3c5G9wQx0 YpUjRkK/wY+nxEgEtifCmgHTJabqfGtViU7j8c2SzLd0fhnM0cv6fGP0BORQprF9gCJD xMKdKFyTUofXTglH+s+Dl7V1WZ2EsrmjUEW5V4QYiZatnVYIhpbNpyZvLYs6Ebb6PDZ2 T/RCfuFg7kYDQuiiiWXS8CcQQWQ+UFT38SDn+icjsYk4k9k3LrSYmr3kOzCUR3pJc7DK wNnQ== X-Gm-Message-State: AOAM532tK5ymh5E3pVtApW2fvf0oJow/e5t9N4EzOQ+2bmWs9S2YhvVk hKfXub8HTbylLwbJVXP4n7Y+ZVEjs8arUlVGYu84BA== X-Google-Smtp-Source: ABdhPJyOrzlWkoVIaLHkttqajl4XMgO0aurTdB6h+VKYy6/1QTV9Jv+b5yfxfmob5Dc0Jf8Nt2PRRmMZ1KJwejvTc8A= X-Received: by 2002:a05:6e02:ca:: with SMTP id r10mr21453506ilq.274.1592914164565; Tue, 23 Jun 2020 05:09:24 -0700 (PDT) MIME-Version: 1.0 References: <37f1f8fb-0e1b-cc39-f4b6-6c943a731d49@telia.com> <250b7671-2919-9385-c149-931212397e4b@telia.com> <04d86e2d-0815-195a-6111-3034e0ca5918@telia.com> In-Reply-To: Date: Tue, 23 Jun 2020 13:09:12 +0100 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="000000000000efc8f205a8bf3af3" Subject: Re: [PHP-DEV] Re: [RFC][DISCUSSION] Match expression v2 From: rowan.collins@gmail.com (Rowan Tommins) --000000000000efc8f205a8bf3af3 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, 23 Jun 2020 at 09:54, Bj=C3=B6rn Larsson wrote: > > Ok, thanks for the clarification. The reason for me to bring > this up is that I was pondering on if this is the only place in > PHP where a semicolon is required after a curly bracket > when not used in an expression. > Two things: - as proposed here, match is *always* an expression; it just happens that PHP lets you throw away the result of an expression, so "match($x){};" is a valid statement for the same reason "42;" is a valid statement - as Ilija mentioned, ending a statement with an anonymous function also leads to the combination "};" function returnsFunc() { return function() { echo "Hello, world!\n"; }; } function returnsMatchResult($x) { return match($x) { 1=3D> "Hello", 2=3D>"world" }; } I'd also note that while there aren't currently many cases where it would be ambiguous whether a statement or expression was intended, new ones might be added in future. For instance, post-fix conditionals (like in Perl and Ruby) would give us match($x) { ... } if $condition; This kind of syntax short-cut tends to end up with complex rules of "it's optional except when it's not", which I'm personally not a fan of. Regards, --=20 Rowan Tommins [IMSoP] --000000000000efc8f205a8bf3af3--