Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:54216 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 56926 invoked from network); 26 Jul 2011 19:10:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Jul 2011 19:10:44 -0000 Authentication-Results: pb1.pair.com header.from=sebastian.krebs.berlin@googlemail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=sebastian.krebs.berlin@googlemail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 209.85.215.173 as permitted sender) X-PHP-List-Original-Sender: sebastian.krebs.berlin@googlemail.com X-Host-Fingerprint: 209.85.215.173 mail-ey0-f173.google.com Received: from [209.85.215.173] ([209.85.215.173:40437] helo=mail-ey0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id ED/F2-38647-2311F2E4 for ; Tue, 26 Jul 2011 15:10:43 -0400 Received: by eyb7 with SMTP id 7so1084024eyb.4 for ; Tue, 26 Jul 2011 12:10:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=message-id:date:from:reply-to:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=biM/loIKyvfoiESfW5yb6T0N6O/b0iL4dK021bdcelk=; b=aZDrW/1QCfKez1D5BwnJVEH19PFMw12zjS3ICe7mmS+3pv8875fNIK0vP+lpXYNSx4 T9WQzlIps2HnnjPXedzQpB0r4JXsCgCU7lbvbUGMHwyd/ombUozUhwzZf3SC4PXkbDH8 JGdLz0NEgLilwIMMyLCQnd/TV21Xk5JRiZRJs= Received: by 10.204.134.196 with SMTP id k4mr150451bkt.131.1311707438836; Tue, 26 Jul 2011 12:10:38 -0700 (PDT) Received: from [192.168.24.2] (91-64-205-130-dynip.superkabel.de [91.64.205.130]) by mx.google.com with ESMTPS id i14sm126056bkd.39.2011.07.26.12.10.38 (version=SSLv3 cipher=OTHER); Tue, 26 Jul 2011 12:10:38 -0700 (PDT) Message-ID: <4E2F112D.3030702@googlemail.com> Date: Tue, 26 Jul 2011 21:10:37 +0200 Reply-To: sebastian.krebs.berlin@googlemail.com User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110617 Thunderbird/3.1.11 MIME-Version: 1.0 To: PHP internals list References: <4E2E784F.4050307@googlemail.com> <4E2E7D5F.9090908@googlemail.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Function/Constant autoloading From: sebastian.krebs.berlin@googlemail.com (Sebastian Krebs) Hi, Thanks, that looks similar to what I'm looking for. It doesn't seem, that any of the reply is really against autoloading of functions (and maybe constants), but are against the given implementations (because they are built on top of the outdated __autoload() function), what brings me back to my "overall" question: Why it doesn't exists, but autoloading of classes exists? That makes me feel, that, since classes exists, functions (and the youngest children namespace constants) are the unloved children of the multiparadigma approach. Just to make an example, what goes on in my mind: // register-autoload signature spl_autoload_register($callback, $type = SPL_AUTOLOAD_CLASS); // register an autoloader spl_autoload_register(function ($name, $type) use ($myLoader) { switch ($type) { case SPL_AUTOLOAD_CLASS: return $myLoader->loadClass($name); break; case SPL_AUTOLOAD_FUNCTION: return $myLoader->loadFunction($name); break; case SPL_AUTOLOAD_CONSTANT: return $myLoader->loadConstant($name); break; } }, SPL_AUTOLOAD_CLASS | SPL_AUTOLOAD_FUNCTION | SPL_AUTOLOAD_CONSTANT); class-only-autoloader can simply ignore the second argument `$type`, thus I don't see any BC-break. Am 26.07.2011 10:53, schrieb Ferenc Kovacs: > On Tue, Jul 26, 2011 at 10:39 AM, Sebastian Krebs > wrote: >> Hi, >> >> thanks for your reply, but I'm not talking about class loading (because >> thats already possible). I'm talking about autoloading of userspace >> functions and constants >> >> >> // /path/to/my/functions.php >> namespace my\functions; >> >> const THING = 'I am constant!'; >> >> function helloWorld () { >> echo "hello World; >> } >> >> // /path/to/some/other/file.php >> namespace foo; >> use my\functions; >> >> functions\helloWorld(); // fail! >> echo functions\THING; >> >> > > I think it's pretty clear what are you after. > autofunc with a patch: > http://www.mail-archive.com/internals@lists.php.net/msg43983.html > > __autodefine proposal and rfc: > http://www.mail-archive.com/internals@lists.php.net/msg48986.html > https://wiki.php.net/rfc/autodefine?s[]=autodefine > > from the replies I think that the idea didn't got traction from the core devs. >