Re: [PHP-DEV] First-class callable partial application

2023-03-16 Thread Stephen Reay
> On 17 Mar 2023, at 05:33, Larry Garfield wrote: > > On Thu, Mar 16, 2023, at 4:14 AM, Rowan Tommins wrote: >>> On 15/03/2023 21:12, Dan Ackroyd wrote: >>> Would it be desirable to split those two things into two separate >>> RFCs, by having the first RFC not have native syntax support, but >

Re: [PHP-DEV] Brainstorming idea: inline syntax for lexical (captured) variables

2023-03-16 Thread Rowan Tommins
On 16/03/2023 22:14, Larry Garfield wrote: Wouldn't the functionality described boil down to essentially just materializing into a few extra lines in the constructor? At least to my ignorant non-engine brain it seems straightforward to have this: $a = 1; $b = 2; $c = 3; $o = new class ($a, $

Re: [PHP-DEV] First-class callable partial application

2023-03-16 Thread Larry Garfield
On Thu, Mar 16, 2023, at 4:14 AM, Rowan Tommins wrote: > On 15/03/2023 21:12, Dan Ackroyd wrote: >> Would it be desirable to split those two things into two separate >> RFCs, by having the first RFC not have native syntax support, but >> instead another static method on Closure? e.g. something like

Re: [PHP-DEV] Brainstorming idea: inline syntax for lexical (captured) variables

2023-03-16 Thread Larry Garfield
On Thu, Mar 16, 2023, at 5:06 PM, Rowan Tommins wrote: > On 16/03/2023 17:59, Nicolas Grekas wrote: >> We could define the "use" as declaring + setting the properties before >> the constructor is called, if any. >> But I'm also fine making both constructs conflict: when there is a >> constructor,

Re: [PHP-DEV] Brainstorming idea: inline syntax for lexical (captured) variables

2023-03-16 Thread Rowan Tommins
On 16/03/2023 17:59, Nicolas Grekas wrote: We could define the "use" as declaring + setting the properties before the constructor is called, if any. But I'm also fine making both constructs conflict: when there is a constructor, the boilerplate saved by the "use" becomes really low. No strong o

Re: [PHP-DEV] Brainstorming idea: inline syntax for lexical (captured) variables

2023-03-16 Thread Nicolas Grekas
> > To overcome the issues spotted in the thread, what about doing some sort > > of CPP instead of autocapture? > > > > new class (...$arguments) use ($outer) extends Foo { > > public function getIt() { > > return $this->outer; > > } > > } > > > > This would be the equivalent of thi

Re: [PHP-DEV] Can we get compile time routines?

2023-03-16 Thread Larry Garfield
On Thu, Mar 16, 2023, at 9:40 AM, Hans Henrik Bergan wrote: > Something like > ``` > $data = compile_time_routine(function() { > return json_decode(file_get_contents("large.json"), true); > }); > ``` > being equivalent at runtime to > ``` > $data = array(...whatever json_decode returned...); >

[PHP-DEV] Can we get compile time routines?

2023-03-16 Thread Hans Henrik Bergan
Something like ``` $data = compile_time_routine(function() { return json_decode(file_get_contents("large.json"), true); }); ``` being equivalent at runtime to ``` $data = array(...whatever json_decode returned...); ``` and ``` echo "opcache compiled at " . compile_time_routine(function(){return

[PHP-DEV] PHP 8.2.4 Released

2023-03-16 Thread Sergey Panteleev
The PHP development team announces the immediate availability of PHP 8.2.4. This is a bugfix release. All PHP 8.2 users are encouraged to upgrade to this version. For source downloads of PHP 8.2.4 please visit our downloads page. Windows binaries can be found on the PHP for Windows site. The list

[PHP-DEV] PHP 8.1.17 Released

2023-03-16 Thread Patrick ALLAERT
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 The PHP development team announces the immediate availability of PHP 8.1.17. This is a bugfix release. All PHP 8.1 users are encouraged to upgrade to this version. For source downloads of PHP 8.1.17 please visit our downloads page. Windows binaries

Re: [PHP-DEV] [RFC][Vote announcement] Arbitrary static variable initializers

2023-03-16 Thread Ilija Tovilo
Hi Alexandru >> https://wiki.php.net/rfc/arbitrary_static_variable_initializers >> https://externals.io/message/118976 >> >> There haven't been many responses, so I'd like to put this to a vote >> early next week. >> > Only a small thing in the example for > "ReflectionFunction::getStaticVariable

Re: [PHP-DEV] [RFC][Vote announcement] Arbitrary static variable initializers

2023-03-16 Thread Ilija Tovilo
Hi Tim > Using Alain's example of static variables that depend on each other. For > the following: > > function foo() { >static $a = 0; >static $b = $a + 1; > } > > The value of '$a' is known at compile time. Is the value of '$b' also > known at compile time? It might make sense to include

Re: [PHP-DEV] First-class callable partial application

2023-03-16 Thread Robert Landers
On Thu, Mar 16, 2023 at 10:14 AM Rowan Tommins wrote: > > On 15/03/2023 21:12, Dan Ackroyd wrote: > > Would it be desirable to split those two things into two separate > > RFCs, by having the first RFC not have native syntax support, but > > instead another static method on Closure? e.g. something

Re: [PHP-DEV] Brainstorming idea: inline syntax for lexical (captured) variables

2023-03-16 Thread Rowan Tommins
On Thu, 16 Mar 2023 at 09:28, Nicolas Grekas wrote: > > To overcome the issues spotted in the thread, what about doing some sort > of CPP instead of autocapture? > > new class (...$arguments) use ($outer) extends Foo { > public function getIt() { > return $this->outer; > } > } > >

Re: [PHP-DEV] Brainstorming idea: inline syntax for lexical (captured) variables

2023-03-16 Thread Nicolas Grekas
Hi Rowan, I have been pondering for a while how to improve the anonymous class > syntax to allow "capturing" of values from the outer scope, and came up > with the idea of a special variable marker for "lexically captured > variable" - instead of $foo, you would write $!foo or $^foo (I quite > lik

Re: [PHP-DEV] First-class callable partial application

2023-03-16 Thread Rowan Tommins
On 15/03/2023 21:12, Dan Ackroyd wrote: Would it be desirable to split those two things into two separate RFCs, by having the first RFC not have native syntax support, but instead another static method on Closure? e.g. something like: Closure::partial($callable, array $position_params, array $na