Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118407 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 3407 invoked from network); 10 Aug 2022 22:09:11 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 10 Aug 2022 22:09:11 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 85F6E1804AF for ; Wed, 10 Aug 2022 17:11:02 -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, 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 out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (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, 10 Aug 2022 17:11:02 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id D0EBE5C0118 for ; Wed, 10 Aug 2022 20:11:00 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute1.internal (MEProxy); Wed, 10 Aug 2022 20:11:00 -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=1660176660; x= 1660263060; bh=59EWG//MBl3XlQa7UKcQm8LOALA2+O78NH/GMOpqTm0=; b=W MhLlasPtr+AlbPZVEhZxCAPFTSZMxIjGufA+ttnLV4U9xEs2kTQa26TzoCT46KN8 UHVUy/AmNW1N6CjWpvB12SelCpAT787WllfusYR5Z+kI32A+/7tHr6E/BNBL0cZM PosVesWD9/8USVA7qN4CSXsHyV/kirEnBm3YHU7WKAR4WckNUEmvUUz9HfRxRv2f fnfMm5Yd3IYszgr18oiALmCuHUsNglvcrhrmFXCFdvqjy2Fa1t955n9l7HdWb8hh MUrINpgotmrV6ICFPXsSeiGVljKuiYZQLXsK3bGP0tVFEBm0bDdfu9FtCdW+YFtl 73qj//8xff/Nw8gqXcH/w== 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=1660176660; x=1660263060; bh=59EWG//MBl3XlQa7UKcQm8LOALA2 +O78NH/GMOpqTm0=; b=2IEMyXAXjqebRPXUXrBFk+bDxFzHCXOY1Wv7EQ0gYxQr t7JubNu8Mxu/j697KY8xt3b6miGOiq6ThKyMxfpP6CPtu2qXBgWI5yHuYegexppe P81phi64i4rH9mpzLhf7mgMOYELAziBa7bKeEpQooApfqZtC9ZUcGDaaapnoS2nb 2SFuB0erMf56aGbanMr6ua4jKFEQgK98c6p+NuL1e6G3XZaap5k1H1dNmbJunDOa AWjY0gr4FTG3KzP3n2L2i8w+DmAKSLZA9eFK3USf/0GZ9/hzqmpwJ4ihOqi+yBQ/ BLLmm3oe0j8W9G1Sluq/AtRFhVltQGBQkt9/Jip7nA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdegfedgfeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdfnrghr rhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hmqeenucggtffrrghtthgvrhhnpeeglefgkeduiedvvdetffeujefftdfhjeeiveehgfff keduveektddvledvvdfffeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 7B68F1700082; Wed, 10 Aug 2022 20:11:00 -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: <1f37ea30-249c-46fd-b99d-9f2097ed86b2@www.fastmail.com> In-Reply-To: References: <62f3da67.810a0220.ed5e8.1b2cSMTPIN_ADDED_MISSING@mx.google.com> <17C7EF67-298D-40E8-A872-5A9D78A7EEDA@gmail.com> Date: Wed, 10 Aug 2022 19:10:40 -0500 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] Re: [Concept] Extension methods From: larry@garfieldtech.com ("Larry Garfield") On Wed, Aug 10, 2022, at 5:23 PM, Deleu wrote: > On Wed, Aug 10, 2022, 11:30 PM Rowan Tommins > wrote: > >> >> To be honest, I put them in that order more for "purity" reasons: if they >> come before __call, they can change the existing behaviour of the class, by >> defining an extension method with the same name as a "virtual" method >> implemented with __call. That then becomes a very different feature. >> > > I would argue in favor of extension having precedence over __call because > 1) classes with __call wouldn't be able to be `extended` and 2) extensions > could actually "fix" the ~ab~use of some use of __call. I suppose this > would allow me to write an Extension that mimics the exact behavior of > __call and actually avoid __call from being hit while still keeping the > same behavior of the class. Possibly very dumb idea, but I'll throw it out anyway: Would it be OK if extension methods came *before* normal methods? Would that allow a compile time translation of this: use extension Foo:bar; $collection->bar($b); to this: Foo::bar($collection, $b); Since the extension would only have public access anyway (modulo messing around with rebinding and reflection, of course), it's logically equivalent to just a static method like that. That could allow the existing autoload logic to work (if extensions compile into just classes), and no runtime overhead because it's "Just" a static method call; if it's missing, oh well, it just fails like a static method call. A side effect of that is indeed that you could override an object's method externally, in effect, at the loss of internal access. I... could probably make a solid argument for that being very good or very bad, depending on my mood. (I'm at the moment lukewarm on the idea overall, and I still believe pipes are the superior solution, but if we do it then it should be done well.) --Larry Garfield