Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51173 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16729 invoked from network); 31 Dec 2010 20:53:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Dec 2010 20:53:12 -0000 Authentication-Results: pb1.pair.com smtp.mail=smalyshev@sugarcrm.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=smalyshev@sugarcrm.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sugarcrm.com designates 207.97.245.143 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 207.97.245.143 smtp143.iad.emailsrvr.com Linux 2.6 Received: from [207.97.245.143] ([207.97.245.143:48560] helo=smtp143.iad.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7B/D0-10838-6B24E1D4 for ; Fri, 31 Dec 2010 15:53:11 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp44.relay.iad1a.emailsrvr.com (SMTP Server) with ESMTP id 96B3B12891C; Fri, 31 Dec 2010 15:53:08 -0500 (EST) X-Virus-Scanned: OK Received: by smtp44.relay.iad1a.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id 04E52128917; Fri, 31 Dec 2010 15:53:07 -0500 (EST) Message-ID: <4D1E42B3.1050508@sugarcrm.com> Date: Fri, 31 Dec 2010 12:53:07 -0800 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7 MIME-Version: 1.0 To: Nicolas Grekas CC: "internals@lists.php.net" References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] RFC - Namespace initializers From: smalyshev@sugarcrm.com (Stas Malyshev) Hi! > About namespaced functions and constants, the fact that they are not > autoloaded makes them useless for any code that wants some good > packaging. For example I looked at the Doctrine2 code, and (tell me if This is not true. You can always load stuff manually - in fact, many languages don't have any autoloading at all and are just fine. > I also have a second strong grief against namespaced functions and > constants : due to their at runtime namespace resolution, static code > analysis is now very hard, even impossible in the general case! It is In general case, it always was so. Think of $foo->$bar() - what is being called? > So, my first proposal for namespaced functions and constants is : > 1. Remove namespaced functions and constants at all - promote > namespaced public static methods and class consts instead. This won't happen, for obvious BC reasons. Please re-read the discussions on the list about namespaced functions to know what are reasons for their existence. > 2. At runtime, when a namespaced identifier is used (lets say > \my\sub\ns\class_interface_constant_or_function), take the namespace > part of the identifier and if any, autoload it as if it were a class, > do not generate any error if the given class name is not found. (ie, > trigger something like class_exists('my\sub\ns', true);). Autoloading for functions/constancs don't seem to have enough benefit to justify the complications. As for classes, you can always make you autoloader do anything you want with the name it receives. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227