Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123286 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 729FD1A009C for ; Thu, 9 May 2024 14:05:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1715263602; bh=VYOx4/YCEaprjX4tOhMvfgi9fvmKJu3gAQjIdbibmg0=; h=In-Reply-To:References:Date:From:To:Subject:From; b=Ars8DFH8qKMpMOVHKLpkenIaiuM3wqtsoyjLhp2Eqp+zMyw3SC982dlSIVWVIG8Ic aHWXHjCtkVj8aTzEwNHe5Py48gECN0Xp90ZfuVNkjWVzsBfgGEty0poCr79z4/EaeB ijm+zX98A4ueapjkGo+6oR0mvuOeg1bDzaRDDC+nGnbqcFS/0DJiW99KGEYBBhiauk vLXCPdYmakH8e42tE+oz/vfuXPYCZ8TJ7ofA9dEFag64l9m9dgFuj+aGVueOyH0KtG SP2v17SVSo/onQmA4et1CnoBmn01ektNfO0svysSg+JeVb4dzqEfqf/9gfBmq4/pCH ME1e2KH57UJDA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id F001B18006D for ; Thu, 9 May 2024 14:06:40 +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, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from wfout2-smtp.messagingengine.com (wfout2-smtp.messagingengine.com [64.147.123.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 ; Thu, 9 May 2024 14:06:40 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfout.west.internal (Postfix) with ESMTP id BB64E1C00199 for ; Thu, 9 May 2024 10:05:49 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute1.internal (MEProxy); Thu, 09 May 2024 10:05:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; 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=fm3; t=1715263549; x= 1715349949; bh=aznnIk2n5UEfmmBbgzmm+e0PQnSqawv1jAvsTLXgteI=; b=R QUXah4gsjykuIwyqAz+10tLWpjxDRocnsRk/gpWwWeN3rhqSb7N262xxTvhNvQps cC//kYfTiK2duu78iwPc59O60HAqSGDTQrsJbszptISjMgciqf6O/u9MCcmS/WEf TCstmQ/8jyloCreUH5Z3PQAe3670lAeZK7uvbXVR+NQQad9oT7czKVDeIj55etz1 VxjaRb8+x4YyxZoq2KcEy4uqvL4coJOIz0daprZ3MmtQHLOh28r3SeQ3y0MVEZN5 Dw9zL+3xu08VsDRAipdGQhOJpFtgqCg4/qYwI9no1Y+Z5Lhe1HYqrBEdw5d3agDA 0cRgSX0sUZeFBQW9uDABA== 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= fm3; t=1715263549; x=1715349949; bh=aznnIk2n5UEfmmBbgzmm+e0PQnSq awv1jAvsTLXgteI=; b=gZNh+UbIIjnqecKuVzHSJWwHDPMvw+M91BDoszA7rEYE 4AhdXB1nzI7mJVceeg2tKsnIWK9VArhxyV3nviRTYtcFP1aUGLYyHFEPY0RYyPF2 dhuZ32fINhibl6tceyDigWNo9VwvGD5a9uXme7FSKVqG7caQN4zvASpXsDpZ2t8j DAPO2/hUF3PAUR/g6fxpZm7sLE5L8zsGgjiuFRB3wqkUTMbH9gCGVJVmYUM34Hc3 JBac4buTT6dLuec97hRfg4c5SL14+kiV6M29e2YXWXi5rZCsvYYCUQ8CbynCsRve LJMVehtJa6P05SeHNfvC3cYPxLsiRJR6XhBRs3SU1w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdefvddgjedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdfnrghr rhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hmqeenucggtffrrghtthgvrhhnpeeglefgkeduiedvvdetffeujefftdfhjeeiveehgfff keduveektddvledvvdfffeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id C87051700093; Thu, 9 May 2024 10:05:48 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-443-g0dc955c2a-fm-20240507.001-g0dc955c2 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: In-Reply-To: References: <799ae864-6e25-4196-a5ce-0d74600a8378@app.fastmail.com> <280bcea8-9483-4191-80d3-81763a988290@app.fastmail.com> <5db38bc4-a6fd-4cb7-b10d-3ad1a590888c@app.fastmail.com> <39511e44-93cb-4fde-b0ec-ce24ee88f4be@app.fastmail.com> <07b0f341-f062-45fe-ade0-52cf75003895@app.fastmail.com> Date: Thu, 09 May 2024 14:05:28 +0000 To: "php internals" Subject: Re: [PHP-DEV] [RFC] [Discussion] Clone with Content-Type: text/plain From: larry@garfieldtech.com ("Larry Garfield") On Thu, May 9, 2024, at 1:10 PM, Andreas Hennings wrote: >> Where all properties are readonly, and if an object those are *also* readonly, and all are assigned in the constructor... >> >> Yeah, that ideal case is kinda narrow, and likely will remain so for a long while yet. >> >> Whichever order it goes in, that should be documented explicitly and the reasoning for it included. (Feel free to pilfer my examples above extensively if that helps.) >> >> As for the syntax itself, my preferences, in order, would be: >> >> 1. clone $foo with (...), where (...) follows named-argument syntax in all its variants and forms, which includes ...$arr. >> >> 2. clone $foo with $array, where $array is an honest to goodness assoc array/array literal, created by any means the developer wants. >> >> Either of those are equally expressive; the first is, IMO, cleaner and easier to read/type, and probably nicer on static analysis tools, but they're still both equally expressive. >> >> Anything less than that is, IMO, creating unnecessary confusion about how the syntax behaves that will trip up developers left and right. >> >> --Larry Garfield > > Hello list, > First, I am very much in favor of the named-argument syntax `clone > $obj with (key: $value, ...)`, with support for argument unpacking. > > The syntax is well suited for the most common case, which is regular > wither methods for one or more known properties. > I don't like the array syntax as a default. It has inferior DX for > regular withers, and possible performance impact from the temporary > array. I agree. > For the execution scope ideas: > I kind of like the idea to have a special object state or scope effect > where some properties are writable that otherwise wouldn't be. > However, I don't like this kind of concept being introduced as a > special case only for this clone execution scope. > E.g. the current "readonly" implementations actually means write-once > + write-private, applied on property level. But in the clone scope it > would mean something different. Yet again, readonly was badly designed and it's biting us. :-( This is one of the reasons Ilija and I are planning to take another swing at asymmetric visibility, which solves nearly all of these issues. Or, it will if we can avoid bikeshedding over the syntax again... --Larry Garfield