On Fri, Apr 17, 2020 at 6:11 PM Theodore Brown <theodor...@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

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to