Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111225 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 1468 invoked from network); 28 Jul 2020 19:01:38 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 28 Jul 2020 19:01:38 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9568A1804E6 for ; Tue, 28 Jul 2020 10:57:36 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10olkn2041.outbound.protection.outlook.com [40.92.40.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 28 Jul 2020 10:57:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E8GmEEyMCMQtjtsHcwzzLfwAJCW0C0KLT/1Q4YfoIc5wW5AskKwub6o02FG6RTTvscBpqj4QSImL3DWIVNbSDug58eStmoDV6xXrcchxvFQdhdX8ZnDWm84flswYO33dvYNmc5+fvzhfPVM+w0SFY4LzyhIbe5uRfIeXGWeX6vWlaZ2PFyLxIasbekzSNLwHuo+FfSSXntZCAybbsoQndtLUCsvPCZFxyVAtUaFtvMpJHmYmYsLwt2qrA9uvurkn0qAGVSmnsqdotrffKCyDWNVVUiyHMPwpTu6r2n1DCPDfofSyxPQ83NxYogoPEYyTBvzK6XX5LI/1Bmf+Rg2m2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=f0HJe21B0j1xoKgAabOGkU/wi9XxlcbesOw2nPGKNDk=; b=TxMIQMEYl3t9vRCxc42bMEbiCLzkZnd+kYr9Y0qd5c7r8lotVpZNlHCGRJurvONNPco+s3EPDD87N5W6uo7O6XmoCFFklSE6Ked/yhXlKkr3tcznpYkaiADeG9YKhCVwPEn0BbKLv4bQqVsG+pAbSAVN3SOTvtokqbou8r5E8x1LwB5T/StlFU3VbOZnGiyMtIQCJfyry/EucvyCdIx67Zee//dbh6es8DOaoV/2Sh7FL8VrNIC31R5LC2U9N8pLt2Fj6tb86591hLAqpSS58pcKK62HKqfhQA7CsOtSBYgTqYiMF/gPRPjBesn9/CUe92t6SXYAo0z0wsvFbB7afw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=f0HJe21B0j1xoKgAabOGkU/wi9XxlcbesOw2nPGKNDk=; b=K6uESJ8s4S+T8MSLYtzaJp92/fbQ1ABiu+Q0hFaSv3aGMiSKPIV+hQ8gyQHLP8AqE16xUppVnzXfWas0vslqNOizBsbQh3Ejs4NEjiBhhZZjM3ZcNe42SVt+eJ/aD68YoyjHNlpESB/ObFry+LgZd5RpeEJ4NcdHg4AW3rXHFDeotTMCruG2u/kHONn+OiXEiavFmZkeTV5er7fOuAO8k5G3TODEKkkV6+Ft6oaOjLf54yw/RoLbXAEo2dO2WcjfaqvX0Z6eSfHF90LcaEGoJEVlvOip9HPtB218PRc6Ty+xhK7ZAeAB0Ex77PeSNPOmKedHi2ynZWKzsNJ2q6JDXg== Received: from BN7NAM10FT005.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::43) by BN7NAM10HT036.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.10; Tue, 28 Jul 2020 17:57:34 +0000 Received: from BYAPR05MB6535.namprd05.prod.outlook.com (2a01:111:e400:7e8f::43) by BN7NAM10FT005.mail.protection.outlook.com (2a01:111:e400:7e8f::430) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.10 via Frontend Transport; Tue, 28 Jul 2020 17:57:34 +0000 Received: from BYAPR05MB6535.namprd05.prod.outlook.com ([fe80::fc6c:38b0:fa18:f355]) by BYAPR05MB6535.namprd05.prod.outlook.com ([fe80::fc6c:38b0:fa18:f355%7]) with mapi id 15.20.3239.016; Tue, 28 Jul 2020 17:57:34 +0000 To: Joe Ferguson , PHP Developers Mailing List Thread-Topic: [PHP-DEV] [RFC] [Discussion] Shorter Attribute Syntax Change Thread-Index: AQHWZO4EZIMJMorBK0qxy5SLq6JXCakdN4bO Date: Tue, 28 Jul 2020 17:57:34 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:65134022025D5815E7618F1FA54D5E49329D62076B3F6DA52319BB4BCD865E52;UpperCasedChecksum:84A7E3E34079E0C10CF2F4D0F4706FB159C3268680C327DB623FDCB5BB435461;SizeAsReceived:6936;Count:44 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [FVAvWWWN0T8N0XOggUhMmgrCAjY9cCl/] x-ms-publictraffictype: Email x-incomingheadercount: 44 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: dd0f4ea4-31b4-44a4-a0b4-08d8331fb4eb x-ms-traffictypediagnostic: BN7NAM10HT036: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: tEUDY0ReQqkzew/W9OORmPyir/f/VONYx6w6La8QzW4fXtDF46y8Asj1L7O/v5EZ72ROVTwJPkvsXK32uleduHJpiSaLlW/+Ek6J8ZzzNfz3AK8b3PKSgl9u1kTFjGkoKORHFhSHq4YUtC0Hd6oXWfm156FWFPQGfHg5/Jpq5wveZ6crc2ZLGif1QBtQWm59SY2MrzRk2CWB9eoGANe2gEtXHZgitPLoN98pYxvw4s2A9aVR7PXKfqirnyFMRzGz x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:0;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR05MB6535.namprd05.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:;DIR:OUT;SFP:1901; x-ms-exchange-antispam-messagedata: yQT7WI9nBEB3hNsbmSqTC3XkHxKfPFiCxz/Kg3VgiJdwzopX87rbJSoqRorZxUhWzcnJcNURpCf5yHNUJZQ6lflRdwWIoEMVKZ0q4FU6C+9H1+SGJZyLQ0d8oWf7VquBKhV3j3ZX3QwJxgC6e6NaoA== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-AuthSource: BN7NAM10FT005.eop-nam10.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: dd0f4ea4-31b4-44a4-a0b4-08d8331fb4eb X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Jul 2020 17:57:34.4729 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7NAM10HT036 Subject: Re: [PHP-DEV] [RFC] [Discussion] Shorter Attribute Syntax Change From: theodorejb@outlook.com (Theodore Brown) On Tue, July 28, 2020 at 9:46 AM Joe Ferguson wrote:= =0A= =0A= > Hello Internals,=0A= > =0A= > I've been working with Derick Rethans and others (thanks all!) on a Short= er=0A= > Attribute Syntax Change RFC which outlines reasons why the "#[]" syntax= =0A= > would be preferred over the currently agreed upon "@@" syntax for Shorter= =0A= > Attribute Syntax.=0A= > =0A= > An important part of the research that went into this proposal demonstrat= es=0A= > how "@@" will make handling attributes more difficult for PHP_CodeSniffer= =0A= > (and similar tools) and shows how the alternative "#[]" syntax is more=0A= > friendly for these tools.=0A= > =0A= > You can find the RFC=0A= > https://wiki.php.net/rfc/shorter_attribute_syntax_change and I'm happy to= =0A= > answer any questions as best I can.=0A= =0A= Hi Joe,=0A= =0A= From the perspective of looks alone I don't care much one way or the=0A= other between @@ and #[]. However, I don't find the arguments for #[]=0A= in this RFC very compelling, and it ignores some of the other downsides=0A= of #[] compared to @@ that should be highlighted. Let's go through the=0A= arguments from the RFC:=0A= =0A= > It [@@] currently causes a parser conflict=0A= =0A= This isn't true now that namespaced names are treated as tokens. The=0A= @@ implementation has been merged into php-src and there is no parser=0A= conflict.=0A= =0A= > Various luminaires [sic] consider @@ a joke=0A= =0A= Who does this refer to? A random Reddit user?=0A= =0A= > Feedback to Derick's tweet (https://twitter.com/derickr/status/1285912223= 639130114)=0A= > were [sic] overwhelmingly positive=0A= =0A= Are you sure? I took a look at the thread and it seems like the=0A= responses were pretty mixed. Some people expressed support for #[],=0A= but almost as many were happier with the @@ syntax. If anything the=0A= majority of responses were neutral or expressing dislike for all the=0A= syntax options.=0A= =0A= > It has the distinct possibility to cause further parsing issues=0A= =0A= Like what? How is it any more likely to cause parsing issues than the=0A= @ syntax used by the majority of other C family languages?=0A= =0A= > Having a closing ] makes it easier to extend Attributes with more syntax= =0A= =0A= This might be a good argument if there were actually a need to extend=0A= attributes with more syntax. What other languages have found a need for=0A= this? Even Rust doesn't allow additional syntax inside the brackets.=0A= =0A= > There is no =93end symbol=94 to make finding occurrences easier,=0A= > including by reading or using regular expressions.=0A= =0A= Can you provide an example? When reading code I personally don't find=0A= the ending bracket very helpful - my brain tends to parse it as the=0A= end of an array, not the end of an attribute. Even when using a regex=0A= to search code, the ending bracket doesn't seem very helpful since=0A= arrays can also be passed as attribute arguments. For example, to=0A= match this attribute the regex for @@ is actually simpler than the=0A= one for #[]:=0A= =0A= ```php=0A= # regex: /@@\w+\(.+\)/=0A= @@Attr([1, 2])=0A= =0A= # vs.=0A= =0A= # regex: /#\[\w+\(.+\)\]/=0A= #[Attr([1, 2])]=0A= ```=0A= =0A= > A syntax with a closing demarcation is much easier to back fill with=0A= > tools such as PHPCS.=0A= =0A= I'm not sure I understand this. What does it mean to "back fill" a=0A= syntax with PHPCS, and what does a closing demarcation have to do with=0A= it? As a user, I'd expect to have to update PHPCS to work with PHP 8=0A= code - doesn't it have to be updated anyway to correctly support the=0A= syntax for named arguments, union types, the nullsafe operator, match=0A= expression, etc.?=0A= =0A= And from a perspective of compatibility with existing tools, couldn't=0A= @@ be considered superior since people can use it in code examples=0A= on a blog without the syntax highlighter treating it as a comment?=0A= =0A= > It is a syntax no other language uses.=0A= =0A= Rust chose to use #[] even though it wasn't used by any other language.=0A= Does that make it a bad fit for Rust? No. But just because Rust uses=0A= a syntax also doesn't mean it's a good fit for PHP.=0A= =0A= @@ fits well with PHP since there is virtually no BC break, and the=0A= syntax is close to the @annotation syntax currently used in docblocks,=0A= so it's easily recognizable for what it is. On the other hand, #[]=0A= would be a larger BC break and can easily be confused for a comment.=0A= =0A= Best regards,=0A= Theodore=