Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94973 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 12287 invoked from network); 9 Aug 2016 17:44:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Aug 2016 17:44:08 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@mindplay.dk; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@mindplay.dk; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mindplay.dk from 209.85.217.195 cause and error) X-PHP-List-Original-Sender: rasmus@mindplay.dk X-Host-Fingerprint: 209.85.217.195 mail-ua0-f195.google.com Received: from [209.85.217.195] ([209.85.217.195:33246] helo=mail-ua0-f195.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CC/75-03404-8661AA75 for ; Tue, 09 Aug 2016 13:44:08 -0400 Received: by mail-ua0-f195.google.com with SMTP id u13so1574777uau.0 for ; Tue, 09 Aug 2016 10:44:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mindplay-dk.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=/QbZuK0KpskfEa1XBdh5zq6AZNHJGyrIrfo3DyrC5HE=; b=sRMr4prmHhQ78aoCNmyTFlT4w5hZLyuU4emE2p7yNI4TYCDaPwSK7Cd+75vgJNntbU ZPnFvfngphIt/mvLnHH9F8XsDTpVBmCgO/xyba2oI5OfAjfjEXKE3wtIblS3xUlmXWte l/UUP9dqFnP37vQkAVa8SJkYU1jI66CkAS9B4z/W3gdJNlHRxXN03T7sROq98YrKBL1l O4D5rL0M97VZPNPSf4OjiM/i+RO4qrKeqRH6rmLj5bpQ3vf6ZOu5Eez3Xupo+yHmtBSr RRyql+f1ijF+vXniB/jXTiIEseq/rl4eq7eYcTYTxbT6xYzNcyh9xGDRI4F9li/Y9Nx4 GgnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=/QbZuK0KpskfEa1XBdh5zq6AZNHJGyrIrfo3DyrC5HE=; b=eYd5yojyZdq9/12HJFQ+jA4PXiSs9ILwGi71ZhcbUirudMJFb1tc7y5FgVvaKamT34 1S0se9lzhxD0OrQ3IMwkyr22AHohVpht8WqyMV5UPfyPvwBgGZ+SkhGndia9L+1WGmqm Mzor3m8a8N3M+pJHsMeMQLmrYaV5TlVK3dcQGB0mO6oqLvHbbKCoBeIOFl43tPKO7Mrx 4+1k9y+/9wCUoOEBTa8tidhEk0+X1I1ppZGpM2kJzxTwcsG7DqoL+WjJ0pMQ+I9nHHbS mMjyKB2C/osKUqnymModRDnQkNLG7Wj/Sl3094JvT6ojoxXOTbImDwKM2/Qe8bsomBDy IuMA== X-Gm-Message-State: AEkoouvQMrnA0vMsbZ+dw5DFgAHal84LcxwpFVV6Mx0mMVrREDMfOH5HAfpUNFM0y2B0Bw+1P0y0lsZsfIezaA== X-Received: by 10.31.180.214 with SMTP id d205mr50594149vkf.140.1470764645447; Tue, 09 Aug 2016 10:44:05 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.153.195 with HTTP; Tue, 9 Aug 2016 10:44:04 -0700 (PDT) In-Reply-To: <615f02b9-0621-2e7a-bec9-af4e342529b2@gmail.com> References: <33781781-2a63-78c1-68a1-9e19ad720d8d@gmail.com> <1d89ec68-de5e-2670-aed1-f12872c073c3@gmail.com> <615f02b9-0621-2e7a-bec9-af4e342529b2@gmail.com> Date: Tue, 9 Aug 2016 19:44:04 +0200 Message-ID: To: Rowan Collins Cc: internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Function auto-loading From: rasmus@mindplay.dk (Rasmus Schultz) On Tue, Aug 9, 2016 at 6:17 PM, Rowan Collins wrote: >> In other words, calls to substr() does not trigger the resolve - a >> statement like "use function substr" on the other hand, does. > > Ah, I see. The problem with that is, you still have to explicitly list every > function you're going to use, so you might as well just use require_once, or > call "load_function('substr')" directly. Well, no - there is still the issue of file names and paths becoming a dependency, besides issue of having to locate the file in the first place. So there is still very much a purpose to this. Importing all classes with use-statements is good practice anyhow, and - it forces you to document at the top of your file which elements you're referencing outside of the local namespace. Of course, that's opinion, but it's a common opinion - you don't see too much code in the wild with inline qualified class references, most everyone has a leading set of use-statements in every file. Actually, now that I think of it, for that reason, I might actually be okay with only qualified references triggering auto-loading after all - this would never become an issue at all, because I'd qualify everything with use-statements anyhow. Though I do think it would be somewhat easier to *explain* this feature, if it was simply triggered by the use-statement, not by the circumstance of whether the name is or isn't qualified, because it's not always obvious from looking at the code - you'd have to look at the use-statements first and then correlate those with function-calls and figure it out, every time you look at a file. That mental overhead is eliminated by just having the use-statement trigger auto-loading. Also, come to think of it, triggering the auto-loader could still be deferred, for performance reasons, even if the use-statement is what triggers is - so it wouldn't aggressively trigger the auto-loader when the use-statement is encountered, but rather the first time the a function imported with a use-statement is called. That would be more consistent with how class resolution works. I think maybe this could work after all??