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.

> I think that's a prerequisite for adding any dedicated syntax
> for "make a closure that doesn't work until it gets bound".

To be clear, I don't support anything like that. As I wrote:

Danack wrote:
>
> That sounds like a complete non-starter. Adding something to the
> language that produces a closure that can't be called would be an
> instant new entry for PHPSadness.

cheers
Dan
Ack

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

Reply via email to