On Mon, Jan 23, 2023, at 3:52 PM, Dan Ackroyd wrote:
> On Mon, 23 Jan 2023 at 20:51, Larry Garfield <la...@garfieldtech.com> wrote:
>>
>> On Mon, Jan 23, 2023, at 12:32 PM, Dan Ackroyd wrote:
>>
>> >
>> > $fnConstructor = Closure::fromClassConstructor(Zoq::class);
>> > // signature of $fnConstructor is the same as `function(Fot $fot): Zoq`
>> >
>> > Or for individual methods:
>> >
>> > $fnMethod = Closure::fromClassMethod(Zoq::class, 'Pik');
>> > // signature of $fnMethod is the same as `function(Zoq $zoq, string
>> > $zebranky): Frungy`
>>
>> I don't think that actually helps.  If you have the object already,
>
> Neither of new functions I was suggesting have the object already.
> Only the type.
>
>> If you do not have the object already, then we run back into the issue
>> I pointed out before where we need to differentiate a bindable from
>> needs-binding callable,
>
> That's not what I suggesting.
>
> Danack wrote:
>>
>> $fnConstructor = Closure::fromClassConstructor(Zoq::class);
>> signature of $fnConstructor is the same as `function(Fot $fot): Zoq`
>
> That doesn't need a binding at all.
>
> Danack wrote:
>>
>> $fnMethod = Closure::fromClassMethod(Zoq::class, 'Pik');
>> signature of $fnMethod is the same as `function(Zoq $zoq, string
>> $zebranky): Frungy`
>
> First parameter is the object to be operated on. You wouldn't need to
> do any binding. *magic* would happen inside the function to take care
> of that.

Oh, I see what you're getting at.  I missed the signature on first read.  So 
you're saying that would generate a callable equivalent to:

$fnMethod = fn (Zok $zok, string $zebranky): Frungy => $zok->Pik($zebranky);

That's an interesting idea, though probably not self-evident to many people.  
If we wanted to do that, I'd probably push for something more compact as a 
syntax, and a bit more auto-refactorable.  I think the Ara language had syntax 
for something like this, $$->Pik(...) ?  If I'm remembering correctly, which I 
may or may not be?

(We're also now rather far afield from the OP's request, I think.)

--Larry Garfield

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to