Re: [PHP-DEV] [RFC] Draft - Closure self reference

2020-11-20 Thread Sara Golemon
On Wed, Nov 11, 2020 at 12:37 PM David Rodrigues wrote: > My suggestion is to reuse the keyword `as` to set a variable that will > represent its own closure. It is more flexible once that we could choose > any name and reuse in nested closures. It is pretty similar to how SQL > works too. > > fun

Re: [PHP-DEV] [RFC] Draft - Closure self reference

2020-11-20 Thread David Rodrigues
> Is it `returnType as $thing` ? That doesn't read well, but I don't see us making return type movable. as/use should be placable in either order, but maybe we give them required order anyway? I don't know if that would be a problem, because today we can have it "function(): Type use($x)", so "T

Re: [PHP-DEV] [RFC] Draft - Closure self reference

2020-11-20 Thread Larry Garfield
On Fri, Nov 20, 2020, at 10:01 AM, David Rodrigues wrote: > > Is it `returnType as $thing` ? That doesn't read well, but I don't see >> us making return type movable. as/use should be placable in either order, >> but maybe we give them required order anyway? > > I don't know if that would be a p

Re: [PHP-DEV] [RFC] Draft - Closure self reference

2020-11-20 Thread Sara Golemon
On Fri, Nov 20, 2020 at 11:40 AM Larry Garfield wrote: > > (5) function $lambda(... $args): returnType use ($captures...) {} > > > > To be honest, as I typed what came to mind, I ended up preferring this > last > > option. > > I kind of like that option, too. Agreed that this has some attractiv

Re: [PHP-DEV] [RFC] Draft - Closure self reference

2020-11-20 Thread Guilliam Xavier
On Fri, Nov 20, 2020 at 5:02 PM David Rodrigues wrote: > > Is it `returnType as $thing` ? That doesn't read well, but I don't see > us making return type movable. as/use should be placable in either order, > but maybe we give them required order anyway? > > I don't know if that would be a probl

Re: [PHP-DEV] [RFC] Draft - Closure self reference

2020-11-20 Thread Sara Golemon
On Fri, Nov 20, 2020 at 12:58 PM Guilliam Xavier wrote: > > I don't know if that would be a problem, because today we can have it > > "function(): Type use($x)", so "Type use($x)"? > > > > No we can't, try it (Parse error). The correct order is > "function() use($x): Type". > > Ugh. That's ugly.

Re: [PHP-DEV] [RFC] Draft - Closure self reference

2020-11-20 Thread David Rodrigues
> No we can't, try it (Parse error). The correct order is > "function() use($x): Type". Oh! You are right! In this case, we still have the old idea: function() as $lambda use ($x): int {} > Ugh. That's ugly. I want to say we should fix it, but the horse has left the stables, so it's too late to