Re: [VOTE] Shorter Attribute Syntax Change

From: Date: Wed, 12 Aug 2020 19:43:40 +0000
Subject: Re: [VOTE] Shorter Attribute Syntax Change
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-111498@lists.php.net to get a copy of this message
On Wed, Aug 12, 2020 at 9:08 PM Rowan Tommins <rowan.collins@gmail.com> wrote: > > On 12 August 2020 19:03:02 BST, Jakob Givoni <jakob@givoni.dk> wrote: > >> > Is > >> > > >> > <?php @[Bar()]; ?> > >> > > >> > on it's own an error? > >> > >> Yes. Basically this is an example of valid code in PHP 7 that will > >> break if @[] is adopted. > > > >Wow, that was unexpected. By what logic? > >Also, how long must I wait before I can put a semicolon after the new > >attribute syntax? Is one whitespace enough or do I have to go to a new > >line? > >To me, suddenly disallowing semicolons at some points between > >statements or between a "declaration" and a statement seems to break > >PHP logic. > > > It's not that the semicolon is forbidden as such, it's that the code is interpreted > completely differently. > > Imagine if we had no "private" keyword, and then added it; this would previously have > been valid (a statement followed by a declaration): > > private; function foo () {} Ok, that's starting to make sense. Having seen so many attribute examples lately I started to get the impression that you could basically insert them anywhere (like comments) - even if it didn't technically make any sense... Reading the original RFC again I understand that an attribute MUST be directly followed by a function, class, interface, traits, class constant, class property, class method, function/method parameter, a docblock or another attribute. I hope I didn't forget anything... Sorry, I'm just a sucker for details and accuracy :-) Thanks, Jakob

« previous php.internals (#111498) next »