Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109610 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 46162 invoked from network); 13 Apr 2020 19:02:41 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 13 Apr 2020 19:02:41 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 37B5A180504 for ; Mon, 13 Apr 2020 10:32:10 -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.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS11403 64.147.123.0/24 X-Spam-Virus: No X-Envelope-From: Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) (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 ; Mon, 13 Apr 2020 10:32:09 -0700 (PDT) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 23BBB7B2 for ; Mon, 13 Apr 2020 13:32:08 -0400 (EDT) Received: from imap26 ([10.202.2.76]) by compute7.internal (MEProxy); Mon, 13 Apr 2020 13:32:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=PTjn7Iqz6suqlq3TVOEKhLhA2W2Xdpzmef5t0HOYh GE=; b=Hoexhbkr4UJOX4O1bPKePdHj8wr7K+oHPyKyGxOda5e/3XzVGMMXP5GLT FmNrf7yym31g7qk0/+m85sHFdn+sK9hiuK9aaFn6OSyk1XIdOs5DlxSc20IzKTM2 sPgE5w+z2lfRrCyyudbjhf4SL9+WMks6E3GZCg9ZlL3FmuYX+DHTONOS4LGkFMVl fk90IOYDtjCW8jKhAb2eD3yN9f1lJFH67LVVodLkjOGa4xxnX9l9+JrdEI40aWoC K3WOelczAhoKl5MBc+Mk1N7KIy/JK6ZrTpm7aCccjz/AyVr9MBnJleLsjuxBMh9f bmc6Sj2WcL3RuzimwoJtu03SUyJsA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrvdelgdduudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgfgsehtqhertderreejnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhep lhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 4038E14200A2; Mon, 13 Apr 2020 13:32:07 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.1.7-1104-g203475c-fmstable-20200408v2 Mime-Version: 1.0 Message-ID: <894804b0-868d-4575-8248-a74e17b3c4fc@www.fastmail.com> In-Reply-To: References: <6aebe21d-2137-885e-5ee9-99d4f917a7f9@gmail.com> <5071DCCE-4572-4B1F-A50B-832C5EA74795@gmail.com> Date: Mon, 13 Apr 2020 12:31:45 -0500 To: "php internals" Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [DISCUSSION] Match expression From: larry@garfieldtech.com ("Larry Garfield") On Mon, Apr 13, 2020, at 10:08 AM, David Rodrigues wrote: > With all the humility of the world and without wanting to be exhaustiv= e > about this, my only question is why can't we keep it as a switch, inst= ead > of creating a new keyword? That was the original proposal. The main issue came down to it being to= o much different functionality crammed into one bit of syntax, where lot= s of subtle little context would change the meaning and what you had to = do. That's difficult for users, and for the parser. Fundamentally, this is not a switch statement. I think it is an error t= o equate it to or relate it to a switch statement. It's a more powerful= , multi-branch version of the ternary operator, and should be conceptual= ized as such. And conceptualized that way, I really want it. :-) Piggybacking off of if makes slightly more sense than off of switch, but= it then involves a lot more syntax and a lot more typing, plus the conf= usion about when it needs a semi-colon and when it doesn't. =20 A new keyword creates a mental separation that is beneficial to users, a= nd allows it to be implemented with a minimum of syntax and no condition= al syntax (where certain sigils are needed only in some situations and a= re an error in others). > Em seg., 13 de abr. de 2020 =C3=A0s 11:49, Rowan Tommins > escreveu: >=20 > > On 13/04/2020 12:28, Ilija Tovilo wrote: > > >> It would be possible for the blocks to return values (though not = with > > >> the return keyword). > > >> [...] > > > We can't do everything at once. > > > > Then why not introduce the match expression first, and add block > > expressions (as a general concept) later? That way, we don't need al= l > > the special restrictions on when to use them, and can work out a > > consistent set of rules for them which can apply language-wide, rath= er > > than being constrained later by decisions we make half-implementing = them > > now. > > > > The ability to use them with short closure syntax would be very > > interesting, if the scoping/capture rules could be agreed. I really feel like this is the best solution. Multi-line expressions ar= e not a logical one-off part of match(). They may or may not be a good = idea for PHP generally, in which case they should be proposed and though= t through generally. If they do end up being a good move generally, the= y'll apply to match naturally just like everywhere else; if not, then th= ey wouldn't confuse people by being a one-off part of match() and nowher= e else. The various discussion about parse logic when the semicolon is there or = not only highlights that it is not a fully-developed concept. There's a= lot more thought and design that needs to go into multi-line expression= s that is not in scope for a match expression; embedding statements insi= de an expression is just weird... Please, pull that part out. It's the most (only?) controversial part ri= ght now. I suspect (note: no data) that the RFC would pass almost unani= mously without it (which is good; I want this RFC to pass). With it, it= may pass or not, but it would be a weaker proposal. At the very least bump it to an secondary add-on vote. --Larry Garfield