Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109604 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 312 invoked from network); 13 Apr 2020 12:59:31 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 13 Apr 2020 12:59:31 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2C9721804CC for ; Mon, 13 Apr 2020 04:28:55 -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, 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-yb1-f172.google.com (mail-yb1-f172.google.com [209.85.219.172]) (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 ; Mon, 13 Apr 2020 04:28:54 -0700 (PDT) Received: by mail-yb1-f172.google.com with SMTP id t10so5070404ybk.8 for ; Mon, 13 Apr 2020 04:28:54 -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 :cc; bh=7Tpcer3SE4wrZJScH5qXMGQZ0w73zrb0JZoPnf4q/Ro=; b=UfKQ3lQZ/PzbhrpfBNrYM0xr95dBKEqVghgfHYDNQ8j7weig8qQR3MGk3xwGDjKiAe 99SpuJdBCPFRdpU/uWRb92qoqa6K182qWMqtoPE5U3RC2RbRk62jmIVHRRXTPzYekojD NYNV39ftHXer9/KA6CSra8WG54nMoEY6Nrbf8GqFpGiIOO2K+oBOFdq3kbCnsIQQTzHg OI/NRYuaZDDDz5vSY/jRp0tdByipIalOBY94SPCWA5iHJvZUI40FTFEDLlq6uhiKJrKf +tk0YHVaIYSXplx8NiwUB6h/GGZRH18h9A5633R4IfnzSqXJwNc0axUshPzj/LB02viL X0cw== 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:cc; bh=7Tpcer3SE4wrZJScH5qXMGQZ0w73zrb0JZoPnf4q/Ro=; b=NNRYcweAHDNYRDDR29sCSXt4Hx8ySZ4x4RexAu7QK8IEyjbIow6G4CLU21BwOHjzUG /F3MDX+xWxfHRwcbPFTXPDXSpFXx/i/awG/aQdr6JQaSkiTNJYgziX3sGtbwQk30M43b FCliO6ayThklIiz2z9oGIh7R/OMnn0W1XtJnhxzRVHoYL7hUjWRYzUvWDawt+o9kUa5c 83st6dCx0pNavpJEutK92PHfDzKSGiRexJToURBUzETv9ipToE95NrCYrJDYGI/V5XMW 3V9VD+FwpcyGKHywYbLLRlFl9IqFaX4KCr/UN3JpB50NHNkUb2m/KbNTXnyjAiwdrxxI 4gzQ== X-Gm-Message-State: AGi0PuZllwJbfJTSb7WF0Lanqrr/X7PnuJ0A9qzMfyRTc5xhcNN3uUZh W6ttDj3rVjQHd/YmRKTWaHTEvTj2QzSz3l0jpzg= X-Google-Smtp-Source: APiQypIfuKFF/BBWS1vkdQFajwFrUAe/a+xzjgp+h8N+lyEuLqJUQC6kkSOvEKYGddeBL/erS3/S3sMs4oQIosokoBw= X-Received: by 2002:a25:ba81:: with SMTP id s1mr26896010ybg.114.1586777332644; Mon, 13 Apr 2020 04:28:52 -0700 (PDT) MIME-Version: 1.0 References: <6aebe21d-2137-885e-5ee9-99d4f917a7f9@gmail.com> <5071DCCE-4572-4B1F-A50B-832C5EA74795@gmail.com> In-Reply-To: <5071DCCE-4572-4B1F-A50B-832C5EA74795@gmail.com> Date: Mon, 13 Apr 2020 13:28:41 +0200 Message-ID: To: Rowan Tommins Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [DISCUSSION] Match expression From: tovilo.ilija@gmail.com (Ilija Tovilo) > Firstly, block expressions are a foundational part of the Rust > language, not a special case used in only one place. From a previous e-mail: > It would be possible for the blocks to return values (though not with > the return keyword). I've created a small prototype a few weeks ago: > > https://github.com/php/php-src/compare/master...iluuu1994:block-expression > Heavily inspired by Rust: > https://doc.rust-lang.org/reference/expressions/block-expr.html > > While this would perfectly solve the problem perfectly it feels a > little foreign in PHP. Either way, this is something that can be > discussed an implemented in a separate RFC. We can't do everything at once. The current block syntax is completely compatible with that suggestion. All we'd have to do is relax the restriction of only allowing blocks when the result isn't used. > it makes *all* the control flow blocks in Rust feel more natural to > developers coming from other languages. Same thing here. If you don't use the result value, it looks just like the switch. That's why I'd feel odd to require a semicolon. > the page you linked calls out an ambiguity caused by omitting the > semicolon This code is parsed like this: ``` match($x) { 1 => ['foo', 'bar'] } [0]; ``` * statement list * match expr * array literal Note that we can't have ambiguous grammar since Bison would immediately expose it. > It then explains the important restriction of only omitting the > semicolon if the result is void/null rather than a concrete value. That's true. Unfortunately we don't have this info at compile time. That's why we throw away the expression result just like with any other expression statement. > I would probably vote no to the current proposal I understand. Everybody is entitled to their opinion. If the vote fails that doesn't mean we'll just completely give up. I would reiterate and try again. Sadly, it's very hard to get a feel for how many people have which opinion through the mailing list. Ilija