Re: [RFC] Shorter Attribute Syntax Change RFC 0.2
| From: | Benjamin Eberlei | Date: | Tue, 04 Aug 2020 14:28:48 +0000 |
| Subject: | Re: [RFC] Shorter Attribute Syntax Change RFC 0.2 | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-111320@lists.php.net to get a copy of this message | ||
On Tue, Aug 4, 2020 at 4:19 PM David Rodrigues <david.proweb@gmail.com>
wrote:
> Suggestions:
>
> $(Attribute()) (available)
> $[Attribute()] (available)
> <<Attribute(1 \>> 2)>> (like strings escapes)
>
I had someone else suggest $[] to me today as well, funny coincidence :-)
Can you take the "@@ to @[] pull" request as a starting point to try if
this works with a patch?
https://github.com/php/php-src/pull/5928
This syntax is "not" familiar with docblock usage of @, as it doesn't
contain a @ :-D
It does pose difficulty for static analyers and userland parsers, because
they see the $ as a T_VARIABLE
in PHP 7.
> About $() syntax:
>
> - Number of required characters: (2+1)
> - Has end delimiter: yes
> - Allow grouping: yes
> - Forward compatibility in PHP 7: yes
> - Breaks BC of valid PHP 7 codes: no
> - Used by other languages: no?
> - Familiar with Docblock Usage: I don't know
> - Difficulties with Userland Parsers: I don't know
>
> And my another suggestion is use a more verbose for now, until we have a
> good consensus about it "using attribute()":
>
>
> - Number of required characters: (16+1)
>
>
> - Has end delimiter: yes
>
>
> - Allow grouping: yes
>
>
> - Forward compatibility in PHP 7: yes
>
>
> - Breaks BC of valid PHP 7 codes: no
>
>
> - Used by other languages: no?
>
>
> - Familiar with Docblock Usage: I don't know
>
>
> - Difficulties with Userland Parsers: I don't know
>
>
This would definitely need a fully working patch to be a contender in the
vote.
- It's not forward compatibltle with PHP 7, because use of the syntax
would lead to a fatal error on PHP 7 parsers or am I seeing something
wrong?
- its not a familiar syntax for PHP developers used to @ in docblocks
>
> Atenciosamente,
> David Rodrigues
>
>
> Em ter., 4 de ago. de 2020 às 11:03, Benjamin Eberlei <kontakt@beberlei.de>
> escreveu:
>
>> On Tue, Aug 4, 2020 at 3:46 PM Derick Rethans <derick@php.net> wrote:
>>
>> > Hi,
>> >
>> > Out of Banjamin's suggestion[1], I've updated the Shorter Attribute
>> > Syntax Change RFC to reflect that process:
>> >
>> > ç_ú_ZhlFÕè•*8Ï
>> > https://wiki.php.net/rfc/shorter_attribute_syntax_change
>> >
>> > Patches and comments welcome.
>> >
>> > FWIW, this has an excemption from the RM Sara as per [2]:
>> >
>> > > * Shorter Attribute Syntax Change
>> > > - Joe/Derick - Please make sure this RFC moves along and reaches
>> > > conclusion by beta3, as discussed previously.
>> >
>>
>> In combination to the existing proposals we already voted one, this RFC
>> includes a fourth option that has not been discussed before,
>> and could be the compromise we are all looking for :-)
>>
>> @[Attr] combines both the with to use the familiar @ of many, and the wish
>> to have a closing symbol/termination symbol that many others have.
>>
>> It does not have the downsides that Tyson found w.r.t. to #[Attr] being
>> interpreted as comment on PHP 7, but that also means its not forward
>> compatible like #[Attr] is.
>>
>> It provides a small BC break where code written as @[$foo, $bar] = baz();
>> or $foo = @["bar" => $baz]; will not compile on PHP 8 anymore, but that
>> can
>> be easily
>> fixed by writing it with a space between @ and [.
>>
>>
>> >
>> > cheers,
>> > Derick
>> >
>> > [1] https://externals.io/message/111218#111261
>> > [2] https://externals.io/message/111286#111286
>> >
>> > --
>> > PHP 7.4 Release Manager
>> > Host of PHP Internals News: https://phpinternals.news
>> > Like Xdebug? Consider supporting me:
>> > https://xdebug.org/support
>> > https://derickrethans.nl |
>> > https://xdebug.org | https://dram.io
>> > twitter: @derickr and @xdebug
>> >
>> > --
>> > PHP Internals - PHP Runtime Development Mailing List
>> > To unsubscribe, visit: https://www.php.net/unsub.php
>> >
>> >
>>
>