Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107994 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 92254 invoked from network); 5 Jan 2020 20:43:40 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 5 Jan 2020 20:43:40 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 288851804A8 for ; Sun, 5 Jan 2020 10:48:22 -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,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 5 Jan 2020 10:48:20 -0800 (PST) Received: by mail-wr1-f50.google.com with SMTP id w15so34704462wru.4 for ; Sun, 05 Jan 2020 10:48:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=FFvDpQGl+g+UEmj+T5VnM699htYr0lwPHxc/Z9TfB7I=; b=K773QDVUq2Mp0VdtFwkC4HFSUREj848KTFv8SsxuPpQjw2zLYobGmjiVVIGCPG06dU BmOSKSXAOGJTNP7HP8FJL65Ih5c2ilMwhHKWPV4yHvRW6QKmKWg+N5sLFQfhXnUuDGi1 Jq2z/A3zvZCULtU6UKDyEZ7/uq5nOx0tcnzm/PPaYOfR3j2wAhLbBkRn6QTbF3BJpwBS IFbVKY92pm1XmRTLvUzz8pMbhBlbaZlSnro6Xc2n3ABTFlm2RwIq3XYDEXD0d6lnzNWA 0ZpdZD9Dy71dse76GQ/mqaSq015vnRdpEUGmxjClLyTAFJ+JkjqxR96dZ42IB1nGekMg RjMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=FFvDpQGl+g+UEmj+T5VnM699htYr0lwPHxc/Z9TfB7I=; b=a2bw+/BUplCyU5qy7/n7vKd9OR+vGfHQA5S2qwmBv9xJaHSQ0EnE+rimkCCma12LhL S/PYaMyw1VHIM5xhWhzq6T7tH4AV221WOrPrsTKBOvoSC6FzqRSLbfq47/y2EM3SHKkY Y3ZT/dAJgAslgz9I2Qis6WAgrz7Ff9NMdxT364K7YyydbY6uRmRYLoNInOm3Sx+Wnukb AeTfKEjiHoG1Q1kwiE087vmFQlC39mHN8kJfxRoKWI2OLpWrFyVd8c7K9fF/MBVZHnb2 fj972945DJ6GOUXh0u+GhkiTDj1pt9xjB1Wx39aHCGsFTgHgZRzlNQMa/05j1jnoAq5X 8S4g== X-Gm-Message-State: APjAAAXuIDt0yA0bl6sj+5vVNjYfF+sQeV1d5/PU4qOSToCd2HEs62dd wAihOjDvcltjJbdpVJ3ABA+EdnQf X-Google-Smtp-Source: APXvYqxafy3Sa9uDROFQBI4p+JwK04vj5+gCpvKRRDBfPQux7Y8hAr/ThRhZcfr7Nc1SmzyD2mrtsQ== X-Received: by 2002:a5d:4085:: with SMTP id o5mr97567168wrp.321.1578250099514; Sun, 05 Jan 2020 10:48:19 -0800 (PST) Received: from [192.168.0.14] (cpc84253-brig22-2-0-cust114.3-3.cable.virginm.net. [81.108.141.115]) by smtp.googlemail.com with ESMTPSA id u18sm68439925wrt.26.2020.01.05.10.48.18 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 05 Jan 2020 10:48:18 -0800 (PST) To: "internals@lists.php.net" References: Message-ID: <97a60300-6041-5ce0-e509-91657235650a@gmail.com> Date: Sun, 5 Jan 2020 18:48:16 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [PHP-DEV] Autoloading functions/consts without a performance impact From: rowan.collins@gmail.com (Rowan Tommins) On 05/01/2020 18:03, tyson andre wrote: >> Yes, I'm saying that the autoloader should be called for each lookup, so >> autoloading of Foo\strlen should come between checking if Foo\strlen is >> defined, and checking if \strlen is defined. > That would be the intuitive approach for a language, > but as mentioned earlier, > it would significantly harm performance of existing code for php 7 > (slightly without an autoloader, more with autoloaders), > and I can't imagine that getting approved. Yes, I'm fully aware of the downsides. I just think relaxing that constraint would lead to a horribly confusing language. > I'd considered that option, but that introduces its own surprises, > which I'd consider to have more frequent and significant impact on applications that start using this. > > namespace NS; > function f1($x) { > return mb_strlen($x) + 1; > } > function f2($x) { > return \mb_strlen($x) * 2; > } > > Calling f2() then f1() would work, but f1() then f2() would not work, because f1() wouldn't autoload. True; again, it violates the user's expectation, which I think can be summed up this way: - The autoloader for a function should run the first time that function would run if it was pre-defined. That in turn stems from an even more fundamental expectation: - An application using an autoloader should behave the same as one which defines all functions in advance. The more I think about it, the more I think we should just be optimising for the case where everything *is* defined in advance. As far as I know, PHP's autoloading is an anomaly among programming languages, and maybe it has outlived its usefulness. Regards, -- Rowan Tommins (né Collins) [IMSoP]