Re: [RFC] Shorter attribute syntax

From: Date: Thu, 04 Jun 2020 10:37:10 +0000
Subject: Re: [RFC] Shorter attribute syntax
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-110362@lists.php.net to get a copy of this message
> > Does the PHP parser prevent us from adopting #[attr]? I presume C#'s [attr] > > syntax and C++'s [[attr]] are impossible due to PHP's short array syntax. > > yes, that would create ambiguity in the parser since # (just > like //) > is for comments. I've mentioned this off-list before. If we consider @@ with a BC break we could also consider #[] by making #[ a symbol. This is also a breaking change but a probably similarly small one. It would break code like this: # Comments still work #[ <-- But they can't start with #[ To me both of those look acceptable but #[ looks nicer (but that's just my personal preference). Ilija

« previous php.internals (#110362) next »