Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110436 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 30361 invoked from network); 8 Jun 2020 21:57:28 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 8 Jun 2020 21:57:28 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3BF66180510 for ; Mon, 8 Jun 2020 13:40:59 -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-ASN: AS8075 40.80.0.0/12 X-Spam-Virus: No X-Envelope-From: Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11olkn2081.outbound.protection.outlook.com [40.92.18.81]) (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 ; Mon, 8 Jun 2020 13:40:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XHrPUAStjJeKZylKBAPHppYXDpmf5XcGPOKOxeF5O4hrbdcnrb1Bg6OkIYjU/zQrXhpeMTNfmVXp1Yo/cp94ZKZkKMWc9YGvAbgeHbk4/pGGbnHJRbutF54rBeFZgC6+c0ymfFb8BIbd9VZIJBOEa6abEhSCXaipUG/JnOdwVmE0eKIt8jhuY+kuKYYvwb6zB2dTFzYWZQykrXP0WF18bloRgLVxQ4RPoG0C3P6hFggTqcTqaLbtHkNXSZ114AlamR1+x3ViO8z5nwldNSBqXHHZQA/QgRApUhmwaP+86+2EO87dvlxxovb9wQW5+Ot26rdWdoVuoLgWnJGfiwVDEA== 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=LyCb7EzQF6E6+l+fyCXCiT3T5pT1y6Dp5VxDFPYs7yI=; b=H2nTfF/SzgWRq4WBJhWg8iQdFhMTKZc611X0OunuhrHOHtkl+bqd3i78+4uRidJ0geDZTnnz1fEFx7QxziV6C7nOTkjNS9px9fSfhPsFt4ApIhl7UwTBVv29AWmHLah1tGBqvnS2N7i9t+gzJ2OWIWHQ2zPXGGJkctxzGK0Qv+zj/7zuDCjL8OFooOe1/83ehjgCakubkgvl8GN0UZovzZ2K/otCWlFsIMY2X7fZMHYKgowG8WjTePhzEgY0BOn9eC5vyCXZRHslYYrc1q3XNZ5h8Fip6mO32B5Ik6Pgic7gNgVP8ILTGKlv33UWt6qN7V2sfZRTEBPg7eszk8Y/mg== 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=LyCb7EzQF6E6+l+fyCXCiT3T5pT1y6Dp5VxDFPYs7yI=; b=SzSXtcyW130xPALj/q5+r06xwmK2rFj24CK06G7HV8bK7X0Auyz525UbYaBeyF0Q8u2hfcHvwInVin/0JhY3RQzmsFFJIMjI4O/nH8pNYGwHWRpipBkPN75wWxKUpj4z2NeBE2tf/aexs8j6PDtDy1H7ROyd9qTXo8RmDVQOz36tUxYu5rOsi9Q0dd7ZnYdY83KhVMxSThqBS5dwt3sKhMZfAcKfTW25wQrWYMBIudroxypUCIOeVnzMyoW8RhUXtYIwosLY0l14M6BH65+DSnJnoAesq/wh+/T3idZ6YQLAXwsdnM+OyfplkVEdcWG/7gjfUg8I8JyUNbC8vG1FgA== Received: from DM6NAM11FT064.eop-nam11.prod.protection.outlook.com (2a01:111:e400:fc4d::53) by DM6NAM11HT020.eop-nam11.prod.protection.outlook.com (2a01:111:e400:fc4d::101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18; Mon, 8 Jun 2020 20:40:57 +0000 Received: from BYAPR05MB6535.namprd05.prod.outlook.com (2a01:111:e400:fc4d::47) by DM6NAM11FT064.mail.protection.outlook.com (2a01:111:e400:fc4d::234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18 via Frontend Transport; Mon, 8 Jun 2020 20:40:56 +0000 Received: from BYAPR05MB6535.namprd05.prod.outlook.com ([fe80::54e2:1eeb:fc5d:8c21]) by BYAPR05MB6535.namprd05.prod.outlook.com ([fe80::54e2:1eeb:fc5d:8c21%3]) with mapi id 15.20.3088.017; Mon, 8 Jun 2020 20:40:56 +0000 To: Larry Garfield , php internals Thread-Topic: [PHP-DEV] [RFC] Shorter attribute syntax Thread-Index: AQHWOgIv0rCwDWp4oECJgOMrWx9MxKjItJCAgABT1+2AAnlHgIAB4RWMgABgUwCAAE4Q4IAAxkKAgABeMFI= Date: Mon, 8 Jun 2020 20:40:56 +0000 Message-ID: References: <5ebecd58-9f39-72b9-369d-dbb60b80af36@gmail.com> , In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:F293AE5E3A51467C925D8EAD5888D66513C38150667AF588FDE2333F00A64CF9;UpperCasedChecksum:8FB67BEA6B864815D4C9BBBA45CE3B8AD2742E9C9C976F1ED01BE3D2914A748C;SizeAsReceived:7421;Count:44 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [VfyskEtzRZ5dA8JsKDxkcrvJqTwRAJA9] x-ms-publictraffictype: Email x-incomingheadercount: 44 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: f5b25a99-ffa5-4385-d328-08d80bec3eae x-ms-traffictypediagnostic: DM6NAM11HT020: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: +PdlkvaQ5FEzt6B2Mu3TBh8chFieV3TcwnJN84Ehy/WQaEK9tflDxZK6EQcGYE/EFWXZ0EX3vBo6BolOqnB0u1K0lILMA4AxpFJb/IZ72cZmsz0+UTmV75kSy96FjMru3Onr7lSDyrW0V71NG7h9tpWKeTPrAwlruBAuC+QQtr+Rr631qbrJ8tMk1ibFw44Z1Q4dGcSxihdGCxEDfpgdwHiiQiFQh+D/5AlSqvsPD3l+JgVE5u3Dzcmqo9mf3xIL 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: l5YQRR/DiOzDP5QdPK+EOh0HLhZhy8w9IeqUL/++QsxqGqvqWSWkKOYhf3SE+aq/awy8+4Uo5gLocLsMwGdzxvAJauaLm50SOIZ7U8bhCmztdT3xKhz+JHuSgOD4FOaeDiQs+cVcRw6MLRn0R3+0tg== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: f5b25a99-ffa5-4385-d328-08d80bec3eae X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Jun 2020 20:40:56.4247 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6NAM11HT020 Subject: Re: [PHP-DEV] [RFC] Shorter attribute syntax From: theodorejb@outlook.com (Theodore Brown) On Mon, June 8, 2020 at 10:01 AM Larry Garfield wr= ote:=0A= =0A= > FWIW, I find both alternatives ugly to my eye. So, there's that. =0A= >=0A= > Given that `@` is off the table for obvious reasons, my preference=0A= > would frankly be for Rust's `#[]`, which has the nice side effect=0A= > of being a normal comment in earlier PHP versions and so attributes=0A= > can be included as optional without breaking BC. I don't know if=0A= > that's a big deal or not, but it's a benefit. And it should be no=0A= > harder on the parser to differentiate than `@` vs `@@` is.=0A= >=0A= > (The only advantage of `@@` in my mind is another obvious Star Wars=0A= > joke.)=0A= =0A= Hi Larry,=0A= =0A= From the perspective of looks I don't have a strong preference=0A= between them. There are two main reasons I decided against borrowing=0A= the `#[]` syntax from Rust:=0A= =0A= 1. It's a much larger BC break. Disallowing comments from starting=0A= with a certain character could break a lot of code in the wild.=0A= From a quick search of grep.app, I found two examples on the first=0A= page of results using `#[` as a comment. [1] Is it worth breaking=0A= this code?=0A= =0A= 2. `#[]` is slightly more verbose, which works against one of the=0A= objectives of the RFC. Rust is the only language I found that uses=0A= three characters for its attribute syntax like this.=0A= =0A= I actually starting trying to draft an RFC which would propose the=0A= `#[]` syntax for attributes, but one thing I noticed while doing=0A= so is that (at least on my QWERTY keyboard) `#[` is noticeably=0A= harder to type - I kept typoing it as `#]` or `#\`. This is dependent=0A= on keyboard layout, of course, but being prone to accidental typos=0A= was also one of the arguments against the `@:` syntax in the original=0A= RFC.=0A= =0A= > Something that I don't think has been addressed explicitly in this=0A= > thread yet is single line vs separate line attributes. Vis:=0A= > =0A= > `<> class Blah {}`=0A= >=0A= > vs.=0A= >=0A= > ```php=0A= > <>=0A= > class Blah {}=0A= > ```=0A= >=0A= > Syntactically both are legal AFAIK; I don't know which most people =0A= > will do. The separate line version seems more likely, and cleaner =0A= > to me, but for parameters people may want to inline it in shorter =0A= > signatures. Or it may push people to always multi-line those=0A= > function definitions, for better or worse. (I find that quite ugly=0A= > myself, but I don't know if I'm in the majority on that view.)=0A= >=0A= > My gut feeling is that `@@` is notably worse inline. It subjectively=0A= > feels messier because there's no clear indication of where the end=0A= > is. On separate lines, `@@` and `<< >>` seem about equally ugly to me.=0A= =0A= Personally I have the opposite reaction when it comes to inline=0A= parameter attributes - the closing `>>` always looks like a shift=0A= operator at first glance which makes it harder for me to read. And=0A= for an inline function or class attribute the function/class keyword=0A= already provides a strong indication of where the attribute ends.=0A= =0A= But for anything other than very short attributes, I expect most=0A= people will want to put the attribute on a separate line for optimal=0A= readability, regardless of the final syntax:=0A= =0A= ```php=0A= function foo(=0A= <>=0A= < "val"])>>=0A= Type $myParam,=0A= bool $param2,=0A= ) {=0A= ...=0A= }=0A= =0A= // vs.=0A= =0A= function foo(=0A= @@ExampleAttribute("foo", "bar")=0A= @@OtherAttribute(123, ["key" =3D> "val"])=0A= Type $myParam,=0A= bool $param2,=0A= ) {=0A= ...=0A= }=0A= ```=0A= =0A= Best regards, =0A= Theodore=0A= =0A= [1]: https://grep.app/search?q=3D%23%5B&filter[lang][0]=3DPHP=0A=