Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118412 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 54165 invoked from network); 11 Aug 2022 12:20:36 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 Aug 2022 12:20:36 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1DFDD180506 for ; Thu, 11 Aug 2022 07:22:39 -0700 (PDT) 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,SPF_HELO_PASS, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS29838 64.147.123.0/24 X-Spam-Virus: No X-Envelope-From: Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (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 ; Thu, 11 Aug 2022 07:22:38 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 6EA303200912 for ; Thu, 11 Aug 2022 10:22:36 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute1.internal (MEProxy); Thu, 11 Aug 2022 10:22:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc: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=1660227755; x= 1660314155; bh=kwgwFM+Z5Ymi31rHK1QOPb/2qFkmCSCP2zbhCBmk7Xw=; b=I eD+hnTm6+4/E/UGeHjybiEhnhQkwyRJkUcHaG1/TBKVkPPKuIzr6YXCZOqMWw9BF cwNgVPL4wR2yp1urEObeEGE1tjpK7t9KMKVbCTxvMH/RlqUMmu/P/yy1Azu/S+46 02hiLcRC0X+ZJfV00vt7J2FmECuNtfeHpTaXB6NNXo+Nsh05pW9SYXi0c4XHe6F/ NVQLWWyPeX7xXDSVGeFnT3Q3G5ACbrZIFRkSbFW3IEvPUhi86dU3Sw+ohajTQad1 9dEzbQU3mtrNBwHF5yIN+3Vgv4O+B9ggE1AlgL0PG8VCARPhY53BSrCSwVALPB3H alN1rlljG+BSt9vDsqXzw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=1660227755; x=1660314155; bh=kwgwFM+Z5Ymi31rHK1QOPb/2qFkm CSCP2zbhCBmk7Xw=; b=c+p2w0l4c7SWGB6JcSti7cqpue3RBm5j3THDtCw/uYrv uUM96w27gWxZfGzk6Ksn1rX9ZpQZQI4NGe1s+z3DJt+jpXf28tSib+8XPsWFBlvh uGtZ/qwy9vKLeYBGaFFI6vcuwZyoiWVmUOUhvTltuqrgEokiq8xmiEg5fFXe0iGM g65oWgZvfICpDD9WcdGTiAaEtNM5W7G6mC+AfLP1687M0L3CXz4lRl5jeUkPtpVq sQxvGildouflzOc9uemF37yn+w3us6WCVxj3W8NEW1fdxrhkr7ahGQc2yCcboNW5 G83kEWoA/Iw+PiYgCIqYDdXnK+6Mk4yBzNLzH68N/A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdeggedgjeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdfnrghr rhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hmqeenucggtffrrghtthgvrhhnpeeglefgkeduiedvvdetffeujefftdfhjeeiveehgfff keduveektddvledvvdfffeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 9F3D31700083; Thu, 11 Aug 2022 10:22:35 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-811-gb808317eab-fm-20220801.001-gb808317e Mime-Version: 1.0 Message-ID: <326783c2-b480-46d8-88b4-bb1d53265bae@www.fastmail.com> In-Reply-To: <3a3085d7-1abb-9f89-90b8-2bd725357614@gmail.com> References: <62f3da67.810a0220.ed5e8.1b2cSMTPIN_ADDED_MISSING@mx.google.com> <17C7EF67-298D-40E8-A872-5A9D78A7EEDA@gmail.com> <1f37ea30-249c-46fd-b99d-9f2097ed86b2@www.fastmail.com> <3a3085d7-1abb-9f89-90b8-2bd725357614@gmail.com> Date: Thu, 11 Aug 2022 09:22:15 -0500 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] Re: [Concept] Extension methods From: larry@garfieldtech.com ("Larry Garfield") On Thu, Aug 11, 2022, at 3:05 AM, Rowan Tommins wrote: > On 11/08/2022 01:10, Larry Garfield wrote: >> Would it be OK if extension methods came*before* normal methods? > > > It would certainly be possible, and seems more logical than allowing > extensions to over-ride __call but not anything else. It does lead to a > very different feature, though: it means that you can take a fully > working unit of code, add a "use extension" line at the top, and change > the behaviour of that code. > > I haven't looked in detail at how other languages implement them, but my > impression is that such a behaviour change would be something other than > an "extension method" as normally understood. > > >> Would that allow a compile time translation of this: >> >> use extension Foo:bar; >> >> $collection->bar($b); >> >> to this: >> >> Foo::bar($collection, $b); > > > Unfortunately not, because the compiler doesn't know anything about the > type of $collection, so doesn't know whether to apply the extension. The > process would look something like this: Ah, good point. I keep forgetting that even though well-written code has pretty sold type information, it's not quite enough to be able to do anything useful at compile time, generally. Poopy. If that makes the performance even worse on every method call then it's definitely not worth considering. --Larry Garfield