Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111207 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 77969 invoked from network); 28 Jul 2020 05:38:08 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 28 Jul 2020 05:38:08 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3D1151804E6 for ; Mon, 27 Jul 2020 21:33:58 -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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, 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-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10olkn2013.outbound.protection.outlook.com [40.92.41.13]) (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, 27 Jul 2020 21:33:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RPtjr/So2a6rmgM17sJwVOs8k9vq/UgOgiJ4Q6moGvrntz7Tf3Dpzo96B4NVIpJ9Ng8wgfgr4H7LbjA5xjQoFfg02/uf/Xyxf9oq5V4Grv4oELS0CX9uj1SKn4cHjznkHJJdxZ5HIkCVNrhwlIkaUgGXIBDW+MCxMEo9V/jV0vqnrkU4dOD4y05GjTrgoLo2I6ghsRBJ6U+QWMl9XFZVmUApUb9ay0reRj8iw/5rUWdpqjqlqSlo/Xyerl4gmrn7fkO6cbp/j/6GeHcc1+DtJV0s/dmS8S0/nuj5INbqmIW6OrZeJbcJqaLBjDmlcayXlpdvfoIgWn6IQPeL5yOHLg== 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=NT2Vb2cdykAZxyruUSsoWOsXkFemmVuYYBYnLNWIUjA=; b=VcManTh6qjOYshOPLAkVelsOQgSXctIocri0yXrOFeLbk7BA+sLy4+dG0JzWlzwxrfVDjmZc2YcNmiLao2mqnyX4c5fETDkW0F0T0B2wgJDHgqab+vkHqBUw4MyhehFrgIO/HmWBTlKTuoipaRY2OrtOCc+sCEQ/SACA8gPqXFhlN2aO+FtTN4tOWuSYW3n9ePf3ug9myg7LsbwcnT9dQ3llJLglLhivUgvCUN4GjEW6DH1UsWTOovxH0MKRA0eJOETuDTojdzM/7G4vAEzEVgX2RW8o5hWnEQGRH9XofyuQi7F2MXutLrwhCkXejp1r2mbxCAcsqbinVSJJ6AZsew== 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=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NT2Vb2cdykAZxyruUSsoWOsXkFemmVuYYBYnLNWIUjA=; b=Kox8yN53N2EyNFHvB+skSoL7TKjkTysKlveGevlr9cWBWme6AW/Y4B89qTrpapv5Yqwh2NmilnicXJf6XDdVVnoO3xC7WcjuP30xZOAD+pNHbvDhxa6h3u2D5aiO/Bc5dwP4Om7WUYfHm+IZ3ltnFj5V4fxJKz/72vyhmsaw8kEdhs9dvakOaurTTVvhhxnFSKZH/F2k/8Q9mBe+OQodbY7efXVtbzSQLbr9XPw8xgsK8r1uBk4PjDMgNhPKCjuS61KdKYzBguN0mCbb7ZHahBgWpyz/9Y56wXYtWgMPizEG5KeJN54iCS2D62CvIbpiQkkTYvd6UvwhPwVUmOyCpA== Received: from BN7NAM10FT045.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::52) by BN7NAM10HT061.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::270) 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 04:33:56 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2a01:111:e400:7e8f::51) by BN7NAM10FT045.mail.protection.outlook.com (2a01:111:e400:7e8f::337) 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 04:33:56 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::cc10:a3e2:1dcf:adc1]) by DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::cc10:a3e2:1dcf:adc1%6]) with mapi id 15.20.3216.033; Tue, 28 Jul 2020 04:33:56 +0000 To: Rowan Tommins , "internals@lists.php.net" Thread-Topic: [PHP-DEV] Re: [RFC][Proposal] Renamed parameters Thread-Index: AQHWY1QGV6S1Us1HE06xDv4fiLJYpKkaL3yAgAIzOFw= Date: Tue, 28 Jul 2020 04:33:56 +0000 Message-ID: References: ,<0bba3669-ce0a-068e-d3ed-28fa5605e03f@gmail.com> In-Reply-To: <0bba3669-ce0a-068e-d3ed-28fa5605e03f@gmail.com> Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:AA3B59D2A7EEC1F10F6E03EAB03054CE35976AC07713C86A63A37D6C1042641F;UpperCasedChecksum:08DA2332C8B2E006F444984CF2AF87A46D647D1BF51724B7D292A3DC5CA1D7AB;SizeAsReceived:7186;Count:44 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [nt7aIZH23faQoM1YPbafULX3JZBzPxEXxdmkdS2SVTl1vkNtnvU+9t+vgnaGNERD] x-ms-publictraffictype: Email x-incomingheadercount: 44 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: e6c9ea26-e5a6-4947-1ad9-08d832af707a x-ms-traffictypediagnostic: BN7NAM10HT061: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: cnm3EhVo6fTXWuacalZ2ORCQZllhUadgK9I+AoDok2MZ0jYloBXxdTZMxK9QoxgJYkdzu818XHAc/Veijep9XHSuET/5WUTPo1sK/6wgNwNYVT13i2/ed1W5FH12r4AoHNnqGPoiEozg1kMLOB5wu9CoVZmeDu37x+shG0iieDrgkreKb73drXWGRHShCqchIKDHixBpbFtJ+KNVi1RxnGap3u96VLJdDQ/NW1GSV6n98CP3d3TApzh3HYCGrEeJ x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:0;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR07MB6618.namprd07.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:;DIR:OUT;SFP:1901; x-ms-exchange-antispam-messagedata: G+jR2FEXXFMWZfC3nlkjyhMX1Z7oWwD2CAA475Z3RgfUVu7iTNvfGnQghcna3Q1isp4ZV0LJkPLi57weI2hda6XVulYuR1s6yNJmpRoHshBe+ir93ixWS7/qYEHUYCvKJlq1DakZcxExMwCRPgZqgpIedXZ2SmkotgVJlha4qJXWn+LH6tlQAV1oejBowzqJz+2/CuEdTbwuOtf+RInB8Q== 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: hotmail.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-AuthSource: BN7NAM10FT045.eop-nam10.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: e6c9ea26-e5a6-4947-1ad9-08d832af707a X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Jul 2020 04:33:56.0161 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7NAM10HT061 Subject: Re: [PHP-DEV] Re: [RFC][Proposal] Renamed parameters From: tysonandre775@hotmail.com (tyson andre) Hi internals,=0A= =0A= Continuing on my response in https://externals.io/message/111161#111192 , a= nd considering ways to enhance named arguments without a BC break=0A= (while minimizing the impact on application/library authors that wish for t= heir libraries not to be used with named parameters)=0A= =0A= I was considering setting up a short straw poll on the wiki for a week with= two questions, open for a week:=0A= =0A= 1. Whether voters consider it appropriate to add amendments/enhancements to= named parameters (in general) in php 8.0 past the feature freeze. (Both/Ba= ckward Compatible Enhancements Only/No)=0A= (yes if interested in any of the alternatives proposed in https://extern= als.io/message/111161)=0A= =0A= I'd recognize that named parameters are potentially a large change to wh= at is considered the public API of a project,=0A= so I'd think continuing to add enhancements would be worthwhile, but I'd= like to know where others stand on this.=0A= (e.g. if any proposals I made should be postponed to 8.1)=0A= =0A= I'd also think that implementing a backwards incompatible change after t= he feature freeze (in terms of impact on code targeting 8.0 alphas at the t= ime of the feature freeze)=0A= would be a bad precedent.=0A= =0A= 2. Interest in adding support for positional-only arguments in 8.0 or 8.1 (= 3 options: 8.0, 8.1, or no)=0A= =0A= (e.g. with a symbol such as `/` to indicate that parameters or variadic = parameters prior to the symbol are positional-only)=0A= =0A= I'd consider positional-only arguments useful in some cases, such as whe= re the names would always be confusing,=0A= (or automatically generated code)=0A= =0A= - `function my_merge(string $firstArg, ...string $otherArgs, /) { }`=0A= This also provides an easy way for user-defined code to add restrictio= ns similar to what `array_merge()` already has.=0A= - `function my_pow($x, $y, $z =3D null, /,) {}`=0A= - `function autoGeneratedCode($arg1, $arg2, /) {}=0A= =0A= Other syntaxes are possible, such as using attributes=0A= (I would find 5 attributes rather verbose if there were 5 positional-onl= y parameters),=0A= or keywords such as `__END_POSITIONAL_PARAMETERS`.=0A= Nothing stood out as a good option (e.g. `_`, `...`, `%` seem meaningles= s, `*` would be the opposite of python, `#` can't be used),=0A= and I've only seen markers for the end of positional-only parameters in = python after a quick check, so at least some users would find `/` easier to= learn/remember.=0A= =0A= --------=0A= =0A= On an unrelated note,=0A= =0A= 1. A few people had suggested adding a line to a README indicating that nam= ed parameters aren't supported.=0A= An idea I had was to standardize on a machine-readable file format (e.g. ".= php_analysis_config.json") that IDEs/analyzers may choose to support.=0A= It might have JSON entries such as `"supports_named_parameters": false` to = indicate that code (e.g. src/main.php) using files in that directory (e.g. = vendor/a/b/ with vendor/a/b/.php_analysis_config.json)=0A= should not invoke functions/methods in vendor/a/b/ with named parameters,= =0A= because there is no guarantee the names will remain the same.=0A= (TOML or ini settings might be more readable, but a complicated format requ= ires extra dependencies and ini files won't support arrays if future settin= gs get added)=0A= =0A= - I can't think of many other settings I'd want there that aren't covered b= y composer.json, editorconfig, or other means.=0A= Maybe less importantly `"supports_classes_being_extended": bool`=0A= - Alternately, it might be possible to put it in "extra" of composer.json,= =0A= but some projects/libraries don't use composer.json (e.g. a project has b= oth vendor/ and third-party/)=0A= - I'm not aware of similar indicators for python for named arguments, so th= ere might not be much interest in such a proposal. Then again, I think pyth= on had named arguments for much longer.=0A= =0A= 2. Another attribute idea I had was `<>` on a cl= ass/method,=0A= to make PHP enforce that method overrides other than __construct must=0A= have the same names in the same positions and not lead to errors when valid= named arguments are passed to subclasses,=0A= but I don't plan to propose that any earlier than 8.1=0A= (e.g. for classes that have calls such as `$this->method(someFlag: true);`)= =0A= =0A= Thanks,=0A= - Tyson=