Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110414 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 76514 invoked from network); 8 Jun 2020 05:53:33 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 8 Jun 2020 05:53:33 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3632B1804F3 for ; Sun, 7 Jun 2020 21:36:53 -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-co1nam11olkn2030.outbound.protection.outlook.com [40.92.18.30]) (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 ; Sun, 7 Jun 2020 21:36:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QfQqHS2LCyzFhdSQd60ZDYR0bjsy9KDLH7L9PvpTzDodH8Hkov6Ng3oG00HiE45Ni+f0VTTQtQeTmKpEM7HuTmKyjB+xo6F7mYBYWullgqWfiZ9gZtaoOXSt6E1d0nNcQfUAOT4dFaKvqWPCbJIXd41cpvnCy6mboCYmxFLkleQdS/dzBHnl8NfcHVy2EJe7ZlKJGnjLlz9awKmcw7dx3HWzl2TtAS5vs9w+rZy698KcZ/Af0nPM7Q5vSyK/GdOXLP2FFX80js0iJcw8YE2msBxnurrt7cChIawASF5xUEleqwCVp68AgajklyRm1+shuW/hB3QZoRGkwcZmBO/uIQ== 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=W1ndtsguMGU0/gZZVQ58MyuOr2f182krFJpyij9mkZo=; b=aIsp6MG7U88LMHIvYTr0Mu5CgZdVNuebeWQ6J3Ut5XqK4kYNB6W+EnCch6vMKgMLrlYWTLd+gnZQgp3ZBRZ9BYaOmLInCCSY0V6iXXZ8UWaR8780H91syDqoxPwvI6J28KBum6r5O55UErBXGqOMzOX5YuSHLwbxKeON2dj0FRKGdYMKWw/bUa7qMd3YfddfARI/uDc7YCgrbjTVNPURmYJuu2O8JH0TCBO0+hL7TmqTwF3Jq1MdP/jbYnkqHY1BKCdMlXzmxm5FHEECwB6Mxk7ChEb3N1TV5MQ60m9z8CDv3DOYnswPpwLyizT3b054sQONdv3iGjBGt3wFIwZAXw== 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=W1ndtsguMGU0/gZZVQ58MyuOr2f182krFJpyij9mkZo=; b=JG9f/0FqmNXNj12H7nQeIhqv0kKB7PU04bbsM6Wxsl3bhTQuGY5fnvUapfgKs/dAaji2hF3SOIVwwdk0rCO6WZ3aQ2eSqETenhFwy+5diVlYQBgoFylGEbYOgk2zqf5BXd5rFsbAMFEbKjSvyutsg28a1m9ss4Ga2vVHDEvWvoje9w/QrDTZOvAkAfwci7pDnaLy3chUr1xuWp2kGgpueYQlscjEueZup8jShCjJg9QVPtq0GhPZQcT3+ksHEe+euYorMPCJt2UvJpUTIfsBiUeO0sQnOFn9/NZS7DqqYnvnFoBhOxn4iIAGZw2MMmtVKeo3hzq6bl3DTC8zPTwLtw== Received: from CO1NAM11FT006.eop-nam11.prod.protection.outlook.com (2a01:111:e400:3861::43) by CO1NAM11HT020.eop-nam11.prod.protection.outlook.com (2a01:111:e400:3861::169) 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 04:36:50 +0000 Received: from BYAPR05MB6535.namprd05.prod.outlook.com (2a01:111:e400:3861::4b) by CO1NAM11FT006.mail.protection.outlook.com (2a01:111:e400:3861::246) 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 04:36:50 +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.016; Mon, 8 Jun 2020 04:36:50 +0000 To: Rowan Tommins , internals Thread-Topic: [PHP-DEV] [RFC] Shorter attribute syntax Thread-Index: AQHWOgIv0rCwDWp4oECJgOMrWx9MxKjItJCAgABT1+2AAnlHgIAB4RWMgABgUwCAAE4Q4A== Date: Mon, 8 Jun 2020 04:36:50 +0000 Message-ID: References: ,<5ebecd58-9f39-72b9-369d-dbb60b80af36@gmail.com> In-Reply-To: <5ebecd58-9f39-72b9-369d-dbb60b80af36@gmail.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:D9ECBDB144F9133299E0A7FB1E239B56486C954BBF06ADD128B8E86F3F669A2B;UpperCasedChecksum:08D57E4CE4D806F711EDFC95A218CA8C7004983944E8CDE3A574325CB4E20B6E;SizeAsReceived:7251;Count:44 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [u/w9tk1YpQGeEY6irJMtKC17Zy3wuBK8] x-ms-publictraffictype: Email x-incomingheadercount: 44 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: d8dd390e-5a68-46cb-aa1f-08d80b658fd1 x-ms-traffictypediagnostic: CO1NAM11HT020: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: yAVEdzHJoM2MkBSXMbD2Nm1ylKQA1OQ57JaBsTCSNcRG8uN/rlBIJihm/MfEG77I5NPqvURl6tdmyner0od33CBDDkIi101OKhinC92Oge82CHPNbq9DYhcZ0sMIwYvIkKKOMVF4HdYcGD9/rjxFSXG6vZ9IGpNCEKWc3CbQam7FUo9M5+qUwc2/nXQqNn/gJ342k1jWvcgrTLhVVl3aw9mY4xzVnzPDSSai7CwzGkZAGlKS4U7UKKF3dAg93gWd 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: BUrvYTTrS3lsyzn2M38JH1wirkZqVNfynNwuVLDeoGqhZKEETJe0MakgHEwsV5LOylUn2Zr6n/Y+PzlbfF/CzCFcRXlrIdmXUjMKy5XzjJLWWy03dBnwcY8NTQPCda50srUx+Ny4sgXIcEoHT/moqA== 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: d8dd390e-5a68-46cb-aa1f-08d80b658fd1 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Jun 2020 04:36:50.4910 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1NAM11HT020 Subject: Re: [PHP-DEV] [RFC] Shorter attribute syntax From: theodorejb@outlook.com (Theodore Brown) Hi Rowan,=0A= =0A= On Sun, June 7, 2020 at 5:32 PM Rowan Tommins wro= te:=0A= =0A= > On 07/06/2020 19:37, Theodore Brown wrote:=0A= > > Yes, I agree that there's a judgment call to make. Out of curiosity,=0A= > > given these shortcomings of the double-angle-bracket syntax, do you=0A= > > think there are any objective reasons to prefer it over `@@` (other=0A= > > than the theoretical BC break of code like `@@@really_suppress_me()`)?= =0A= > =0A= > I'm not convinced there's any objective reasons to be found either way, = =0A= > but for the sake of "playing devil's advocate", here are a few that =0A= > could be put forward:=0A= > =0A= > If grouped attributes are added, they're actually slightly less verbose = =0A= > than repeating a double-at prefix, once you have enough attributes in =0A= > the set:=0A= > =0A= > Minimum spacing and punctuation requires n+3 chars vs 3n, so a saving =0A= > even with 2 attributes:=0A= > `<>class Bob{}` =0A= > vs =0A= > `@@Foo @@Bar class Bob{}`=0A= > =0A= > More realistic spacing is 2n+3 vs 3n, giving a saving only with 4 or more= : =0A= > `<>class Bob{}` =0A= > vs =0A= > `@@Foo @@Bar @@Baz @@Quux class Bob{}`=0A= =0A= Neither of these are realistic examples, though. In practice, you're=0A= not going to have an empty class definition on the same line as a=0A= bunch of short attributes like this. Based on the Use Cases section=0A= of the Attributes v2 RFC, [1] typically there would be three or fewer=0A= attributes applied to a given entity.=0A= =0A= The RFC only has one example with four attributes, which happens to be=0A= a flattened version of the nested attributes use case discussed in the=0A= Shorter Attribute Syntax RFC. But in this example, the attributes each=0A= have one or more parameters, which makes them long enough that they=0A= have to be on separate lines. And with sane formatting, the `<<>>`=0A= syntax version still ends up being more verbose:=0A= =0A= ```php=0A= // 170 characters for attributes (162 not counting leading whitespace)=0A= <<=0A= ManyToMany(Phonenumber::class),=0A= JoinTable("users_phonenumbers"),=0A= JoinColumn("user_id", "id"),=0A= InverseJoinColumn("phonenumber_id", "id", JoinColumn::UNIQUE),=0A= >>=0A= private $phonenumbers;=0A= =0A= // 160 characters for attributes=0A= @@ManyToMany(Phonenumber::class)=0A= @@JoinTable("users_phonenumbers")=0A= @@JoinColumn("user_id", "id")=0A= @@InverseJoinColumn("phonenumber_id", "id", JoinColumn::UNIQUE)=0A= private $phonenumbers;=0A= ```=0A= =0A= So the idea that the `<<>>` syntax with grouped attributes will be=0A= less verbose than the `@@` syntax turns out not to be the case in=0A= real-world use cases.=0A= =0A= > Bracket-based syntaxes, particularly with grouping, are more clearly =0A= > separated from the main code, particularly when used inline. For instance= :=0A= > =0A= > `$f =3D @@Something @@AnotherThing function(@@Special @@ReallyInt int $va= r) {};` =0A= > vs =0A= > `$f =3D <> function(<> int $= var) {};`=0A= =0A= To me there doesn't seem to be a big difference in readability between=0A= the function attributes in this example. And with syntax highlighting,=0A= the function keyword itself provides a very clear separation.=0A= =0A= For the parameter attributes, the `@@` syntax example is actually=0A= more readable to my eye. I can't help seeing the `>>` token as a=0A= shift operator at first glance in this context.=0A= =0A= > Finally, typing up those examples, it occurs to me that `@@` is quite a = =0A= > "heavy" symbol - it has a large proportion of black (or whatever colour) = =0A= > pixels - and inevitably a rather "fussy" one. I find it draws the eye =0A= > more than the angle-brackets do, which feels unfortunate.=0A= =0A= I guess this is somewhat dependent on the font you're using. But in=0A= general I don't think that the symbol being "heavy" is necessarily=0A= a bad thing. It can help attributes stand out better from function=0A= calls, generics, and other nearby syntax.=0A= =0A= Best regards, =0A= Theodore=0A= =0A= [1]: https://wiki.php.net/rfc/attributes_v2#use_cases=0A=