Re: [RFC] Shorter Attribute Syntax Change RFC 0.2
| From: | Derick Rethans | Date: | Mon, 10 Aug 2020 08:35:14 +0000 |
| Subject: | Re: [RFC] Shorter Attribute Syntax Change RFC 0.2 | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-111415@lists.php.net to get a copy of this message | ||
On Fri, 7 Aug 2020, Theodore Brown wrote:
> On Fri, Aug 7, 2020 at 6:03 AM Derick Rethans <derick@php.net> wrote:
>
> > On Fri, 7 Aug 2020, Theodore Brown wrote:
> >
> > > Even if we assume the implementation is only about 30 lines, it's
> > > still extra complexity that I don't understand the benefit of. I
> > > sincerely would like to know what advantage there is of grouped
> > > attributes over the
@@ syntax.
> >
> > It was very *specifically* voted for:
> >
> > https://wiki.php.net/rfc/attribute_amendments#group_statement_for_attributes
>
> It was specifically voted for the <<>> syntax, with
> the explicit
> qualification that "This feature would be superseded by any other RFC
> getting accepted that changes the syntax." This is exactly what
> happened when the Shorter Attribute Syntax RFC was accepted.
But there wasn't a *specific* vote to remove that, like there was one to
enable it.
> > You still haven't addressed any of the deficiencies that the other
> > alternatives don't have:
> >
> > https://wiki.php.net/rfc/shorter_attribute_syntax_change#proposal
>
> I'm not sure which deficiencies you mean, but let's briefly go
> through the table in the RFC to make sure nothing has been missed:
>
> - Number of required Characters:
> - @@ has the advantage here.
But @@ takes up 94 pixels, whereas #[] only takes up 77 (and @[] 83), so
clearly better.
> - Has End Delimiter:
> - This isn't clearly a pro or a con in itself.
But you haven't said why it is better that *not having it* is better.
> - Allows Grouping:
> - As discussed before, @@ has the advantage of being
> equally
> concise without this added complexity.
I have no idea what that means.
> - Forward Compatibility in PHP 7:
> - This is at best a temporary benefit of #[] which will be
> irrelevant in a few years, at worst a source of confusion and bugs
> when code intended for PHP 8 runs on PHP 7 with different results.
But it helps now, maybe only a little, but it does.
> - Breaks BC of valid PHP 7 code:
> - All syntaxes but <<>> technically have a BC
> break. There really
> should be a separate line in the table for "Breaks useful syntax",
> since #[] and @[] have this
> deficiency, but @@ does not.
@[] and #[] don't break "useful syntax" either.
>
> - Used by other language:
> - This is listed as an advantage for #[] and
> <<>>. However, the table
> fails to point out that Hack is migrating away from
> <<>> to @Attr.
It can only do that because they are removing @ as the shut up operator,
which ain't going to happen in PHP.
> Furthermore, while #[] has the same start/end symbols as
> Rust, the rest
> of the grammar/semantics vary significantly. E.g. these are valid Rust
> attributes (see https://doc.rust-lang.org/reference/attributes.htmlõ¶<à(jÚ
> ÙùåOxòÑ):
I've never said that it has the same semantics, only that the syntax is
familiar. It still stands that nothing uses @@.
> - Familiar with Docblock Usage:
> - @@ has the advantage here once more.
@@ isn't used in docblocks.
> - Tokens used:
> - This isn't clearly a pro or con in itself.
[citation required]
> - Changes the lexing of **remaining** tokens:
> - This is apparently a con for #[].
That's why there is @[] now, which is a compromise, something that you
don't seem to be interested in caring about.
cheers,
Derick
--
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