Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108274 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 67055 invoked from network); 27 Jan 2020 18:30:35 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 27 Jan 2020 18:30:35 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C61AB180606 for ; Mon, 27 Jan 2020 08:40:46 -0800 (PST) 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,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 NAM02-BL2-obe.outbound.protection.outlook.com (mail-oln040092003013.outbound.protection.outlook.com [40.92.3.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 Jan 2020 08:40:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h49RDtN0GAaYlFzKHmcqL0bxA03g0GSJmVh8J+dHtwjpm1s7neLdl3e2E8t55BJ/kudkJCH2bCpgChCmz0rYy2OZNOatu1jL5TJtWLtgercmIGFHQ0hWYxNQXYUD5a8Wibpdi+dscCxY0bHomSzRtO1JEDVlXuD+kjiH/6hbkpG7EY0VxyF+K0BPF/HN9uWlJhx6Y6JHY7LuO41o8Q5yKYrk6aKoWmnFbUW/sSuvf1hZx8cS78+pZCcbR1j+Tg/sPKggyzSNBVlBae4BfcS5rp47DE59qJ3KQI9lRjMxkHSSjn6xVQaRA4KfQDv4mS7gXvYZdzZIigl0DGqmXIaxuA== 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=Vgw2EeifcFeqzZm5iZOpDdXAWc9EBx69ZzyfeQjBNqk=; b=aqM/CFqMiLPSokuFb42kxpINtPXn851lJeX+4j63qOEIQYWQgrRktXJSbgwIwikTAvtaKRMHCgvpubuNyzx4y1GG+6sj77NMjztvTm8D6IrnEUux5FlEgX6exUs7xzI1faU+rgpOtDfn97GcVzm7rl3AXOPwECcnAVdV9BhdjuUo6cnDzVNN06ncd3QPMmAbHIoYs5GFf84vw71F0eMwHcxflwX/cm5on07tfg7pcNUfzxPeiCf/rmpDA/8osBDfUjEWYaxg2TrRvU/xUtBbXeJNzYc789+QnBYaQGC6r1AWJN9G5s3nsR5svkQ0UKvKORuUXwvsuv/ptGuVFNnWZA== 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=Vgw2EeifcFeqzZm5iZOpDdXAWc9EBx69ZzyfeQjBNqk=; b=R0TugLUMTfijPX9UtiTRcrq2GrgotDYlNZLYylqOVvOsAe3BIYvXv5Goqjf+/jrQ/h4Ux+yPKdYOFVkAVJjtlzsFxCrl1xnBQusMA+qKQpGlaWrUBBvWoSuS0g5EKl4Vr6hZKxdREq/nIM8XNNx20Zdw1R9yaX7+05HyaV+JgrojTgYq64fN1iShlg9g42r1CHvoje+S3/DGHKYhwhidFLCLZZEZxHejjQ/lZR1i0gpzdGQMOGS4lFgMjvMJ2nfZ/LzpYgwEg3mQVJitHwq/EN6hgUGYKe3ayiP+4mVdGW8zyQB9F6DQC9yGNF+OpCYwOjQ9IkRb4lk613nb1aoxsg== Received: from BL2NAM02FT027.eop-nam02.prod.protection.outlook.com (10.152.76.60) by BL2NAM02HT170.eop-nam02.prod.protection.outlook.com (10.152.76.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2665.18; Mon, 27 Jan 2020 16:40:44 +0000 Received: from BYAPR05MB6535.namprd05.prod.outlook.com (10.152.76.51) by BL2NAM02FT027.mail.protection.outlook.com (10.152.77.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2665.18 via Frontend Transport; Mon, 27 Jan 2020 16:40:44 +0000 Received: from BYAPR05MB6535.namprd05.prod.outlook.com ([fe80::d512:a8c6:f95a:56a8]) by BYAPR05MB6535.namprd05.prod.outlook.com ([fe80::d512:a8c6:f95a:56a8%7]) with mapi id 15.20.2686.019; Mon, 27 Jan 2020 16:40:44 +0000 To: tyson andre , Nikita Popov CC: Nicolas Grekas , Mark Randall , "internals@lists.php.net" Thread-Topic: [PHP-DEV] Re: [RFC] "use global functions/consts" statement Thread-Index: AQHVwNgGtev425C1jEaW2/fYCDQJoKfqjUCogAA6vwCAABZSCIAF7qHQgAA+1YCAABKbIoAI/p4AgAAC2gCAABgFtYACp60AgABaA0aAAIW5Vg== Date: Mon, 27 Jan 2020 16:40:44 +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:C9848C4C6C421AA939CDEEF702EA6744A18E2632B6436F3A3C7CC1B1042FFF15;UpperCasedChecksum:E980B3B009E172C1D73449C998A197FF9B9441039D225D49C40D1DF725007FCC;SizeAsReceived:8102;Count:46 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [kS+C4AoKhdNIftgcFNIGdZWNVvdVw1X2] x-ms-publictraffictype: Email x-incomingheadercount: 46 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: 3e11df11-485e-44d7-5406-08d7a347a7ae x-ms-exchange-slblob-mailprops: =?iso-8859-1?Q?GAKwtM8+QqtjGD8LvJ5rbtDzxgAv3Szn+4AE3WUsEQlQjGpm+yo4/YmTi0?= =?iso-8859-1?Q?WnMe5LCJk5uKnBuc8jVKH+noRLSH4L9MH7g3zvJb9gZMHyPpBXNlyPOnEi?= =?iso-8859-1?Q?NibUt0qsEedJsNiEY9Ob+Qbs9szvpFyIZqgkAhXSbegTaT7w1L4yGTS4co?= =?iso-8859-1?Q?/I8w5ef2rukdl3JPUEiG8Hwh7ELngDizzrXo0gPHjEJwfTpQeBXZvkxswT?= =?iso-8859-1?Q?F7VwUYmlEGqQeJrXcF1GOfXcbuBesCU41/rr0euNAQUJiW9WcUu6pVQriW?= =?iso-8859-1?Q?EbB3LnN1l1IHd4e12WfV33W46PZRLcB+GjYaVq9TRauwkvm706M3mjGoTb?= =?iso-8859-1?Q?1nGIfv2xkP0HvtgYfaAORJ4whxtvUYTT/Yq5xxhNXIameY33v+2nMfFszg?= =?iso-8859-1?Q?Wquk+pZC34qSExEHe6+C3iSpcE86HKnD8mg8FuixbJbyf/AaHN6k9JdMfW?= =?iso-8859-1?Q?3lSrX47DEJp6voVHkvnrX9uepf1+OnUUsF6xQ1rTDQNXeg5h9w+0msl8Qm?= =?iso-8859-1?Q?AOV4REMjlSZ4B/ZmATLThlcP08+uP6nh5Z+R3kUhdo84ildMXlGRmA2FUH?= =?iso-8859-1?Q?zAjjwwr6tBpmSsEBOFQ4A2X9uAhHldcvEZK+gwG4Vls9tCXfMPr14ZAV/Z?= =?iso-8859-1?Q?YOZu3IfsHQeesvNq2p37IqD0Y/BmwjU6wTgcc1MBEnfu032KVVwKUs4FNN?= =?iso-8859-1?Q?uMk/vap1s+ou9JRW8s3DXWdzdUoHm/lX93/yDljdO+4AmHu1KVNv3ioD9F?= =?iso-8859-1?Q?nJbzSFtDQ2+hQK42Ow6gllVYxO7x4UnlkNuKLvlQEWYLD3F/5dfXvqDf/J?= =?iso-8859-1?Q?3B4HyaSl3tlDkMi1wFnvPv37fqd3BSeVo/LRHdU0l4bBPlDwgKQkpZw9Mn?= =?iso-8859-1?Q?iQ1kb6hcZxYom3KKRQ05xCAT6qcwhC32vZXL72DAbQlhFAbPtFXrlFdyqM?= =?iso-8859-1?Q?WLNi4hqVaS4VjsdkMOkaIn+pJC1RKGgyjfsvJW8fNk+J2s39gJ+HKZnS6f?= =?iso-8859-1?Q?VA3D6g?= x-ms-traffictypediagnostic: BL2NAM02HT170: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Wlx4xR+HY3bXwwnuhII67L3eTz8w73zCPkeu7wtz3a9mZVG1LTAgqroHAzizXaT7cOxvfWp0alNHiPEVf6AHziqBmkGPlw6PoUGaEz7T0TifYil6DYDE/G24Esosniyqz6mTlDF1GnEFPeBt/dBZS32Qzeet7IEeanOVpXi5Pomh51pJzDVt6wsXex5oFH0MVx5RO9cMddN8rB86PbmCCtui7JlDYRTdcCAdz2xkMf4= x-ms-exchange-antispam-messagedata: Bv5/sIPqEozBoWoqEWiIUhQ0WUHcNdccHa8BfO+c9FbE0JnfEzg4vNwpvacc05KT0NxoohO/NfGZgKRaz/9Hr6/AKCmFbq3IqKB/S7ekEaIBb7RVl3n9iA2YBYYgvUqR6NF6vO/7L6jG3r0DoTeUQQ== 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: 3e11df11-485e-44d7-5406-08d7a347a7ae X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Jan 2020 16:40:44.5620 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2NAM02HT170 Subject: Re: [PHP-DEV] Re: [RFC] "use global functions/consts" statement From: theodorejb@outlook.com (Theodore Brown) On Sun, Jan 26, 2020 at 10:25 AM tyson andre wr= ote:=0A= =0A= > https://wiki.php.net/rfc/use_global_elements and the implementation=0A= > has been updated again - the syntax is now declare(function_and_const_loo= kup=3D'global')=0A= > with a literal string instead of a keyword.=0A= =0A= > The voting option for whether it was a string or a keyword was removed.= =0A= > I plan to move this to the voting phase on Monday, if nothing else=0A= > needs to be addressed=0A= =0A= I have a few questions and concerns:=0A= =0A= 1. Is it a typo that the first code example in the proposal has a=0A= namespace declaration before the `declare` statement? Currently it is=0A= a fatal error if a `strict_types` declaration isn't the first=0A= statement in a file. Are you intending to change this restriction,=0A= or have it not apply to the `function_and_const_lookup` declaration?=0A= =0A= 2. How will this RFC fit into "future work on autoloading" (mentioned=0A= as a benefit in the discussion section)? Would autoloading only be=0A= possible for files with `declare(function_and_const_lookup=3D'global');`?= =0A= =0A= This RFC seems like a pragmatic attempt to solve the global/namespaced=0A= ambiguity issue for the way code is typically written today (most=0A= const/function uses in a namespace being global yet unqualified).=0A= However, isn't the current lack of autoloading part of the reason for=0A= this usage pattern? Personally I would love to write more plain=0A= functions in namespaces, but am forced to use static class methods=0A= instead to benefit from autoloading.=0A= =0A= In other words, if PHP had function autoloading, there would be more=0A= usage of namespaced functions, in which case changing function and=0A= const lookup to global becomes less helpful. In this way the RFC seems=0A= to work against one of its own goals.=0A= =0A= I would find it quite annoying and counterintuitive to have to=0A= explicitly `use` namespaced functions and consts in the same file=0A= they are defined in. The example in the RFC of a function defined in=0A= a namespace that appears to call itself but actually calls a different=0A= global function is particularly confusing.=0A= =0A= I'd really like to see a more complete proposal that thinks through=0A= how it will fit in with future autoloading and the way people will=0A= then write code, rather than just the way they write it today due to=0A= current limitations.=0A= =0A= Long term I think it would be better to have a `declare(global_lookup=3D0)`= =0A= option which could be applied to a set of namespaces, and a registered=0A= function/const autoloader would only be triggered for those namespaces.=0A= This would allow function autoloading to be used without hurting performanc= e or breaking existing libraries.=0A=