Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107978 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 52883 invoked from network); 3 Jan 2020 17:35:14 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 Jan 2020 17:35:14 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7A9E2180540 for ; Fri, 3 Jan 2020 07:39:25 -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,HTML_MESSAGE, 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-il1-f172.google.com (mail-il1-f172.google.com [209.85.166.172]) (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 ; Fri, 3 Jan 2020 07:39:18 -0800 (PST) Received: by mail-il1-f172.google.com with SMTP id x5so36881099ila.6 for ; Fri, 03 Jan 2020 07:39:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=UhFM8IVqOl0g3ihmRSQpLAJT4qxSaLskmKFGA8idFTg=; b=n6MCe4jErPWaryFEPdxnox3zVxWFTtdE+G2noYqnEXfxF+1g8UG9pI5iDbznF2XnSy T/Dx3yFAs30McnSyHC8whiQJ6UbfE7qB4q/litYHo6HksV4DF8S6l2CRV6DFURErhgqY YbMolEjf6zLSYA/2Uwzoi352WJR1I5RgR8tdmRwTq1c0xxJUrT1/tXHTJ8ihGC21T7b/ JEnbbNJoEx353FakpGZMasbxsCDenpI2SJO+//pdgiEiz5O3r81a908NFMq8eKaMoQvm HsaTqChKuD3bccN/uZn/o0eaU9OZ93aLpSsgcjdoDEX56rT4d4e+2VVDdFYSIRTmQElG 5MsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=UhFM8IVqOl0g3ihmRSQpLAJT4qxSaLskmKFGA8idFTg=; b=QRegPyUVRXsHxJ6yVx59d/5MUlDclJn0vmcklPSUO5kiSylAKxpx1rq0f7abhlU2uh 3fftf0I+RZJz796pLV28IwL/+rwPH0Zs4mRnKkS/FfW6kR7tDMbE0JkHz0P2jRAED5j6 71lTWgomoiJxt5lEn+ESClr6bv1iUe8C+L/Fp7EAx+h2lZyegOc2EsWY+yjA2jc0YMhr 7dsJpGYv4kvjYF+y89eRiNwpRvreRQS5fxho//uaX9xr7Zj+3YZ/W+IuCTQ5Last5xf1 KQfGtvx1gMtvHSoVoPJACP4mORH9IAEGLKvHdeVn43zGJ4uPO+0OJ+jNa90FFGMvm6ca z2Xw== X-Gm-Message-State: APjAAAWYaP9XR+GC9Hm9V6i1G+DbKDAnAYJYKJHupDzaVjKm5vw9dP9d X2zykZ2MNViPaTZxdu1tzychkH5g1+o8sQEWThiSglQV X-Google-Smtp-Source: APXvYqxcdMp3RXl1Os8b+Isz4d27G9epsPdOA4hbVkxpZW/JDLTpDWh4CWkQNRtlKWwPWHkcKXj5bVlNXI+XMRgnjyw= X-Received: by 2002:a92:1f16:: with SMTP id i22mr78093215ile.206.1578065957335; Fri, 03 Jan 2020 07:39:17 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 3 Jan 2020 15:39:06 +0000 Message-ID: To: "internals@lists.php.net" Content-Type: multipart/alternative; boundary="000000000000d1b84f059b3e1ca5" Subject: Re: [PHP-DEV] Autoloading functions/consts without a performance impact From: rowan.collins@gmail.com (Rowan Tommins) --000000000000d1b84f059b3e1ca5 Content-Type: text/plain; charset="UTF-8" On Fri, 3 Jan 2020 at 15:21, tyson andre wrote: > > Now the behaviour of my program can completely change depending on which > of > > those functions I call first, which might even depend on user input. > > Regardless of exactly how the cache works, that kind of unpredictability > is > > a recipe for disaster. > > It already does completely change depending on user input, without > autoloading, in the same way. > Not really, the only way you could have the same dependency on call order at the moment would be if it looked like this: namespace Foo; function one() { echo strlen('hello'); } function two() { require_once 'functions/Foo/strlen.php'; } At that point, it's pretty obvious that you're conditionally including a definition, which is not the case with the original example. > I assume you're arguing against autoloading without autoloading \NS\strlen > every time > 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. > > > The only way to make it predictable again is to pre-define the namespaced > > function in my startup code, at which point I don't need function > > autoloading. > > Other use cases would benefit from function autoloading, though. Then maybe we should target the feature at those use cases - don't call the autoloader *at all* unless we know the fully-qualified name, and give up trying to "square the circle" by combining fallbacks with autoloading for unqualified names? Regards, -- Rowan Tommins [IMSoP] --000000000000d1b84f059b3e1ca5--