Re: [RFC] [Discussion] new MyClass()->method() without parentheses

From: Date: Thu, 09 May 2024 15:26:16 +0000
Subject: Re: [RFC] [Discussion] new MyClass()->method() without parentheses
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-123292@lists.php.net to get a copy of this message
@Lynn, @Alex, thank you for your comments. I have improved the "without constructor arguments' parentheses" part of the introduction section and started the voting. вт, 23 апр. 2024 г. в 16:55, Alexandru Pătrănescu <drealecs@gmail.com>: > > On Tue, Apr 23, 2024 at 3:31 PM Robert Landers <landers.robert@gmail.com> > wrote: > >> On Tue, Apr 23, 2024 at 11:10 AM Valentin Udaltsov >> <udaltsov.valentin@gmail.com> wrote: >> > >> > >> > Does anyone have additional feedback? I'd like to start voting on >> Thursday, April 25th. >> > I've also added a section on other syntax ideas that have been >> expressed on Twitter and in the PR: >> >> https://wiki.php.net/rfc/new_without_parentheses#other_syntax_ideas >> > -- >> > Valentin >> >> I suspect this will break (badly written) reflection in interesting ways: >> >> https://3v4l.org/mcSNH >> >> This basically breaks dereferencing order of operations and makes it >> inconsistent. >> > > Quote from RFC: > "RFC still does not allow to omit parentheses around the new expression > *without* constructor arguments' parentheses, because in some cases this > leads to an ambiguity" > > And actually it mentions a list in the RFC: > > // Instantiate and then access the instance or instantiate the result of the expression?new > MyClass::CONSTANT <http://www.php.net/constant>;new > MyClass::$staticProperty;new $myClass::CONSTANT > <http://www.php.net/constant>;new > $myClass::$staticProperty;new $myClass->property;new $myClass->method(); > > But actually from all of those, right now, only "new MyClass::CONSTANT > <http://www.php.net/constant>;" and "*new* > $myClass::CONSTANT > <http://www.php.net/constant>;" are not working, > while the other 4 are > working fine. > > So yeah, this needs clarification if they continue to work as they work > right now: > https://3v4l.org/PmCfR > > Thanks, > Alex > -- С уважением, Валентин

« previous php.internals (#123292) next »