On 14 April 2023 05:35:39 BST, "Michał Marcin Brzuchalski"
wrote:
>Have you thought about not populating property by default but instead:
>* adding "use" language construct as default to all methods?
>* adding ability to assign variable values from "use" to property if needed?
>
>Like desugar to
Em qui., 13 de abr. de 2023 às 09:40, Nicolas Grekas <
nicolas.grekas+...@gmail.com> escreveu:
>
> I created this draft RFC to help move things forward:
>
> https://wiki.php.net/rfc/syntax-to-capture-variables-when-declaring-anonymous-classes
>
> Please let me know your early thoughts and I'd be h
Hi Nicolas,
czw., 13 kwi 2023 o 14:40 Nicolas Grekas
napisał(a):
> Hi Rowan, hi all!
>
> Le ven. 17 mars 2023 à 15:51, Larry Garfield a
> écrit :
>
> > On Thu, Mar 16, 2023, at 6:05 PM, Rowan Tommins wrote:
> > > On 16/03/2023 22:14, Larry Garfield wrote:
> > >> Wouldn't the functionality descr
On Thu, 13 Apr 2023 at 13:40, Nicolas Grekas
wrote:
>
> I created this draft RFC to help move things forward:
>
> https://wiki.php.net/rfc/syntax-to-capture-variables-when-declaring-anonymous-classes
>
> Please let me know your early thoughts and I'd be happy to move it to
> "under discussion".
>
Hi Rowan, hi all!
Le ven. 17 mars 2023 à 15:51, Larry Garfield a
écrit :
> On Thu, Mar 16, 2023, at 6:05 PM, Rowan Tommins wrote:
> > 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 c
On Thu, Mar 16, 2023, at 6:05 PM, Rowan Tommins wrote:
> 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 straightforwa
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, $
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,
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
> > 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
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;
> }
> }
>
>
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
On Tue, Mar 14, 2023, at 10:28 PM, Alexandru Pătrănescu wrote:
> On Wed, Mar 15, 2023 at 1:09 AM Rowan Tommins
> wrote:
>
>> On 14/03/2023 22:54, Larry Garfield wrote:
>>
>> Well, a large part of my resistance to automatic capture is that it
>> makes variable scope less visible at a glance. This a
On Wed, Mar 15, 2023 at 8:38 AM Rowan Tommins wrote:
>
> On 15 March 2023 03:28:39 GMT, "Alexandru Pătrănescu"
> wrote:
>
> >How about first implementing use() for anonymous classes first?
> >Something like:
> >
> >function foo(int $outer) {
> > return new class() use($outer) {
> > p
On 15 March 2023 03:28:39 GMT, "Alexandru Pătrănescu"
wrote:
>How about first implementing use() for anonymous classes first?
>Something like:
>
>function foo(int $outer) {
> return new class() use($outer) {
> public function getIt() {
> return $outer;
> }
> }
On Wed, Mar 15, 2023 at 1:09 AM Rowan Tommins
wrote:
> On 14/03/2023 22:54, Larry Garfield wrote:
>
> Well, a large part of my resistance to automatic capture is that it
> makes variable scope less visible at a glance. This avoids that by still
> having a marker for "I am from another scope", but
On Tue, Mar 14, 2023 at 7:09 PM Rowan Tommins wrote:
> Outside of
> those cases, though, there's no reason it should mean anything, just as
> $this->foo or self::$foo doesn't mean anything outside a class. In fact,
> it could be spelled capture::$foo or $scope->foo rather than just using
> new pun
On 14/03/2023 22:54, Larry Garfield wrote:
However, I agree with Ilija that the original proposal to just do it
automatically would be better; and if that didn't pass, I have no expectation
that an alternate with a funky new syntax would do any better.
Well, a large part of my resistance to
> I guess you'd have to generate a new class entry every time the "new
> class" line was run, and inject the extra values into that.
>
>
> If it was limited to capturing scalars and arrays, you could treat it as
> a kind of macro expansion, i.e. this ...
>
> $example = new class {
> public $in
On Tue, Mar 14, 2023, at 3:41 PM, Rowan Tommins wrote:
> Hi all,
>
> 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" - i
On 14/03/2023 21:23, Ilija Tovilo wrote:
One thing to note is that, as I've learned recently, anonymous classes
can actually be instantiated at a later point with some tricks.
https://3v4l.org/2OcmP
Huh, that's freaky... I guess this is all a reminder that these really
are anonymous *classes
Hey Rowan
On Tue, Mar 14, 2023 at 9:41 PM Rowan Tommins wrote:
>
> Hi all,
>
> 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
> vari
Hi all,
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
like the
23 matches
Mail list logo