Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108268 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 39262 invoked from network); 27 Jan 2020 16:33:13 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 27 Jan 2020 16:33:13 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B831518050F for ; Mon, 27 Jan 2020 06:43:23 -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=-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,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 NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11olkn2033.outbound.protection.outlook.com [40.92.20.33]) (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 06:43:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hjS8eprSuj/HPiCAjKfzHCX7f+TarYt7Vx1ofbhA2VVWZFquqptW9NMKs8BKBnrFkyijv5No/tJjD/4JwVvvd7mV7Vv6V7lIXI6t/zcqpbivEr1Wf9w6wC62CTEPPL9QLwR76Y0+7VNx6BZ1y4hMoTM19AHsjtPHjHPAQaEhIS2yZql5WUO/q7nzGl8JpkEJ509CkDi8Z0w3Mb/PIEnz8fupUdYaFg4O/k1wlQkcNcJnQmOc8ZF2trpgq+Fd4RN5GOVT/xUiyDGj2USzZJj0uUkTFlFP87ZvZwKLewYzxe1CGRPNVqrTYjYSQjPLx2wBAOzbqGAqK4CsonfMpTrv5w== 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=avlfabhQRsLRcfMviycCw/oICBoRToemD9jn8i7OOSs=; b=G/nLuXB+irCm7O0YdqGHrDGvs3wY1uBGm6JlS6j18M4fuht7hJVzWvC11/ubzwQWhC4k/2UC40K8HhXHgziEXFzq3dFeJCcommQPYm+yG0PB4WukciGDsCjmLr4n4LVUrfU0Wa5FGL4HQCgPeW80OLN+zeq+IJS7YN3IrFxO/MPHWbXHgI/oUzD8HDJEvgOjN2Kj16bXe4xFQ4g3o3xA7hP3Zyc3R9j5ouHkfnouQ41ZCEnWONIhr6Jk637KAUIPDcezTB7kFwsVnnVel8P68V2JSr/905ZQm1+0SOLkiKKZ/ePukqkZ/XIowjl6db+PboTBL2xTKrFtSYIgF3Ykjg== 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=avlfabhQRsLRcfMviycCw/oICBoRToemD9jn8i7OOSs=; b=FG5tOngpcTa2qdx2rzNSDXiOxZFBB2fAoyKMPtexAzMb5oKOQBTFyRlGtkXQfosCR9zCsHGxeqrW/zL+9+h9ty/m8HZs0U/l8xp8sCjnOSDAFVP3ZcDoaX+1BYO9sDkLj1Bb6HQg6pNJEfOJul57BT7qcAmNB5pXoBr3Rt2bkZKm072G6uBVVKCAxkOf96K07OzGLrl/zpONqcivT2RaLvlBZeK5wiUg/jJLK+wNWSk+8BYR9hFsn+43H2GF4lLJPw9wSvDJ8mEip8lfJcEVRHjiX+NOKKt5wQOTouBFa1WiREgmNxjdu/YCFjLbpvBowMdytKhLltU1NruIwrIRgA== Received: from CO1NAM11FT022.eop-nam11.prod.protection.outlook.com (10.13.174.57) by CO1NAM11HT257.eop-nam11.prod.protection.outlook.com (10.13.175.174) 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 14:43:21 +0000 Received: from DM5PR07MB3067.namprd07.prod.outlook.com (10.13.174.57) by CO1NAM11FT022.mail.protection.outlook.com (10.13.175.199) 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 14:43:21 +0000 Received: from DM5PR07MB3067.namprd07.prod.outlook.com ([fe80::29e3:53bf:163e:5beb]) by DM5PR07MB3067.namprd07.prod.outlook.com ([fe80::29e3:53bf:163e:5beb%3]) with mapi id 15.20.2665.026; Mon, 27 Jan 2020 14:43:21 +0000 To: Nikita Popov CC: Claude Pache , Nicolas Grekas , Mark Randall , "internals@lists.php.net" Thread-Topic: [PHP-DEV] [RFC] "use global functions/consts" statement Thread-Index: AQHV1IfBuqjWnIu9lEWrxlRKvYFij6f9dXecgADKhQCAAFMdqA== Date: Mon, 27 Jan 2020 14:43:21 +0000 Message-ID: References: , In-Reply-To: Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:61C57B5B051442861308342C9302D83CF80F5318EF85119958A5C93262627255;UpperCasedChecksum:AA1A07D852CAE8BBD1D7CE9C713F6307D86FD31BB8EC57F959C7DA3FE4FA4200;SizeAsReceived:8246;Count:46 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [P9tTmVTd7A206vtQJtC4zdelMmdsX/sL] x-ms-publictraffictype: Email x-incomingheadercount: 46 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: f351785c-7623-4967-4e38-08d7a33741a2 x-ms-traffictypediagnostic: CO1NAM11HT257: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: BgRcqBXQXtY2PCfDnHbJPikUn22kfxWGauYGncMxZ37qD4ibEm+T+46ORVrVoossyqjIH6j6BA5FDCmRnfbUwHXIiKuRrM2raGeakIH/eCcsO46uX4QE9jsA+7BU6dBd9q7R86k0xdznwNPJK1T+WIA5ldk0bMScoO912apI0P2o3JkhpyOXbQdLJu+YBVDRNKc/e8XJF6EICYFCg9hGgGQl7mDzv5F72VzuUCiVjeE= x-ms-exchange-antispam-messagedata: bDa4sjkNz0HoDtX0zjZg/TlBsZX1CX5Mf6jjF1mQPgk4nPEOWSr49bD8pGUJH0P2hm6gVEFaHvnpwvLmHDh9elOizuXZkOTQPY0+y4s+/W/ZeT6NHNk24WG3WmFoE0iUpIcM4pkDaVMhOZBcrylGNw== 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-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: f351785c-7623-4967-4e38-08d7a33741a2 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Jan 2020 14:43:21.4659 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1NAM11HT257 Subject: Re: [PHP-DEV] [RFC] "use global functions/consts" statement From: tysonandre775@hotmail.com (tyson andre) > This would be a compile error right now though, because we don't allow "u= se"d symbols and declarations to clash.=0A= =0A= As I surprisingly discovered when implementing the RFC, they don't clash.= =0A= The PHP interpreter has a special case where it doesn't warn or throw about= the name being in use=0A= if the resolved (namespaced) name in use is the same as the element being d= eclared.=0A= See https://3v4l.org/RtPKv - the below example works.=0A= =0A= ```=0A= While I was the one who originally suggested to allow this kind of code, = =0A= > I think it might be better to just unconditionally make it a compile erro= r,=0A= > and require the use of declare(function_and_const_lookup=3D'default')=0A= > if you want to declare namespaced constants or functions. =0A= >The main motivation for allowing it is interoperability with namespace-sco= ped declares,=0A= > but as those don't exist yet (and would still allow a per-file opt-out), = we can delay this issue.=0A= > =0A= > I think that principally, the correct behavior here is to bring the symbo= l into scope as it is declared,=0A= > but as you already pointed out, this leads to unclear semantics when cond= itional function declarations are involved.=0A= =0A= The subset of code that can be written requiring "use function NS\foo;" and= "use function NS\MY_CONST;"=0A= with function_and_const_lookup=3D'default' is larger than forbidding it com= pletely, while still avoiding ambiguity.=0A= =0A= > As a minor note, rather than using 'default' as one of the values,=0A= > I think it would be better to use 'fallback' to make it robust against a = potential future change of defaults.=0A= =0A= I'd rather have that done when the future change of defaults is being propo= sed.=0A= Supporting 'fallback' might cause confusion and extra work if the name reso= lution defaults ever change in a different way.=0A= At the point where they do change, we either do or don't want a way to supp= ort the old 'fallback',=0A= but we will want to support the new 'default'.=0A= =0A= Right now, it's deliberately intended to be the same as just leaving the se= tting off for that file.=