Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111157 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 60651 invoked from network); 23 Jul 2020 17:41:39 -0000 Received: from unknown (HELO localhost.localdomain) (76.75.200.58) by pb1.pair.com with SMTP; 23 Jul 2020 17:41:39 -0000 To: internals@lists.php.net References: Date: Thu, 23 Jul 2020 17:36:22 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Posted-By: 87.81.129.66 Subject: Re: The @@ is terrible, are we sure we're OK with it? From: marandall@php.net (Mark Randall) Message-ID: 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