Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110011 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 62764 invoked from network); 5 May 2020 18:24:30 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 5 May 2020 18:24:30 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3BEA5180510 for ; Tue, 5 May 2020 09:59:28 -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.64.0.0/10 X-Spam-Virus: No X-Envelope-From: Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12olkn2028.outbound.protection.outlook.com [40.92.23.28]) (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, 5 May 2020 09:59:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HPwMfE2jPGowiXcAH/7CiqtDmnujAq76KehcHYw+0pOh9uu6Pgpxzx/MXoKNf8uvHD/g5XB8Vh2T0lr+iDcnbKnjKQHZ4KAK5f67xQ4VKrN9kFaVDHLAhX9E8TrKn7qNA35wKyEdO6gcXILxS+KBdnRLAa+IczJs9gb92vO0UJDZvKXyPAOZunQtIOgzVq6SRjWs1YhK5B+AxpZBiwfOFK9s45TSdTK1MCv3VhTQ5edqKZ/AFqYkKjpfVZkAiJMuOAIi4xQVvGCb/5fS5BNyi3e+XRe82AvMr4oEzXNqf1NJWTt80Erzp64JgFHLGCrk6ESdsI580jXmz7lfui00FA== 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=IjRLn4W6m8Qd79dSUUUc+aDru7Wop75vJMhzWddvWoY=; b=DDuOJIxM6LbY8eZLwRwwU9PXTTlzuSdRfRwOQXbSyxoOxzXBVseo+9AE1PzMDPDJ6xi+SUp0m3vydirFJG2vDcOaipqAR9nEuhmZ56BKfEi+qKFHuRfKvn5fDIZqe6i0Jkb2uj0aEF6lQQ2C0dJVfe8rb2w9zDLChXH3ogjEVCEo28LHOSwOjEXEX9zDo+D0jGA02wMov3PrrRfsF8t4bbsQ6bqFzl5H2U2gAKNPyyR9Og7pVVt2s6zJXMTY2ixk6i8vtJ/f4lz9NYVz/dPwxbmql7QeSx+wXzFxet2oN2uYBS0oyL91ADHsoZ4KBktGR3NJe2ut4CaxC+rY4mtiEg== 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=IjRLn4W6m8Qd79dSUUUc+aDru7Wop75vJMhzWddvWoY=; b=u+0McmWdEhceATOqZU6Vv5E/x86YmhnbJz+JT0S5SGRdlsjYBvAok+pQAbK3tHrjEQP3FTUVHZZtZsVVhGgTJ8ecLaNf58cs4/hKY7EH2/Iwy0UASB3iBFtPSN6xYknh7QbEzBygAgoBdq9Et1L0yGQTn+bjiRSUT3ujv5qAF+Cf4F1+ES7NnJnaQULn7da3w4YKABLXltuRFXrPHzjRsMt1CXSAZH+AfjLRq08glXuD5YXMHMzfQXF/ScD8/L265sHb1RJWZoAz84Rzy/8yjjhfxxgIZZPJM5jrgR2YPetAVTg2Ur8N2Z8fRMKN+95ZieMxfM1BxzPWFCS4YgW09Q== Received: from BN8NAM12FT057.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc66::4b) by BN8NAM12HT155.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc66::190) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.23; Tue, 5 May 2020 16:59:25 +0000 Received: from BYAPR05MB6535.namprd05.prod.outlook.com (2a01:111:e400:fc66::45) by BN8NAM12FT057.mail.protection.outlook.com (2a01:111:e400:fc66::192) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.23 via Frontend Transport; Tue, 5 May 2020 16:59:25 +0000 Received: from BYAPR05MB6535.namprd05.prod.outlook.com ([fe80::70ae:fe95:f263:2974]) by BYAPR05MB6535.namprd05.prod.outlook.com ([fe80::70ae:fe95:f263:2974%2]) with mapi id 15.20.2979.025; Tue, 5 May 2020 16:59:25 +0000 To: Marco Pivetta , Nikita Popov CC: PHP internals Thread-Topic: [PHP-DEV] [RFC] Named arguments Thread-Index: AQHWIuRQgEnh5uGy6EupES3pBJ/NLqiZiEkAgAAun/Q= Date: Tue, 5 May 2020 16:59:25 +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:1C491205343AA3CEE7C5F1FAA7554AD11B65186646DA2F98215EFD268E3991B8;UpperCasedChecksum:046D694B839D4B00182FE2AA1516CC05C612F776C439B440A7018F4576851A22;SizeAsReceived:7046;Count:46 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [aWCoqmTmRftKKpqOse2X5oT2FPhguzgJ] x-ms-publictraffictype: Email x-incomingheadercount: 46 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: d8a81dff-84c1-40e2-c602-08d7f115aa5d x-ms-traffictypediagnostic: BN8NAM12HT155: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: lsNs8QDXCDJ7g9b7GUusdWjPEq/GB1r7KaYdewoYor/cIcjpbFKYsys10CBGG+c5Xoryeyk4L/cFbyv0X4TQ7hPgyDLfMWGtC7cV7aYgGXBk2zIKT+nNZa9LDaO8FR+vjEa18dAeh+h02SjQCiDjqsVFL3hcnk2PUzyD8Ar3Abezo9ZHaduAQEwFQkRBqgoyVKn0mwRCgjrlHM2HzsEa3Q== 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: rYPw/r3GtxTu/tzMw4Lumds9QSuaptMSu9XnPCMwtag2JkGP9Gmxllq50OWLEW7pDhqbFlsv9xB7jjQ8X+3X0C5SApiMDzMXt3pJeBKxwppPIwxqEPJvCsashNzLm9+elrtermu/X9Rqa17PSVS34Q== 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: d8a81dff-84c1-40e2-c602-08d7f115aa5d X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 May 2020 16:59:25.0494 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8NAM12HT155 Subject: Re: [PHP-DEV] [RFC] Named arguments From: theodorejb@outlook.com (Theodore Brown) On Tue, May 5, 2020 at 9:11 AM Marco Pivetta wrote:=0A= =0A= > As mentioned some days ago, I see named parameters as an added liability,= =0A= > rather than values.=0A= > The rationale of my negativity around the topic being that a diff like=0A= > following is now to be considered a BC break:=0A= > =0A= > ```diff=0A= > -function foo($parameterName) { /* ... */ }=0A= > +function foo($newParameterName) { /* ... */ }=0A= > ```=0A= =0A= If the function is part of your own codebase, an IDE can automatically=0A= update function calls when renaming a parameter. For functions that are=0A= part of a public API, yes, parameters shouldn't be renamed outside of=0A= major versions. But in my experience, it's rare for function parameters=0A= that are part of public APIs to be renamed. Do you have many real-world=0A= examples of where this had to happen?=0A= =0A= Also, I haven't heard of this being a big problem in other languages=0A= with named arguments like Python.=0A= =0A= > the feature seems to be especially designed to work with particularly=0A= > bad API (anything with a gazillion optional parameters, such as all=0A= > the OpenSSL nightmares in php-src).=0A= =0A= Why do you say that? For me this feature would be extremely helpful=0A= when calling constructors that have several optional arguments (e.g.=0A= similar to the `ParamNode` example in the RFC). Maybe you consider=0A= this a bad API, but it's a very common pattern, and named arguments=0A= will make it far easier to work with than the typical alternative of=0A= converting arguments to an options array (which is itself a BC break=0A= and has many other downsides as the RFC points out).=0A= =0A= > In practice, the issues around bad API (in this case, bad =3D lots of=0A= > optional parameters, maybe even ordered arbitrarily) are fixed by=0A= > using proper value types and structs or value objects=0A= =0A= How can lots of optional parameters be "fixed" in practice with structs?=0A= E.g. how would they improve the `ParamNode` example in the RFC? Would=0A= it even be possible to migrate existing classes like this to structs=0A= without a BC break?=0A= =0A= Personally I think it's a lot simpler and more consistent to have named=0A= arguments which can be used anywhere, including in attributes, vs.=0A= having to implement and learn a new syntax for structs which only works=0A= for that one use case (and may not be easy to migrate to).=0A= =0A= Best regards,=0A= =0A= Theodore Brown=0A=