On Thu, Aug 6, 2020 at 12:30 PM Benas IML <benas.molis....@gmail.com> wrote:
> Hey Theodore, > > On Thu, Aug 6, 2020, 8:05 PM Theodore Brown <theodor...@outlook.com> wrote: > > > While none of our syntax options are perfect, I believe @@ has the > > best long-term tradeoffs because: > > > > - It doesn't break useful syntax > > Fair enough. > > > - It is equally or more concise than grouped attributes without > > adding complexity to the parser/compiler > > Are we really going to debate that ~30 lines of code add complexity? Hi Benas, I don't know how many lines of code it will be, since an implementation for it has never been finished. The patch currently linked in the RFC does not implement it. 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 is equally or more verbose than `@@` in real-world use cases - Adding or removing a second attribute with grouping can require modifying multiple lines, adding unnecessary noise to diffs: @@SomeAttribute("value") @@AnotherAttribute("value") # can be added/removed independently function foo() {} # vs. @[SomeAttribute("value")] # changes to: @[ SomeAttribute("value"), AnotherAttribute("value"), # not added/removed independently ] function foo() {} - How much more added complexity will the grouped syntax require if we add nested attributes in the future? At the least it will have to be special-cased in some way, either to disallow grouping for nested attributes or to treat the grouped syntax the same as an array. `@@` avoids the need for additional complexity, special cased syntax, and having to modify extra lines when adding/removing separate attributes. > > - It is conceptually closest to the docblock syntax the PHP > > community is familiar with > > Well, if `@@` is similar to `@` (to me it isn't), we can say that > `@[]` is also similar to `@`. I would agree that `@[]` is more similar than `#[]` is. But arguably `@@` is still the closest since docblock annotations don't require being wrapped in array brackets. > > - It is aligned with the attribute semantics of the majority of C > > family languages > > In what way `#[]` or `@[]` aren't? The majority of C family languages use `@Attr` without an extra end symbol. This makes sense since attributes are simply metadata modifying the declaration that follows them, similar to visibility and type declarations. Best regards, Theodore -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php