Re: Re: [Concept] Extension methods
| From: | Rowan Tommins | Date: | Wed, 10 Aug 2022 21:30:42 +0000 |
| Subject: | Re: Re: [Concept] Extension methods | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-118404@lists.php.net to get a copy of this message | ||
On 10 August 2022 18:52:58 BST, Alex Wells <autaut03@gmail.com> wrote:
>Thanks for explaining it better than I did.
>
>Regarding the implementation, that was roughly what I was thinking.
>
>But can't we put extension methods second, after real methods but before
>__call? As far as I understand, the reason to put it after __call is to
>avoid a performance penalty on __call calls, but this would mean extension
>methods are not possible for classes that implement __call. Not a huge
>deal, but a thing to consider.
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.
If there was a way for __call to signal "no implementation for this method name", you
could look for extension methods if that was returned; but at the moment, a class implementing
__call is assumed to reserve *all* method names.
I suppose a related question is whether __call itself could be implemented by an extension method. I
would suggest no, to keep things simpler.
(Aside: Reminder that convention on this list is to "bottom-post": quote the part of
message you're replying to, then add your text below.)
--
Rowan Tommins
[IMSoP]