Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109471 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 52476 invoked from network); 30 Mar 2020 20:24:42 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 30 Mar 2020 20:24:42 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 87613180546 for ; Mon, 30 Mar 2020 11:50:41 -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-f171.google.com (mail-yb1-f171.google.com [209.85.219.171]) (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, 30 Mar 2020 11:50:41 -0700 (PDT) Received: by mail-yb1-f171.google.com with SMTP id 11so9637634ybj.11 for ; Mon, 30 Mar 2020 11:50:41 -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=Xrr3mOSDaW+8UF3T35sS7iM1yOeCrDS4+iT0/ptHGIw=; b=VAM5bFsITuVzCvO6Lrz78++4yM6FpldfJq7XXDlT3PwZGj0avg3EPH20aGf+9BXm4F bI8b+VEkNvfly9RKoMlBSrA+JNLkpjU2/ydSAXurFgYfPOak6h5it1RtdU1hk8r6Oipb l1QRnQ/2v7PUwnqSyEaS1R/zoIWfAMy36lpdUxAjUlgvwbY0foqRLCJA9hSJ4wSgdWAJ N0JYECqmGJm/PqIFZdunbBkDujlGHjlSPc09K86OSnttj5wR2sxrUcdk53R/oNHb6Miu 7CTrA2iOE4XomC4pV3S8uk3JHZFDSUS99TQbcAd+Tykk+WK/ZL8F7T9Ey/93Kp61oMKP Luag== 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=Xrr3mOSDaW+8UF3T35sS7iM1yOeCrDS4+iT0/ptHGIw=; b=FJAlpJkTiMH/0UlWUKNDWa+xd2vDBCkoYTvd6smlJd7JCzkcycrt7Ti5DgEuRu8QX3 xNC06TS8SWdnk6JgAfqOxGBZv21BdnLFpqG+SYY0IXQ0RimxXEDZll7yXADOAXBBbxIH Q5SoUYQKNVDtmAJECWYDYwPm+BOQwz8HAy8Hp7XFUOQoBW7V+g6n0tnTIUM1kpLzkyuD F1nUty1v13ISEClQITzLhiPkw8XBJVvEWIrmdsDVGsgO/t/kHDhvaGH8Q3dHqfptpuLh kdsl/x0AO3fzpt8Vja/fICsw/LrRJoHINT9kTZnShm22irRtd5nHqO5etcTjlTwg0kx6 hJog== X-Gm-Message-State: ANhLgQ3Zjnf9o6LzZ94Ypwp36/RArhIDW4EXcr8nfubUw+AihFaa608N O6/id6nzW5p5ykbNNAr6kLicVEmmkFnRw1YLf1Biu6GM X-Google-Smtp-Source: ADFU+vsOVddLlCx2HCUJmzVwCSE47vdPYZOmBNIFelSZbLxrWkeit6TfjgMGkTp44RfxeMZlhbVLDd2FNJOdh9Qko0g= X-Received: by 2002:a25:3446:: with SMTP id b67mr1177045yba.114.1585594238191; Mon, 30 Mar 2020 11:50:38 -0700 (PDT) MIME-Version: 1.0 References: <047092C7-84FB-42AB-8084-7B83F76F55C1@me.com> <026AF97E-ED0C-411C-8942-7DA7CC9705DB@me.com> <34ce624e-7d00-4f63-2c4f-da125deb65b8@gmail.com> <5ddebafa-1f29-4393-8b66-88026031a8a3@www.fastmail.com> In-Reply-To: <5ddebafa-1f29-4393-8b66-88026031a8a3@www.fastmail.com> Date: Mon, 30 Mar 2020 20:50:26 +0200 Message-ID: To: Larry Garfield Cc: php internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [RFC] switch expression From: tovilo.ilija@gmail.com (Ilija Tovilo) Hi Larry > Not everything has to be a statement. This is not what I meant. What I meant is that it should be usable in a statement context. Since you mentioned Rust, match is always an expression. But you can use it without making use of the return value. This is what I'm suggesting. In PHP this is already for any expression as well. The only difference is that we require a semicolon. https://doc.rust-lang.org/reference/expressions/match-expr.html https://doc.rust-lang.org/reference/statements.html > sticking statements inside an expression is just kinda weird This is precisely what Rust does. https://doc.rust-lang.org/reference/expressions/block-expr.html > If you want side effects... you already have switch. Yes plus all the negatives mentioned in the RFC. It would be incredibly unfortunate if we created a new construct that fixes all those problems just to be usable only half the time. > The point of an expression is to be evaluated into another, simpler value. This is certainly an oversimplification. Function calls are expressions and still have side effects a lot of the time. > Isn't this "close enough" to pattern matching that it coves all reasonable use cases I agree. I don't think there's a convincing reason for pattern matching in PHP right now. Nonetheless, this is not pattern matching and we shouldn't call it that. Regards, Ilija