Re: [VOTE] Shorter Attribute Syntax Change
| From: | Theodore Brown | Date: | Tue, 11 Aug 2020 16:54:28 +0000 |
| Subject: | Re: [VOTE] Shorter Attribute Syntax Change | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-111481@lists.php.net to get a copy of this message | ||
On Tue, Aug 11, 2020 at 11:36 AM Rowan Tommins <rowan.collins@gmail.com> wrote:
> On Tue, 11 Aug 2020 at 17:07, Theodore Brown <theodorejb@outlook.com> wrote:
>
> > > > fact that the @@ syntax makes attributes easier to grep for.
> >
> > This can be a simple Yes or No. With @@ or @: you can type those
> > symbols followed by the attribute name to grep for it. With the other
> > syntaxes and attribute grouping, if the name isn't unique it may be
> > difficult to search for since you can't rely on a unique leading symbol..
>
> Surely *all* of the syntaxes will be easily greppable once adopted, because
> any instances that aren't attributes will have to be fixed (other than
> those in comments and strings, which can happen with any of them).
I think you may have misunderstood my point - it's not so much about
the leading symbols but about grouping. Consider the following example:
@[
Jit,
Route("/api/posts/{id}", methods: ["GET", "HEAD"]),
]
public function show(int $id) { ... }
What will you grep for if you want to find all places where the Route attribute is used (but not
some other class named Route)?
With the @@ syntax you can easily grep for "@@Route" to find all the
places where specifically the attribute is used:
@@Jit
@@Route("/api/posts/{id}", methods: ["GET", "HEAD"])
public function show(int $id) { ... }
Best regards,
Theodore