Re: The @@ is terrible, are we sure we're OK with it?
| From: | Mark Randall | Date: | Thu, 23 Jul 2020 16:36:22 +0000 |
| Subject: | Re: The @@ is terrible, are we sure we're OK with it? | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-111157@lists.php.net to get a copy of this message | ||
On 22/07/2020 13:00, Derick Rethans wrote:
- There are lots of grumbles, both on here, room 11, as well as in the wider community (https://www.reddit.com/r/PHP/comments/hjpu79/it_is/)From discussions in R11 I want to offer the following example of why either option with a closing tag is preferable to allow maximum flexibility in future development. Assume we want to extend attributes to include something a lot of PHP features have, an access scope, to only allow accessing annotations from within the class itself, or a descendant. Then we end up with something like : class Foo { @@protected Attr protected int $bar; } Contrast that to something with opening and closing tags where they are clearly grouped: class Foo { #[protected Attr] protected int $bar; } What other syntax might we want to add? Perhaps we want to add a way to enforce validation at encounter time with a "checked" keyword. @@checked protected Attr(1,2,3) protected int $bar #[checked protected Attr(1,2,3)] protected int $bar It's much less ambiguous what belongs to what. Now we could dig ourselves out of this hole using additional tokens around @@ such as @@(checked protected Attr) but at which point why not just use a mechanism that supports it out of the box? Mark Randall