Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125209 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 AEE6E1A00BD for ; Sun, 25 Aug 2024 13:35:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1724593051; bh=cXu6r6Op+CBmmcJ16g5mPbh2Hhoe/zfDS1ERL1gApBs=; h=Date:From:To:In-Reply-To:References:Subject:From; b=WmDslR5Zp2gUloBvDoAxR5l8JLtTHmWvyo//dE89NOob+KjEtCIgM9RF5cFORyTys AjuumsP0BmiiH8z2S4p1f/7YEp7BCGT9vuwC5v1ajD8UZt0LwZGN1/Sf6VAwQtpFLO zhy4khmIXjB3sWuFxG1u8EXgnFUhu2++ZQB0EsuhUSE7RIkKvdZbQRB/IlSArj10Mq hkX3lqN0BUScFQH2Ssvp3qpYCD4sjGVAyEsTrw/CXUGJcgjGjAoRtsiHITRAi55TMg qcSxx0YGJ9+hGv7zyesSh0f3Yrut8yj6VlQy0GYBCytTZb58P+vzA4OuViOagGjKpM q00M4g+1SgMkw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 997E518007F for ; Sun, 25 Aug 2024 13:37:30 +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,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fhigh2-smtp.messagingengine.com (fhigh2-smtp.messagingengine.com [103.168.172.153]) (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 13:37:30 +0000 (UTC) Received: from phl-compute-03.internal (phl-compute-03.nyi.internal [10.202.2.43]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 6D48B1151A6B for ; Sun, 25 Aug 2024 09:35:37 -0400 (EDT) Received: from phl-imap-06 ([10.202.2.83]) by phl-compute-03.internal (MEProxy); Sun, 25 Aug 2024 09:35:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding: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=1724592937; x=1724679337; bh=ZmPiTzsCjaiLN5fiHm46v ltvb4Zu2osa5Eu6pvQJ2mM=; b=LPh2iqxxkRyDKaepfYMlBBzwCYTH9mvEO+8cr D7L0Hm0JPJrJFj7/LlfjflqHtbirazV+ucX/cRyuoiDaowNLBEUSv2lt/SGEBx/5 bIodM5/YGQvevVymwlXxjvyc8gymc4/7jOWMO3MMLB42RPbOcgazlVuD14PYqbiF OlpI+CzPmD2KumXr3NtNxbJPr5iuDL5eLuqtc+XpECdog5jDvkD1hgRmV7w3/cfU yLFJbidPMsNxYy2kL/OA9EwR9QtJR9APY163gA6Y/yIZq9v0MAVHm+w+3jHzGiDd KBTqrnSkmT1zK6DDlc2VQuRd6sfnXh91DIWKL6jEKCbwBmgOQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding: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=1724592937; x= 1724679337; bh=ZmPiTzsCjaiLN5fiHm46vltvb4Zu2osa5Eu6pvQJ2mM=; b=f FJ0jW0MfQeFNC/cSOHVR3XKbL7q92zIeOMOpOvtliBS1wuhVGkrbe2T12LNzbyT0 0f0hgnl06Zjmc+zP8HKYuZpSaK94Gl4YK733m+TvHdWOat+eOQ5cCj3OIXGT62FS yR2rTpOLAQ1rpM/hQG2oNogHo+J/EwrO/PyIM8ZS62Y/nQZRBYAFINm+Ct1ndmKX 9A0zX6zZanUsCbw0g9cPPxRmc7KRadresknHn5RZuTwEsooocMbE7o+zz7DCakr3 N51EFXtc000x4xGvVLatnc0fIOwICpSbdSBFIrh2c+/nh5UkRaVyfHP4D9Yvgoiz AhK2Dcev2Len5LAEx37yQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddviedgieegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepofggfffhvffkjghfufgtgfesthhqredtredtjeen ucfhrhhomhepfdfnrghrrhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfih gvlhguthgvtghhrdgtohhmqeenucggtffrrghtthgvrhhnpeeugfetieejueevffdulefh hfethfekvedtueevgfffvdefiedvtefgheevteelffenucffohhmrghinhepphhhphdrnh gvthenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehl rghrrhihsehgrghrfhhivghlughtvggthhdrtghomhdpnhgspghrtghpthhtohepuddpmh houggvpehsmhhtphhouhhtpdhrtghpthhtohepihhnthgvrhhnrghlsheslhhishhtshdr phhhphdrnhgvth X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 2BE6029C0064; Sun, 25 Aug 2024 09:35:37 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Sun, 25 Aug 2024 08:35:14 -0500 To: "php internals" Message-ID: <0cfd3a28-3cb0-4478-85fb-cf086d8e5c66@app.fastmail.com> In-Reply-To: <0c8ed5d6-5507-4c41-8d7f-05d14ba8aa4c@scriptfusion.com> References: <0c8ed5d6-5507-4c41-8d7f-05d14ba8aa4c@scriptfusion.com> Subject: Re: [PHP-DEV] [RFC] Default expression Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Sat, Aug 24, 2024, at 11:49 AM, Bilge wrote: > Hi gang, > > New RFC just dropped: https://wiki.php.net/rfc/default_expression. I=20 > think some of you might enjoy this one. Hit me with any feedback. > > This one already comes complete with working implementation that I've=20 > been cooking for a little while. Considering I don't know C or PHP=20 > internals, one might think implementing this feature would be=20 > prohibitively difficult, but considering the amount of help and guidan= ce=20 > I received from=C2=A0Ilija, Bob and others, it would be truer to say i= t would=20 > have been more difficult to fail! Huge thanks to them. > > Cheers, > Bilge I am still not fully sold on this, but I like it a lot better than the p= revious attempt at a default keyword. It's good that you mention named = arguments, as those do replace like 95% of the use cases for "put defaul= t here" in potential function calls, and the ones it doesn't, you call o= ut explicitly as the justification for this RFC. The approach here seems reasonable overall. The mental model I have fro= m the RFC is "yoink the default value out of the function, drop it into = this expression embedded in the function call, and let the chips fall wh= ere they may." Is that about accurate? My main holdup is the need. I... can't recall ever having a situation w= here this is something I needed. Some of the examples show valid use ca= ses (eg, the "default plus this binary flag" example), but again, I've n= ever actually run into that myself in practice. My other concern is the list of supported expression types. I understan= d how the implementation would naturally make all of those syntactically= valid, but it seems many of them, if not most, are semantically nonsens= ical. Eg, `default > 1` would take a presumably numeric default value a= nd output a boolean, which should really never be type compatible with t= he function being called. (A param type of int|bool is a code smell at = best, and a fatal waiting to happen at worst.) In practice, I think a m= ajority of those expressions would be logically nonsensical, so I wonder= if it would be better to only allow a few reasonable ones and block the= others, to keep people from thinking nonsensical code would do somethin= g useful. --Larry Garfield