Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109295 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 19893 invoked from network); 25 Mar 2020 17:04:44 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Mar 2020 17:04:44 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E07D11804B8 for ; Wed, 25 Mar 2020 08:29:25 -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.32.0/20 X-Spam-Virus: No X-Envelope-From: Received: from ms11p00im-qufo17281401.me.com (ms11p00im-qufo17281401.me.com [17.58.38.51]) (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 08:29:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=1a1hai; t=1585150162; bh=83FvQvv785ZxU8M1pHbKTUPInbTY+H04PAHsYsrcZpg=; h=Date:Subject:From:To:Message-ID:Content-type; b=RxC9pCgaxHF5TEScn+9htX82WkPR0aphHLiCycdfYZT4FVkbtlJmW8+ufMFAEjNO3 /XZiEcUycueLB/0sK4r09JmTjDRim5N8N4qMMERqXV2MxUh9qaZB4d/r5naNu+rWIE Gf7CZyA3kk4KrGKJGOWlsOjIwCMyl2pKPaNmtBCUCqCWTXFKXLPYd1IQsYb0mlF3DS cjMxGN+hEOI87U9ubQHlu93N42mXaI7hCLJblMcb4n0nF/HtOz1Mxqhe2SHJhquA1/ ORD4HfcmOZrj4Kmg2843iEZE7OK/7sNk8MoRWC/dipx4vN6B2qvrTa0FfOCVqwjXhc uIYcgqO/ALRhw== Received: from [192.168.43.208] (197.226.197.178.dynamic.wless.zhbmb00p-cgnat.res.cust.swisscom.ch [178.197.226.197]) by ms11p00im-qufo17281401.me.com (Postfix) with ESMTPSA id 66E4EBC090E; Wed, 25 Mar 2020 15:29:20 +0000 (UTC) User-Agent: Microsoft-MacOutlook/16.35.20030802 Date: Wed, 25 Mar 2020 16:29:13 +0100 To: Larry Garfield , php internals Message-ID: <2E98378A-605D-40ED-898C-6ABBFBD091B9@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> In-Reply-To: <767910ef-d27b-404c-9ad1-037105c69d12@www.fastmail.com> 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_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 mlxscore=0 mlxlogscore=758 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-2003250124 Subject: Re: [PHP-DEV] [RFC] switch expression From: ilija.tovilo@me.com (Ilija Tovilo) Thanks for your feedback, Larry! > One possible improvement to either version is allowing an expression on the left side. That is, rather than doing an equality match, do a boolean match. This is how Rust does it: ```rust let x = match ... { Some(y) if y < 5 => ... } ``` In other words, you can add an additional guard to each case that excepts any expression. We don't really benefit a lot from that since we don't have pattern matching. I don't think this would add any significant benefit over: ```php $x = true switch { $x !== null && $x < 5 => ... } ``` Regards