Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107991 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 81695 invoked from network); 5 Jan 2020 19:58:29 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 5 Jan 2020 19:58:29 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1782318050F for ; Sun, 5 Jan 2020 10:03:11 -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=-0.5 required=5.0 tests=BAYES_05,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 NAM02-CY1-obe.outbound.protection.outlook.com (mail-oln040092004064.outbound.protection.outlook.com [40.92.4.64]) (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, 5 Jan 2020 10:03:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VdMmIO4DMX4vnBHFrMn+vASQ989wip43UjQKx26L8MLK9a1yhSLIWEqDPQmqtRp54uqRQzTeB5fKUCJcEL471eAm4mgbylvrcdZwdyJHEeWKXQDZB8KI3cOVXwf1ua3iDDAwF6yh+tSYA7MNLpA8Xftg9dXUVvdHAXWmR6qu5hDdakCDBXwsftsKMQ5PnPU4yKpjhv184+k8nGe7rCRYpKI8IC0P1qR51zuN2TcnhElQ+tN2gX20C55LW7ni12s1DZ8TJvMC4bcJ+YxAO1XI/AumMmeykv6fz+zkBBQmfhvIEhAu0cWmWWD8uaNDkK7mCPZhTciNukhakvHyyxKDIg== 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=8/c4QuZzrcdpND9VXj90wjX6CpYqCiDwgTj3hkHzprg=; b=Bnb7K5e8FrySvti48LcNACYLaSdJn8AXvBb0nia5pnSgImx07mh4QRjfTD81r2cZt5QJdv3xtxuK+Pui2rvquNGPa2kEA7fMgb7by9LgCj8HH8K4cvAGHwcPgqBFuKxF0xf0zb+H0fq8XvDQyNBIkuZqq2etXmq7DFA6jH8LH98cq5iPQRAItVY7Wxhu20b6HE1XmU6jntqoUu/YhhgWTc/FvJhZPuUO9B/EmDknccib8+xD9D1Hur9dlDgLbxD8osQf7hEaiM041DPYS6qY3jjkKp0AYfwtwRDo75mcO9Tq90fvFwkr7zIyO972Hf2lNIlFYcsGlLz22LHfv2h69A== 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=8/c4QuZzrcdpND9VXj90wjX6CpYqCiDwgTj3hkHzprg=; b=mQOWmMTik9nd4ZhkeYmS6AynusB4lyOkpRVrLGawlbfoyF9byyaxjdLpU+cHL/4fIq4iVuZdPXSWkumsN1rP1wA/Sa+Rb4uwZqGZ1UkNcZdGeFm2dudYz4DtgHctuETC0Ht/0Dg2yY8tHhacV00ds1F8JocD3D8k1+aZZEBCJeboG7OqIAw3cQxcpUFad+h4QVB2NqH0uxSniUf7pSAhsxyri2blcQiGrsAqWDnU7QEdwfoa2N159Lbq7Lt/C8KZ3Otpmut/OZLpSr1vdW6NuQXOGkk46YMnTp3lYobVaB/CQB/qMWXP1+jTVWGlkE8thJGtKHClo/tQGX6OQ22fJw== Received: from SN1NAM02FT023.eop-nam02.prod.protection.outlook.com (10.152.72.53) by SN1NAM02HT137.eop-nam02.prod.protection.outlook.com (10.152.73.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.11; Sun, 5 Jan 2020 18:03:08 +0000 Received: from DM5PR07MB3067.namprd07.prod.outlook.com (10.152.72.53) by SN1NAM02FT023.mail.protection.outlook.com (10.152.72.156) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.11 via Frontend Transport; Sun, 5 Jan 2020 18:03:08 +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.2602.015; Sun, 5 Jan 2020 18:03:08 +0000 To: Rowan Tommins , "internals@lists.php.net" Thread-Topic: [PHP-DEV] Autoloading functions/consts without a performance impact Thread-Index: AQHVwdV5EmiXz0tOK0a5kq9yFNlY0qfY/a8AgAABdgSAAAldAIAAA1RMgAAIXACAA0V1Cg== Date: Sun, 5 Jan 2020 18:03:08 +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:5D200C99D29EE07E999A5A68E835C9AE4771D10DE94D5A1DA49D890145F30752;UpperCasedChecksum:5F6BFBA4C51AB2EEA701C9D74D217D2DC896EAE14D1B3C83DABD8641C98CAC52;SizeAsReceived:7629;Count:45 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [tLh0Psh9oHELIfckDPVJukCjIRJmCn7OUqydu7yC5mXq3dXUgP433azliBvT9Kat] x-ms-publictraffictype: Email x-incomingheadercount: 45 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: 5cff0bd4-03dd-4157-d5e1-08d79209855d x-ms-traffictypediagnostic: SN1NAM02HT137: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: O0cmEy2iodL11bzdonFeAc9aGi6DEeoUNE64OtvoD+/1LICYDIjG2mp5dMCXumO5Q13w4vcrbXj49BU4v/+WS4fFD/olQpG1wOuGWNSXkBuFPWGKVnRjj897K2l3/Zwf8oawDmIjXf6QaZhin1tBqCqVGSVrefRVy6E1Qlz32pTLVaOVZjzT1rzdvMiGJjuKp1WkjtCmJ4Bsnqgub5hmYgXliEo2CGNMysKgA2wJ940= 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: 5cff0bd4-03dd-4157-d5e1-08d79209855d X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Jan 2020 18:03:08.3416 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1NAM02HT137 Subject: Re: [PHP-DEV] Autoloading functions/consts without a performance impact From: tysonandre775@hotmail.com (tyson andre) > Yes, I'm saying that the autoloader should be called for each lookup, so= =0A= > autoloading of Foo\strlen should come between checking if Foo\strlen is= =0A= > defined, and checking if \strlen is defined.=0A= =0A= That would be the intuitive approach for a language,=0A= but as mentioned earlier,=0A= it would significantly harm performance of existing code for php 7=0A= (slightly without an autoloader, more with autoloaders),=0A= and I can't imagine that getting approved.=0A= =0A= - One option I'd thought of is to invalidate runtime caches of=0A= ambiguous calls' opcodes when the set of autoloaders change.=0A= This is technically possible,=0A= but it would make spl_autoload_register()/spl_autoload_unregister() extre= mely slow for large applications.=0A= (it would be implemented by iterating over all functions/closures/methods= /global scopes=0A= and deleting the runtime cache entry for those call opcodes.)=0A= =0A= That way, if a new autoloader got registered, existing unqualified calls = to strlen()=0A= would check for \Foo\strlen once, the next time they were called.=0A= =0A= I don't have any plans to try this or work on this approach,=0A= but it's worth noting that it's possible.=0A= This approach is taken in http://github.com/runkit7/runkit7=0A= when modifying definitions of internal functions (runkit_function_redefin= e()), etc.=0A= =0A= > Then maybe we should target the feature at those use cases - don't call t= he=0A= > autoloader *at all* unless we know the fully-qualified name, and give up= =0A= > trying to "square the circle" by combining fallbacks with autoloading for= =0A= > unqualified names?=0A= =0A= The largest issue with that is that unqualified names are extremely common = in php 7 code.=0A= =0A= I'd considered that option, but that introduces its own surprises,=0A= which I'd consider to have more frequent and significant impact on applicat= ions that start using this.=0A= =0A= namespace NS;=0A= function f1($x) {=0A= return mb_strlen($x) + 1;=0A= }=0A= function f2($x) {=0A= return \mb_strlen($x) * 2;=0A= }=0A= =0A= Calling f2() then f1() would work, but f1() then f2() would not work, becau= se f1() wouldn't autoload.=0A= =0A= - ASIDE: I guess something along these lines would be less likely to *cause= surprises*=0A= if one implemented "autoload, but only for qualified functions outside of= the global namespace,=0A= but autoloading global functions is my main reason to want this with curr= ent code (e.g. polyfills).=