Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109300 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 35271 invoked from network); 25 Mar 2020 17:57:40 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Mar 2020 17:57:40 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7B3711804E6 for ; Wed, 25 Mar 2020 09:22:23 -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=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, MALFORMED_FREEMAIL,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS714 17.58.16.0/20 X-Spam-Virus: No X-Envelope-From: Received: from mr85p00im-ztdg06021201.me.com (mr85p00im-ztdg06021201.me.com [17.58.23.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 25 Mar 2020 09:22:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=1a1hai; t=1585153342; bh=f+9d2kFnGCtd6hqMr8+wvQ4WbteuM/FtDG5ltAIel/M=; h=Date:Subject:From:To:Message-ID:Content-type; b=ZZxJUXXfBOjLqZcPIbCgHFUD2pThlNkEHVVGvlraQgBDPUWW/a00y6zzTtfIDoKnS ZbfnVqOEveojSwEGI9p/+MsbjMA9Exlq3eLDbrWTKrZpX5KitQaz5MXqt+a8xyZ50F vU3ihXnhJ7FrBuirqTU5F4tlleT8zOvBJAcaHho22SVMgety2GzWMEelEYQFAEfHBA pMgrVukyhu08RWGs6V1N5ojwNUvpodW8Xt2winiA5Zm1KXiSnl57uwZqr+90ARrXYv xfrK6tjeJLcAUuWCjenQFXbzI0sbnYqv7YKZMgOJrKoZWPeYGP07d0lVg8cbIMG7ZK KXqql2oSVJEZw== Received: from [192.168.43.208] (197.226.197.178.dynamic.wless.zhbmb00p-cgnat.res.cust.swisscom.ch [178.197.226.197]) by mr85p00im-ztdg06021201.me.com (Postfix) with ESMTPSA id 11BF71202D0 for ; Wed, 25 Mar 2020 16:22:20 +0000 (UTC) User-Agent: Microsoft-MacOutlook/16.35.20030802 Date: Wed, 25 Mar 2020 17:22:11 +0100 To: Message-ID: <21C8B270-FD87-4B0E-A203-7E6850B13ED1@me.com> Thread-Topic: [PHP-DEV] [RFC] switch expression References: <047092C7-84FB-42AB-8084-7B83F76F55C1@me.com> <4513B88E-CA5B-4DF2-94C8-242BEE54ADCC@me.com> <767910ef-d27b-404c-9ad1-037105c69d12@www.fastmail.com> <2E98378A-605D-40ED-898C-6ABBFBD091B9@me.com> <13054915-92e1-2723-2db7-fa13376ffecb@birkholz.biz> In-Reply-To: <13054915-92e1-2723-2db7-fa13376ffecb@birkholz.biz> Mime-version: 1.0 Content-type: text/plain; charset="UTF-8" Content-transfer-encoding: 7bit X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2020-03-25_09:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 mlxscore=0 mlxlogscore=474 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-2003250132 Subject: Re: [PHP-DEV] [RFC] switch expression From: ilija.tovilo@me.com (Ilija Tovilo) Hi Dennis Thanks for your feedback! > you can fall through to other cases without break You could do the same using the || operator. > what about the default case? I haven't described the default case in my proposal but it is exactly what you'd expect it to be: ```php $var = true switch { $x > 0 => 1, $x < 0 => -1, default => 0, }; ``` > What about the following if-expression-syntax: That would work (once again, Rust already does it) though not with the return keyword. We'd still need a block expression to pass the value from the block to the if expression. When I compare the two I definitely think the match expression is more readable. Regards