Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94969 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2858 invoked from network); 9 Aug 2016 16:05:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Aug 2016 16:05:35 -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.170 cause and error) X-PHP-List-Original-Sender: rasmus@mindplay.dk X-Host-Fingerprint: 209.85.217.170 mail-ua0-f170.google.com Received: from [209.85.217.170] ([209.85.217.170:36798] helo=mail-ua0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B8/D3-03404-D4FF9A75 for ; Tue, 09 Aug 2016 12:05:34 -0400 Received: by mail-ua0-f170.google.com with SMTP id 97so26956160uav.3 for ; Tue, 09 Aug 2016 09:05:33 -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=AIXWmh1mmc773eNuYOcSC7yChTkP0Vwi8LSNdV7kDoc=; b=16trm5eDjU57jC7sFLZKw8l1ys8jg2tcadEB1+3UeXYgHjTKsGGH7iffnWNqjEKUDP P4dgp6qOWvgWZaWzckeYNjYE9zvuMXILQ6D7UUyk6qluSGVhIO61RjxDBr8e1uDuvZFB Teg8PCOLBoR3HfIGZuLuZN5JWy21gWsAcqx8dhP/Nyjeotf20iU6pRvZ+EcuEPbxlGbJ WizIibVxsNQ6WgUw/zrbJQZ1u6dBh0kY+uzavIQOAHSSCbzUO12wDMdp77VMOmKnkJ6Z 6c/m31gyBI9P6ibE81pzMV87QSS/OatcG50zADUf87Rmx6RwffrWgyi/2BH180E/yxUH 1uKA== 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=AIXWmh1mmc773eNuYOcSC7yChTkP0Vwi8LSNdV7kDoc=; b=l7zBcyxlz26aDJdlQrULOydhtiGpILDwnHQmWuU8ABP/gk3PpnJoxAG+yZsveWPyMF WPKdWLYdvKcmqOmly28n+n/+SQH6eHaeyTloR15CAprYk3/80l2PyU4NMCqogGHfEbIN LnJuVfrGaI4DU5diAEUi65Gc7L15eEiUNjhdDg3tPGW4nmAzElrTefWbbMMsXQ7aWC90 QvLNVudsxpuDQ/V6F/W245mAMjQWgYV0K/MhCBZW+qQyRuoUXboxgvt4uOZxB0OOcETO KJlJaIQBT03XNwVfQVrq2aiaxsiGZgkCRFtbq7gqvGSexhCXvzTARoPBNh1uyebLtm1M Ui5A== X-Gm-Message-State: AEkooutqibc7F9m22VnhQ4kqyy6Nv05IdTyo1iPQWwKTQDQd1TvLOInKhTWglsGVOOqOsyF7So/JFFsii8RtSA== X-Received: by 10.31.6.18 with SMTP id 18mr51138186vkg.43.1470758729757; Tue, 09 Aug 2016 09:05:29 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.153.195 with HTTP; Tue, 9 Aug 2016 09:05:28 -0700 (PDT) In-Reply-To: References: <33781781-2a63-78c1-68a1-9e19ad720d8d@gmail.com> <1d89ec68-de5e-2670-aed1-f12872c073c3@gmail.com> Date: Tue, 9 Aug 2016 18:05:28 +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 12:04 AM, Rowan Collins wrote: > I don't quite follow what you're suggesting here. When does this "function > resolver" get called? I'm suggesting the use-statement be the trigger, rather than actually calling the function. In other words, calls to substr() does not trigger the resolve - a statement like "use function substr" on the other hand, does. > Why does returning a callable rather than just > defining the function help with the problems we've been discussing? For some reason, at the time, I thought, this way the function would indicate whether it resolved a request for "foo\bar" as "foo\bar" or "bar", but that's probably false... likely the registered function would get called twice by the engine, first trying for the namespaced, then if that doesn't resolve, for the global function. > we need "namespace > autoloading", which in practice means autoloading any of the items you can > put in a namespace. Good point. So maybe what I'm really proposing is just simply a change to functionality - so that function and constant references do not trigger auto-loaders, but instead the "use const" and "use function" statements do. I guess this deviates from the way auto-loading works for classes, too - just in a different way... so maybe it's not much better. Come to think of it, maybe it's worse, because this would aggressively trigger auto-loading for functions that might never get called, so, hmm... I think, in practice, it's not going to work much differently from the other proposed work-around though - if only qualified references trigger auto-loading, then this would trigger auto-loading: \foo\bar(); And this would too: use foo\bar; bar(); But this would not: bar(); And that could get pretty confusing, since the unqualified call site looks identical to the qualified call site. Ugh. Well, I guess this is what lead to a discussion about a breaking change to the name resolution rules? Is there an RFC detailing that idea? Or what was the title of that discussion? I'd like to read up.