Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121028 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 39054 invoked from network); 10 Sep 2023 10:38:20 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 10 Sep 2023 10:38:20 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A23F61804AC for ; Sun, 10 Sep 2023 03:38:17 -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.2 required=5.0 tests=BAYES_20,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, T_SCC_BODY_TEXT_LINE 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-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 10 Sep 2023 03:38:17 -0700 (PDT) Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-401ec23be82so38875285e9.0 for ; Sun, 10 Sep 2023 03:38:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694342295; x=1694947095; darn=lists.php.net; h=content-transfer-encoding:mime-version:message-id:references :in-reply-to:user-agent:subject:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=OsIHcq0Bg9Tu6jWqMbIQdjBbewz6Y3g2rZPR7Wfbh0I=; b=k4xpL8iR1kszTcXt78ZmXnCC7Z6BSFV4WVlRQpMSO8UfTnfhI30MpZyob+bt/zAMGI QNpsSBdUcgdfje0GrdPVPYhXFUQpYBGpPyMbQQf7gUkOoChft/QlZfAy7XqHFZ/7vS8X x3rhlni7jdbwXOHYXM8sls+MLMJMdZdXr1WvoCKk4wmVaoaLA1YhhPj+BYPQJZCTbHZo Or5W1WjITiEDwGt1yCy+6Y9+0G9LlR0feRrWe/dscYl1V0zr+Ah2moxTWOegsY418qNf 9ztvMxMw4QXzU1C+WuL/8Iqxwm69N0qIiPjijPro21pnJITIK8q0YMmkljtDlFczbMS5 5tSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694342295; x=1694947095; h=content-transfer-encoding:mime-version:message-id:references :in-reply-to:user-agent:subject:to:from:date:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=OsIHcq0Bg9Tu6jWqMbIQdjBbewz6Y3g2rZPR7Wfbh0I=; b=d19bvDurbTlA97owdSz98x2ugB8V7fa2pPoSJwnO8LrwNRDA8SAPBsFFhgtegnjx+m Mld135WjCqt9tJoexN+MDHmQNAzmripjbF6AD4iVgVWs3iCgS8qvDwETCt0Fotp6kCvJ R0Eh3X7+RiEl+619SanrhVUPGp7Dbe6xexf/E8NwbxAUJzAqOIzF3SpyraZNDyBnzDHo C6q7ABJ6cgnDQvjxS9nI+ZF4kpj2xONDMrIbvbMmuDdN54YD2aBtnMK3NQd/Bt2CpAQf TZY9WWw8Jtrjs9oyfJnb10H8rNGz5v0ddWQgkNWlIjLLGFZbziNJNTpnc3xSIbfV+LZt 8Y7A== X-Gm-Message-State: AOJu0Yy5B1TDyd/TqP7kPn7wVGcy6sgLMEylh6EnwQ6NmDFKso9/Vp8D boXpC8LP5CW7HOEpMg+6tJaOkkKLByU= X-Google-Smtp-Source: AGHT+IGIpPFyT125XIB6mW1cxtoKr6WMOydBxx+XmODUXpJ4ZxPlsH2ErL7A53nEbIl8W2UMKLHVVg== X-Received: by 2002:a7b:cd12:0:b0:3fb:ff34:a846 with SMTP id f18-20020a7bcd12000000b003fbff34a846mr6214662wmj.22.1694342295437; Sun, 10 Sep 2023 03:38:15 -0700 (PDT) Received: from [127.0.0.1] (cpc83311-brig21-2-0-cust191.3-3.cable.virginm.net. [86.20.40.192]) by smtp.gmail.com with ESMTPSA id 3-20020a05600c22c300b003fe2b6d64c8sm10023179wmg.21.2023.09.10.03.38.13 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 10 Sep 2023 03:38:14 -0700 (PDT) Date: Sun, 10 Sep 2023 11:38:12 +0100 To: internals@lists.php.net User-Agent: K-9 Mail for Android In-Reply-To: References: Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC][Draft] Match block From: rowan.collins@gmail.com (Rowan Tommins) On 8 September 2023 23:16:07 BST, Ilija Tovilo = wrote: >Hello everyone > >I've been working on match blocks over the last few weeks=2E >https://wiki=2Ephp=2Enet/rfc/match_blocks Hi Ilija, Thanks for working on this=2E A few initial thoughts=2E=2E=2E The use of "<-" as the new token doesn't fit the language very well=2E The= "family" it belongs to are all keywords not symbols: return, yield, throw,= break, continue=2E I understand that you don't want to reuse one of those,= but presume a new keyword would not need to be fully reserved? Relatedly, I note that in the RFC text, you've talked about the arms "retu= rning" a value, but also made clear that a return statement is also allowed= =2E I think it would be clearer to pick a term other than "return" for what= this token does, and use it consistently=2E My suggestion to start the ball rolling is "resolve" - that is, "The block= resolves to a value given after the 'resolve' keyword=2E" Having said all that, the ability to put control flow like return and yiel= d into match statements feels a little weird to me=2E Again, it's partly th= e syntax - the "=3D>" is reminiscent of array literals and short lambdas, w= hich are very much expressions not statements=2E You say in the introduction that part of the motivation is to more complet= ely replace "switch", but I wonder if that would be better solved with a di= fferent construct that handles the non-expression-like uses of switch=2E In= particular, although fall-through by default (if "break" is not specified)= is definitely a historic mistake, the *ability* to fall through to another= case is sometimes useful, so those cases would still not be convertible to= "match"=2E A "strict switch" could look more like the current control flow structures= , but add strict equality (and pattern matching in future) and remove impli= cit fall-through, without having to squeeze into the same syntax as match e= xpressions=2E My final thought for now is a short and slightly off-topic one: someone re= ally needs to look into adding opt-in block scoping to PHP, similar to JS "= let"=2E It would fit so well with proposals like this one! Regards, --=20 Rowan Tommins [IMSoP]