Re: Re: [RFC] Attributes v2
| From: | Guilliam Xavier | Date: | Sat, 18 Apr 2020 16:43:38 +0000 |
| Subject: | Re: Re: [RFC] Attributes v2 | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-109702@lists.php.net to get a copy of this message | ||
On Fri, Apr 17, 2020 at 6:11 PM Theodore Brown <theodorejb@outlook.com> wrote:
>
> the RFC says that the alternate T_ATTRIBUTE
@: token has the
> downside "that it does not permit whitespace in attribute names to
> allow detecting the ending of the declaration." Can you provide an
> example of an attribute name containing whitespace that would be allowed
> with the shift left/right tokens but not with the attribute token?
From what I saw in the related PRs (esp.
https://github.com/beberlei/php-src/pull/2#issuecomment-609466083),
the main reason is that if @: were defined as a standalone token,
then the following sequence (with whitespace everywhere possible, like
in https://3v4l.org/NRYbp):
function ( @: A \ B $x )
would be ambiguous between two possible interpretations:
function ( @:A \B $x ) // A attribute, \B type declaration
function ( @:A\B $x ) // A\B attribute, untyped
equivalent to respectively:
function ( <<A>> \B $x )
function ( <<A\B>> $x )
which permit whitespace (unambiguous because delimited):
function ( << A >> \ B $x )
function ( << A \ B >> $x )
(although I've never seen code with spaces around namespace separators).
--
Guilliam Xavier