Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122611 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 7C2411AD8F6 for ; Mon, 11 Mar 2024 16:11:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1710173534; bh=GRw6cpK9FzV010H66W8BHTdaBz7bqBpiSH4Odh/ZYgc=; h=In-Reply-To:References:Date:From:To:Subject:From; b=Fa4djYDYMhAc5BGUbd2cMQCpOJTFgH41lvmb9bU4YOgt7Di9hefJJnckE/UBiX9MR LMN1ks0ioOAxItEtvbq9xRbaq0oQx1wysoqDRMwhoTx6YHdmbsvtb5GJQT3btaO4AN kCpYlrFTMNISIeEaHjgkB8T6zzD/XM/ZnI7Ikt4cmPJav5SvoKTLUDedhP34H8By/W EfpDlfvmL40MB0Lih/v37lZVTn1+GoGr9WSfhFYvWu4ygWbJSmdIlssAdmxFpzYvXP 96kLdU2tz3hCHIbByDhfBsmNeiCr7ALF8ogVInYh3SrrXupN+FASoHtf/87u45Ue4B YhXUl4JDdwfiw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B9DDB1801DB for ; Mon, 11 Mar 2024 16:12:13 +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 out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (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 ; Mon, 11 Mar 2024 16:12:13 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 983195C004D for ; Mon, 11 Mar 2024 12:11:56 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute1.internal (MEProxy); Mon, 11 Mar 2024 12:11:56 -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=1710173516; x=1710259916; bh=p7zhsG7JeAJI+NbmDSnxN Nrthm0bprsOujBgmqHhGVQ=; b=ebYBUBBdcoDV9b0m7qVm06RYAbzaoNgQVdoJx HUg50tUlvpw/eurMF0A4P7V0OzYnyuRRV/G802wwID9BQo2/YblaouKMljT4L4k1 Qc35e7KyueosdtdN62yq6To2KVnyBvkdKzHa3uhZAjMW0OCdg+c+w8c7A1Oe9nUf k26RKJT7h1G7qwkfJ0J/E9UidUV+aXxa0Vz6sA5Ddu78lNd5yMIehHoTBLxHKMGi sZ7W/rUfmRuxvfuu6L+TNChpsQl61MCZ8j+3PIM4KmvbphPArado3YPFDEaXn401 HE8AP0QqgKjI3Gs3bHqrvW4LQ6bK4A1kNltMPO+j5POPGI4qw== 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=1710173516; x= 1710259916; bh=p7zhsG7JeAJI+NbmDSnxNNrthm0bprsOujBgmqHhGVQ=; b=p YQ0UomuT0KNKj2NqVR213rEr020XVEkLMjTBHJ7M8eIlyUGBi5AcGRf/DZvqMdj7 RVLVCf4sbjGz6IogqaWC83gdY/fMjR1SlyvAHmC9IFKkrqTsu+OCs3uMwtKhCAkL 4T6uM/UNB5BKATYIIerHCYqhuXOTEjz1B9s28H5NG0+XEDWHWIEmAoOTJ92qT/2+ rmq6ZDEvlSDsMkMCDaiJ3oVdt0NzDFUnXvlyvOQaMs1l9YWxFsPPOLCPUIafshCX f0wv09OzP1FPZI0ckPYnSIfbdv16mSarN5lZlOlMykqWvZsMe0MTA9p0vjXK0wjT x5V+jN/7/V3xPCWoENrDA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrjedugdekhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtgfesthhqredtreerjeenucfhrhhomhepfdfnrghr rhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hmqeenucggtffrrghtthgvrhhnpeekvedvhfekueeivefhuddtfeegffetgeffuedukeei ieetgedtkeetkeehteettdenucffohhmrghinhepghhithhhuhgsrdgtohhmpdgtohhnth grihhnvghrqdhofhhfshgvthdqsggvhhgrvhhiohhurhdrmhgunecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlh guthgvtghhrdgtohhm X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id ED4F41700096; Mon, 11 Mar 2024 12:11:55 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-251-g8332da0bf6-fm-20240305.001-g8332da0b Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: In-Reply-To: <1MzJ8G_MuG-LJsMSoGDIRBmSODjO4hxPACqMoQYfx83MS-du6sskpNLJ45HnzPYMoUNkXyGiZEUAtFk-uyeGDv_Kwg6Qgtod05pXCQH-8M8=@gpb.moe> References: <1MzJ8G_MuG-LJsMSoGDIRBmSODjO4hxPACqMoQYfx83MS-du6sskpNLJ45HnzPYMoUNkXyGiZEUAtFk-uyeGDv_Kwg6Qgtod05pXCQH-8M8=@gpb.moe> Date: Mon, 11 Mar 2024 16:11:16 +0000 To: "php internals" Subject: Re: [PHP-DEV] [Pre-RFC] Improve language coherence for the behaviour of offsets and containers Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Mon, Mar 11, 2024, at 12:52 PM, Gina P. Banyard wrote: > Hello internals, > > I would like to get some initial feedback on an RFC I've been working=20 > on for the last 5=E2=80=936 months. > The RFC attempts to explain, and most importantly, improve the=20 > semantics around $container[$offset] as PHP is currently widely=20 > inconsistent. > > The RFC is about six thousands words, so I would recommend a cup of=20 > tea/coffee before starting to read it. > > The main things which are still in flux is the naming of the new=20 > interfaces and methods, the phrasing of error messages, and the=20 > behaviour around using null as a container. > Those are generally indicated with a TODO comment. > > Of note is that I will also be going on holiday for 3 weeks from the=20 > 19th of March, so ideally most of the feedback would come during that=20 > time frame so that I can finalize the RFC after my holiday. > > RFC:=20 > https://github.com/Girgias/php-rfcs/blob/master/container-offset-behav= iour.md > > > Best regards, > > Gina P. Banyard Woof. That's my kind of RFC. :-) The extensive background helps a lot,= thank you. I am generally in favor of this, and have wanted more fine-grained Array= Access interfaces for a long time. Thoughts in no particular order: * "Dimension" is clearly based on the existing engine hooks, but as a us= er-space dev, it's a very confusing term. Possibly documentable if ther= e's an obvious logic for it we could present, but something more self-ev= ident is probably better. * I am not sure combining get and exists into a single interface is righ= t. I'm not certain it's wrong, either, though. What is the argument fo= r combining them? * Do we have some guidance for what offsetGet() should do when offsetExi= sts() is false? I know there isn't really any now, but it seems like th= e sort of thing to think about here. * You sort of skirt around but don't directly address the impact of this= change on the long-standing desire to make array functions accept array= ified objects. What if any impact would this have there? Eg, could som= e array functions be made to accept array|DimensionRead without breaking= the world? * How, if at all, does this relate to iterable? I think it has no impac= t, but since it's in the same problem space it's worth confirming. * You mention at one point applying shim code ArrayAccess to make it wor= k like the new interfaces. Please expand on that. Do you mean the engi= ne would automatically insert some shims, like how `__toString()` now ma= gically implies `implements Stringable`? Or some trait that objects cou= ld use (either a user-space trait or an engine trait) that would provide= such shims in an overridable fashion? I don't fully follow here. * Big +1 to removing the magic semi-silent casting when using weird key = types. * I feel like some of the sections could benefit from more short code ex= amples. Eg, What the heck does fetch-append on a null even look like? = That would help illustrate why the current behavior is weird, or why som= e things need to stay non-obvious because they're used in odd cases. (Li= ke how $a[1][2] is a by-ref fetch internally, something most people don'= t think about.) * What would the changes to ArrayObject mean for a backing object that u= ses hooks on some properties? It says __get/__set would be bypassed. W= ould hooks also be bypassed? (I have no clue what the preferred logic h= ere is, honestly. Just thinking aloud and hoping hooks pass so that we = have to think about this. :-) ) * If I read correctly, an internal object that implements one of the dim= ension handlers will automagically appear to user-land as having the cor= responding interface, much like `__toString()`/`Stringable`. Is that co= rrect? It seemed implied but not fully stated. If so, a brief code exa= mple would help to make it clear in such a long RFC. Again, thank you for your work on this, and I hope it passes easily. --Larry Garfield