Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119560 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 91741 invoked from network); 15 Feb 2023 23:25:10 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 15 Feb 2023 23:25:10 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8E0BA18033A for ; Wed, 15 Feb 2023 15:25:09 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS19151 66.111.4.0/24 X-Spam-Virus: No X-Envelope-From: Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 15 Feb 2023 15:25:08 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 52E035C011C for ; Wed, 15 Feb 2023 18:25:06 -0500 (EST) Received: from imap50 ([10.202.2.100]) by compute4.internal (MEProxy); Wed, 15 Feb 2023 18:25:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to; s=fm1; t=1676503506; x=1676589906; bh=33UkH4XTEI+dvArc5q9fdk+ve mhoAdU/ajwkyp7qSrs=; b=Xb4MaPWprmJMy8xHFBn17HvgFkjDfBtSuDLj+Sm2L CP8MMjW+E90zXaaipwqiVRj9sV/bUjc9CwSvbwRO8qUV3mHhgf9sLnlsmrlxVQpt y32TxxgtkAVqQyPBySJJtKx1NPfUSjKqEMhcSoVEjJFG+cBNwx3KsdHPxgSTuaps Nw8LL0RnoUC+D9cHozE2sMNRV+TPTv1EqvMOekkso3dCdPRd0Aa1ACqz0ZFrQQm4 GYriJHOV4jkyVAM5tOtOyShI9H7Su3zlL/b4RuxFeEgNWkOpyINzQDxfqeLnpmsI c+2hmoDciLK4fjQpAB/NsOs4RSrtWH30X7NaT3aquCGdw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1676503506; x=1676589906; bh=3 3UkH4XTEI+dvArc5q9fdk+vemhoAdU/ajwkyp7qSrs=; b=qyfviDU4tYwkArrvF 5V8pgN7PCl7HI/9UIYfQYxYLXkXupsgGam9cn2TzKouKrHwQ7M+bb44QEzpnDXh9 fch6DqJITYnZ6vJaqI6UJJGAlaFffQYUKe3qgB9owPnpPkmOJFUA+0AGn+KVTDaq rr8Evln5J+8dTyKtNmocO5DI4Z32JGBbqgvAvxXgt8Cd9DgTZ8eTMb/RJ5b6Kg7R p3DVzmCEM/cO3X82bxjNXFI3V0DAXU2UVxWmn+3hJKX3sdOJiNWr1bX1niXVTo+d aZIvJV9tQ7njcDhLfPIOsbpRQY+SBGmZTDckA6qno8mcyjZvX07B31QsBadyCxxo CTiOA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudeiiedgtdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgfgsehtqhertderreejnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepffffffejffdugfegvedviedttedvgfejffefffej leefjeetveehgefhhfdvgfelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 1491A170034E; Wed, 15 Feb 2023 18:25:05 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-156-g081acc5ed5-fm-20230206.001-g081acc5e Mime-Version: 1.0 Message-ID: <5e4d4fc4-5368-4abf-aa6b-ae964e6a263e@app.fastmail.com> In-Reply-To: References: <92c4514f-70e3-75c9-7084-9e29641e25e7@gmail.com> <7e86a2d2-b971-592c-64e3-e86c13b5be80@cubiclesoft.com> <84204896-F9CE-4186-8A72-573A0B46FC1D@gmail.com> Date: Wed, 15 Feb 2023 17:24:44 -0600 To: "php internals" Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] Working With Substrings From: larry@garfieldtech.com ("Larry Garfield") On Wed, Feb 15, 2023, at 1:35 PM, Thomas Hruska wrote: > On 2/15/2023 6:03 AM, Lydia de Jongh wrote: >> Hi, >> Very interesting topic! On which I have NO experience =F0=9F=99=88 >>=20 >>=20 >> In some other languages every variable IS an object..... by default. >>=20 >> As far as I understand, the code above is meant as internal. >> But what if any variable is a small object. >> Has this been ever considered? Or would it use too much performance? >>=20 >> $oString =3D 'my text'; >>=20 >> $oString->toUpper(); >>=20 >> echo $oString; // 'MY TEXT' > > The above represents a significant amount of scope creep but it's=20 > certainly interesting. So let's explore it a bit and gauge the respon= se. > > The above code will currently throw an error. Significant global=20 > adoption of such a change will take a fairly long time - probably a=20 > decade, maybe longer. > > AFAIK, there is nothing technically preventing the core Zend engine fr= om=20 > accepting a -> token after a string variable and calling a function th= at=20 > performs an inline modification of the string. > > As a brief test, I just ran the example code through PHP and got: "PH= P=20 > Fatal error: Uncaught Error: Call to a member function toUpper() on=20 > string in test.php:4" The error message shows that Zend engine clearl= y=20 > already recognizes toUpper() as an attempted function/method call on a=20 > string...it just doesn't know what to do with it. So the logic for=20 > supporting -> method calls on strings appears, at least from my very=20 > brief test, to already be mostly in place. Nice! *snip* What you're describing here is "scalar methods", which has been discusse= d on and off for many years. The idea has its proponents, but also its = detractors. (I'm in the detractor camp, personally, as I think there ar= e better, more flexible options.) I would strongly recommend not allowing "faster string manipulation" to = scope creep into scalar methods, as that will almost guarantee that it n= ever comes to fruition. :-) IF scalar methods were to happen, they shou= ld happen on their own. --Larry Garfield