Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109495 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 25133 invoked from network); 1 Apr 2020 12:38:16 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 1 Apr 2020 12:38:16 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A8F7E180546 for ; Wed, 1 Apr 2020 04:04: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=-0.6 required=5.0 tests=BAYES_00,BODY_8BITS, 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-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (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 ; Wed, 1 Apr 2020 04:04:41 -0700 (PDT) Received: by mail-wr1-f41.google.com with SMTP id u10so30021419wro.7 for ; Wed, 01 Apr 2020 04:04:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:references:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=Djsygrb1Voxjh4vUkwTlRo8z+e1Z6IdmVTeF0NlL0cA=; b=auMpFmVvLsei3oBs/0kclOLWucKB2Ldv3GVVYLkkjIV1KXNthU+N9moBBEnyZCTXY9 qCSc7m8luxUXVkxSL7R85a0YZ0uvE14xNbdMGdi9Hug+taBC9Be5B8BzrzHdU89QJ7Jb 0+xRV0c0dwOEhHjJpIqqCEwWUNe3j9yplbzNId/wNq9p1uK9cMJvRVhdDyYfBMGWhOnV Sk3A1TQoXw6GBkw5Lyyitqij4qfzxP1WT04AJ27hJe1Kl26KYuPoAh+bjStt8Z0JhR6N GrL/kxGNSrVyO4bIriuXbkcUOk1ttZL6EOte0rLpNC/gHuLmqaoLzk/6NXXYOBhA1hfg tTQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=Djsygrb1Voxjh4vUkwTlRo8z+e1Z6IdmVTeF0NlL0cA=; b=fMV9xkTzP0Szry/qtJJXm4eKcAXU3gPx0TNMqi+90J/HTbPhFf7tkNPHmIGGU4uVsz nyCqc/FBUS6WCjVxDJKH4QW8YDHuwKPkfObEKsotSH+I2rvy/7xhs3It2RYg1tkj85Ul hHZlaDTHrCUzQQDk6M5qdn+Yl1ZpK7H1HFQl6VYKn8BMszmUD2l0re0JtlJy4BkVnf3y LVl8zNBnDKPgt2UGSRmSKfQ5owG9J6esgRdqTzjmD7fo6eb46UAEghZelpKW88F0wVXO GDg+uhxuhterrK0KduiCEJBvNQZKOBC3VbCaIV0ukIpWPzHzb0VXAZWs1YWK77suFpXo 3ByQ== X-Gm-Message-State: ANhLgQ1j8beJkAsY3dVQGxKlQvx/fPAxSn+ZEMQLTHMULgbw0AQgM+pR q3D5fazj3lAGr02nxzUQ6DYhdH41 X-Google-Smtp-Source: ADFU+vtCA5kV4iE+2YZxxb2KDqujqiOJuukyYd2mpenm0GuVn4Ojvpvwg+a9YefLscwxQuzaadZjXw== X-Received: by 2002:a5d:4091:: with SMTP id o17mr26904589wrp.254.1585739075264; Wed, 01 Apr 2020 04:04:35 -0700 (PDT) Received: from [192.168.0.14] (cpc84253-brig22-2-0-cust114.3-3.cable.virginm.net. [81.108.141.115]) by smtp.googlemail.com with ESMTPSA id 71sm2639211wrc.53.2020.04.01.04.04.34 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Apr 2020 04:04:34 -0700 (PDT) To: internals@lists.php.net References: <7E3BE38A-1DAB-4523-871A-7AAEE0E697C4@gmail.com> Message-ID: <76ebf15d-5f4f-f5a9-365c-d2e829c9961f@gmail.com> Date: Wed, 1 Apr 2020 12:04:31 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <7E3BE38A-1DAB-4523-871A-7AAEE0E697C4@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [PHP-DEV] [RFC][POLL] Switch expression From: rowan.collins@gmail.com (Rowan Tommins) On 01/04/2020 09:56, Rowan Tommins wrote: > If the intention is to make this feel like an expression version of the switch statement, then making it look more similar would make sense. To expand on this a bit, if the aim is "a switch statement, but usable as an expression", then it would make sense to start with an identical syntax, and make only those changes needed to meet that aim. So, given the following example from the RFC: switch ($x) {     case 0:         $y = 'Foo';         break;     case 1:         $y = 'Bar';         break;     case 2:         $y = 'Baz';         break; } The starting point would be to move the assignments and nothing else: $y = switch ($x) {     case 0:         'Foo';         break;     case 1:         'Bar';         break;     case 2:         'Baz';         break; } That looks a little odd, because the result expressions are formatted as statements, so we could maybe combine them with the break keyword: $y = switch ($x) {     case 0:         break 'Foo';     case 1:         break 'Bar';     case 2:         break 'Baz'; } We could then bikeshed whether to swap out "break" for "return" or "yield", but the result would look and act like an expression version of the switch statement. It could even have other statements between the "case" and "break" lines, and all the normal fallthrough behaviour. The other issues discussed in your RFC - fallthrough, inexhaustiveness, type coercion - are valuable things to discuss, but each one takes this further away from being a "switch expression", and into being "a new value-matching expression". As I said in my last e-mail, I don't think that's a bad thing; I really like the proposed syntax, as a new construct for picking one of a set of expressions, and would be happy to see the RFC re-focussed in that direction. Regards, -- Rowan Tommins (né Collins) [IMSoP]