Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125226 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 996211A00BD for ; Sun, 25 Aug 2024 17:12:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1724606041; bh=lCo+QzFfa6AdGpSoNRcUXUqQtT4U8+UsTTc2Q58Cp1I=; h=Date:Subject:To:References:From:In-Reply-To:From; b=A2FzBA1lV8xiOETLoEihnHEFm+U4RDITnswZOVcuArMMVRCQFc+MmJasmqxhqaeCb cye1ObZ8LAKX75WFxMJpIuFoa+nUhIzvesTnGWlhjNbaI8Ui0LBKDMP2wgcGtX6Xpj lVUFF6pIpH9zt1t1BhzNjEIVo2UjEtNuAPIUTBVVGcg0ceHrQ5EJI5WCjPaMwkZuK7 qFVKp7tbAMLf5SYhaHi5Bw0c3th9I2dZXhKqRpcC/ypkkokQuVmsz27nEe9VbEo09D Iz77awqyXAHCpBS5lpJRXSqH9UWfqdi59Z35Nlqz6WusBGdkbnGni/YN5Hal4ZIYBK TuaBog2hkVyOw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9FC051801D8 for ; Sun, 25 Aug 2024 17:14:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fout2-smtp.messagingengine.com (fout2-smtp.messagingengine.com [103.168.172.145]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 25 Aug 2024 17:14:00 +0000 (UTC) Received: from phl-compute-01.internal (phl-compute-01.nyi.internal [10.202.2.41]) by mailfout.nyi.internal (Postfix) with ESMTP id 777AC138EB1F for ; Sun, 25 Aug 2024 13:12:07 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-01.internal (MEProxy); Sun, 25 Aug 2024 13:12:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1724605927; x=1724692327; bh=Dsp/ECxdVq AFxXOFwLrLoI9IH3tLvohvsgc7zbHHhWs=; b=goVzeSlA3a++Ld/yPhFC0aqATx dBGnMQzLSfe/lja+OLbXQRPj8ftvEEzItWHJECRKdJ6ZifuM5VhqnBMviJjLkAlU B2kS4rTNtxBGK3H6A4sWJdbkGmeSr2BArR7Qb3cKeX+zrusVHz3myID/7IwZv0db PfliavXKLblb1brasCdlRL/8b//AVbK5v6Y6FdynmMh9vldkn8up38+/3h7YJ+yi BY3SXp39R171haDBC5Zk2z0Q2CyhwLVrRWgVkQVWU4LWpo0Jf6CjmctXy88O05O/ JSwUw4jJhtJoXmpYkf5blVO2j2QlN4HsG3Cv3GKZuKseQVlfb+MsDL/iVF2Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1724605927; x=1724692327; bh=Dsp/ECxdVqAFxXOFwLrLoI9IH3tL vohvsgc7zbHHhWs=; b=ER/gT2m6q54q80Vq3yiyJYe53fQSRyh5w+oCACfRxr1T 1rvBfm3VQAG6Ccp9VnpJlO23tdu8Nb9wIzsTk03BfVP1Z4QM/+qO6JxqWAbMT3mm ipODUZWcvh5MC3g8XBE5WNyRsHDaNCoHUUgFfDyjgMMkBQbumCLUcAjTgVc//ng1 8AN1EqwGB4wr3rex4kaBAkfVeMPeoRTKEMpGRbo+vqppyKmv4opv4cVdDA/HsdcQ bsHpf7CTHPZ82iPQzfT8BRY3W24RvPEUQJgCsqPjOuGOIo06+PCQh8G6TqutMgti ObWGDZGNAVq4pyW2PVESb0AQojas1RfS204I5TzZUg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddviedguddtlecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurheptgfkff ggfgfuvfhfhfgjsegrtderredtvdejnecuhfhrohhmpedftfhofigrnhcuvfhomhhmihhn shculgfkoffuohfrngdfuceoihhmshhophdrphhhphesrhifvggtrdgtohdruhhkqeenuc ggtffrrghtthgvrhhnpeehteelieeigfeuudeiueeiffdvveehudeufeekjeeugffffedt iedtgeettdelteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehimhhsohhprdhphhhpsehrfigvtgdrtghordhukhdpnhgspghrtghpthhtohep uddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepihhnthgvrhhnrghlsheslhhish htshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Sun, 25 Aug 2024 13:12:06 -0400 (EDT) Content-Type: multipart/alternative; boundary="------------pxl8dKxIYEXgQJmdSK4WLiGL" Message-ID: <69a5258d-05e4-420e-b4bf-1f58b45e1fc7@rwec.co.uk> Date: Sun, 25 Aug 2024 18:12:02 +0100 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] [RFC] Default expression To: internals@lists.php.net References: <0c8ed5d6-5507-4c41-8d7f-05d14ba8aa4c@scriptfusion.com> <0cfd3a28-3cb0-4478-85fb-cf086d8e5c66@app.fastmail.com> <3e0d031e-256f-47cd-9a2b-dcdc760f5498@scriptfusion.com> Content-Language: en-GB In-Reply-To: From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") This is a multi-part message in MIME format. --------------pxl8dKxIYEXgQJmdSK4WLiGL Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 25/08/2024 17:36, Ilija Tovilo wrote: > I don't agree with that. Constant expressions in PHP already only > support a subset of operations that expressions do. However, default > is proposed to be a true expression, i.e. one that compiles to > opcodes. This is circular: obviously, changing the proposal requires making changes to what is proposed. I'm arguing that allowing default as a token that's usable in arbitrary expressions is unnecessary and problematic, and that we should instead define the specific use cases, and build the feature around those. > I also believe some of the rules you've laid out would be hard to enforce. The rules were intended to guide the design of the feature, not be things that someone needed to enforce in code somewhere. If you start with the aim of implementing: - Use in place of an argument - Use with bitwise | and & - Use on the RHS of ?: and ?? Then maybe you end up with a completely different implementation from what's currently been written. For instance, rather than adding "default" to the "expr" rule in the grammar, and then restricting it at compile-time, maybe we add a new grammar rule "expr_with_default", usable only in expressions and with a very limited set of productions. Maybe that means we can't support match() expressions, because it would bloat the grammar too much, but "match($foo) { 'blah'=> 'bleugh', default => default }" is pretty ugly anyway. Or maybe, the expressions are allowed, but they're compiled down with "default" as a special pseudo-type that has limited legal operations, so that the result of "(int)default" is undefined, no matter how you try to obfuscate it. Just because it's easy to implement a feature a particular way, doesn't mean that's necessarily the right way. -- Rowan Tommins [IMSoP] --------------pxl8dKxIYEXgQJmdSK4WLiGL Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit
On 25/08/2024 17:36, Ilija Tovilo wrote:
I don't agree with that. Constant expressions in PHP already only
support a subset of operations that expressions do. However, default
is proposed to be a true expression, i.e. one that compiles to
opcodes.


This is circular: obviously, changing the proposal requires making changes to what is proposed.

I'm arguing that allowing default as a token that's usable in arbitrary expressions is unnecessary and problematic, and that we should instead define the specific use cases, and build the feature around those.


I also believe some of the rules you've laid out would be hard to enforce.


The rules were intended to guide the design of the feature, not be things that someone needed to enforce in code somewhere. If you start with the aim of implementing:

- Use in place of an argument
- Use with bitwise | and &
- Use on the RHS of ?: and ??

Then maybe you end up with a completely different implementation from what's currently been written.

For instance, rather than adding "default" to the "expr" rule in the grammar, and then restricting it at compile-time, maybe we add a new grammar rule "expr_with_default", usable only in expressions and with a very limited set of productions. Maybe that means we can't support match() expressions, because it would bloat the grammar too much, but "match($foo) { 'blah'=> 'bleugh', default => default }" is pretty ugly anyway.

Or maybe, the expressions are allowed, but they're compiled down with "default" as a special pseudo-type that has limited legal operations, so that the result of "(int)default" is undefined, no matter how you try to obfuscate it.


Just because it's easy to implement a feature a particular way, doesn't mean that's necessarily the right way.


-- 
Rowan Tommins
[IMSoP]
--------------pxl8dKxIYEXgQJmdSK4WLiGL--