On Mon, Apr 20, 2020 at 4:18 AM Benjamin Eberlei <kont...@beberlei.de> wrote:
> I have opened the vote on the Attributes v2 RFC. The voting will be > open until two weeks from now, May 4th 2020, noon UTC. > > RFC: https://wiki.php.net/rfc/attributes_v2 It's unfortunate that the RFC doesn't more fully enumerate the advantages/disadvantages of the proposed syntax options. It only points out that the T_ATTRIBUTE `@:` syntax is shorter and more familiar, but claims that it has the downside of not permitting whitespace in attribute names (it's not clear this is really an advantage - just an opportunity for arguments about code style). But if you look at the pull request for the `@:` syntax [1], there is a much more complete comparison. For example, the `<<>>` syntax is more verbose, unfamiliar to most people, and even Hack seems to be moving away from it. Furthermore, because it reuses existing tokens with a different meaning, it results in expressions that can be very difficult to read. For example: ```php const Baz = 2; <<FooAttribute(2 * 3 + 3)>><<Bar(4 + 5 * 2)>> <<BarAttribute(2 * (3 + 3)>>Baz, (4 + 5) * 2)>> function foo() {} ``` If PHP gets generics in the future (hopefully it does), the syntax will likely get even more confusing (if not a lot of PHP developers use shift tokens, certainly a lot more will use generics). The `@:` syntax makes it much more obvious where separate attributes are being used vs. constant expressions containing a shift token: @:FooAttribute(2 * 3 + 3) @:Bar(4 + 5 * 2) @:BarAttribute(2 * (3 + 3)>>Baz, (4 + 5) * 2) function foo() {} ``` In addition, the `@:` syntax is less verbose, and much closer to the attribute syntax developers are familiar with using in PHPDoc comments, as well as the syntax with precedence in other languages such as Java and Python. The syntax choice is very important, the language will be stuck with it for a very long time! Best regards, Theodore [1]: https://github.com/kooldev/php-src/pull/2 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php