Hello Derick & Internals,

I am a daily user of PHP and read through all the recent discussions about the
attribute syntax, and thought I could add some slightly different viewpoints
from an "end-user" who uses the current annotations a lot. This is my first time
posting, so I am hoping I am doing this the right way ;-)

Currently, I am favoring @@, although I don't have strong preferences to other
syntax if it is more useful in some way. Why I prefer @@:

1. The @ symbol is hardly used in PHP, except for error suppression and within
comments, so searching and scanning over code with @@ works well and does not
have much ambiguity. The syntax with [] (and a symbol) is very close to the PHP
syntax for arrays and destructuring, and would now have a different meaning in
addition to that. This is not the case for C/C++/C# as far as I can tell, as []
is rarely used in those languages so having [] for attributes there makes it
quite recognizable/unique.

2. A big argument about the ending delimiter is about consistency. Yet isn't an
attribute almost like the "new" keyword, which also only allows a class name and
then optionally some arguments passed to the constructor? It is not like you can
define anything but a class + arguments as an attribute, and "new" does not have
starting and ending delimiters.

3. What would starting and ending delimiters be used for except for grouping
attributes? I would be really interested in use cases, and if delimiters are
important, then a few real-world examples why they are important and how the
syntax will come in handy later would be the best argument for them. After using
the current annotations for years it has not occured to me that something is
fundamentally missing, and attributes have been used for many years as
annotations in PHP as well as in other languages, so there should be some
evidence/examples.

4. If at a later time grouping or more options become necessary, something like
@@{} could be an optional syntax. Using {} to optionally group something in PHP
has a lot of precendence, and if it is only optional, it seems like a reasonable
addition while still having the simple just-one-class-with-arguments attributes.

When looking at the new RFC, I feel like none of the syntax arguments in the RFC
are very self-explanatory or even would be a factor why I would prefer them or
not. A larger explanation about each syntax, some real code samples with each
syntax (possibly with colors) and longer pro/con arguments would be a lot better
for an informed decision, so if there is a lot of contention around the syntax,
I think more time to flesh out such an RFC and then do it for 8.1 would be
better. At the same time I do feel like @@ would be a good syntax, but if there
are open questions or more discussions to be had it might be better to have the
time for those compared to having hasty discussions now with a hasty vote where
everyone will be unhappy at the end.

Best regards,

Andreas

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

Reply via email to