Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:54616 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2555 invoked from network); 15 Aug 2011 07:54:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Aug 2011 07:54:12 -0000 Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.42 as permitted sender) X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.218.42 mail-yi0-f42.google.com Received: from [209.85.218.42] ([209.85.218.42:37550] helo=mail-yi0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CC/B0-31518-1A0D84E4 for ; Mon, 15 Aug 2011 03:54:09 -0400 Received: by yie19 with SMTP id 19so3410967yie.29 for ; Mon, 15 Aug 2011 00:54:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=wD4VYCvx2Bj4IFIBTRQc7DeWrcRI+uVxJWs/nB6g8m8=; b=AzCyaWn6Fy1wspBZNX6iCH1mGrcXLf8bVm6s4k4XjxjnKiGgXPb/JkonCTyrqwbusv fN1MhIIOoxMchF/TehKHwG2leMrDj6UIg4y4PPnNe5qA0leL4FDlD+gbU/AF3w4TC7PK SkqSYeBbSSI2vTnGJhpTmuAz7QaOFO8uJqPRg= MIME-Version: 1.0 Received: by 10.236.154.42 with SMTP id g30mr4519297yhk.236.1313394846391; Mon, 15 Aug 2011 00:54:06 -0700 (PDT) Received: by 10.146.168.9 with HTTP; Mon, 15 Aug 2011 00:54:06 -0700 (PDT) In-Reply-To: References: <4E481136.3090508@sugarcrm.com> <4E483284.4010100@googlemail.com> <4E4838E1.3000006@sugarcrm.com> <4E48430D.6070409@googlemail.com> <4E486A50.4010700@sugarcrm.com> <4E48A22E.1040900@googlemail.com> <4E48AD3E.6010801@sugarcrm.com> <4E48C126.50707@sugarcrm.com> Date: Mon, 15 Aug 2011 09:54:06 +0200 Message-ID: To: Sebastian Krebs Cc: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] Function autoloading through spl_autoload* From: tyra3l@gmail.com (Ferenc Kovacs) On Mon, Aug 15, 2011 at 9:15 AM, Sebastian Krebs wrote: > 2011/8/15 Stas Malyshev > >> Hi! >> >> >> On 8/14/11 11:21 PM, Sebastian Krebs wrote: >> >>> I already made an suggestion [1], that bypass this. >>> >> >> That suggestion means you can not autoload namespaced function that >> overrides global function. Major WTF. > > > Imo overriding built-in functions is a WTF... Confusing others by changin= g > the behaviour of well-known functions just sounds scary. > Stas was referring to the fact that namespaces already provides this kind of monkey-patching, of course this won't work language constructs (which is a big wtf for most users in it's own way). > However, when you really want to do this, than you can load your function= s > like before > > >> Also leads to two autoload calls (one most probably resulting in exhaust= ive >> include path search) when autoloading a non-namespaced function. Pretty = bad >> idea IMO. my idea was something similar what Sebastian suggested, to call the autoloader twice, but now I think that the best way would be to: 1, we check that the function exists in the current namespace 2, call the autoload callbacks with the absolute name (foo\bar\baz). 3, we check that the function exists in the global namespace this would of course mean that for every occasion when you forgot to put the \ for your global function calls your autoloader gets called, but that's a bad practice, and I really hope that the namespace fallback will be deprecated/removed in future versions. it had a nice promise: you can use namespaces without rewriting your whole application, but with the current implementation, thats simply not true_ - you have to put your namespace declaration into every file, included files won't inherit that. - you can't use the classname type constructors in namespaced code. so this is a valid concern, but I still think that the people who would use this feature could still live with either of the proposed solutions. I know that the bad decisions in the past won't count in this argument, but the current "namespace resolution falls back to the global namespace" is the one to blame for this shortcoming. --=20 Ferenc Kov=C3=A1cs @Tyr43l - http://tyrael.hu