Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:17859 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 78409 invoked by uid 1010); 12 Aug 2005 06:34:21 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 78394 invoked from network); 12 Aug 2005 06:34:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Aug 2005 06:34:21 -0000 X-Host-Fingerprint: 81.169.182.136 ajaxatwork.net Linux 2.4/2.6 Received: from ([81.169.182.136:46825] helo=strato.aixcept.de) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 0F/4B-33075-CE24CF24 for ; Fri, 12 Aug 2005 02:34:21 -0400 Received: from [192.168.1.3] (dsl-082-083-240-043.arcor-ip.net [82.83.240.43]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by strato.aixcept.de (Postfix) with ESMTP id 4722635C37B; Fri, 12 Aug 2005 08:53:38 +0200 (CEST) Date: Fri, 12 Aug 2005 08:34:29 +0200 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <1688137061.20050812083429@marcus-boerger.de> To: Jessie Hernandez Cc: internals@lists.php.net In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Allow functions in namespaces? From: helly@php.net (Marcus Boerger) Hello Jessie, don't overcomplicate it, just stay with classes. marcus Friday, August 12, 2005, 5:50:08 AM, you wrote: > Right now, my patch is complete as respects classes inside namespaces, > simple import, namespace imports, etc. I just made a few changes locally to > see how feasible it was to allow functions inside namespaces, and it was > actually very simple. Like classes, the functions internally are prefixed > with the namespace name and a colon, e.g.: > namespace test_ns > { > function test_func > { > echo "hello!\n"; > } > } > test_func(); // generates an error, 'test_func' does not exist > test_ns:test_func(); // prints "hello!" ?>> > I haven't done anything with functions as regards imports, and I think it > would be difficult/useless to do so. Simple imports might be easy, but what > about namespace imports? There is no such concept as __autoload for > functions, so namespace imports for functions would be discarded. Also, if > you import foo:bar, you don't know if this is a function or a class. The > former syntax of "import function/class foo from bar" would need to be > used, and this syntax was very ugly IMHO. > So, I ask, would it be useful to have functions inside namespaces and only > use it as above? Imports would only work for classes, and the only change > would be that you can reference functions with a colon (of course, just > like classes, you cannot declare a function name with a colon, only > reference it). > Let me know what you guys think. My Beta 2 patch is working great as it is, > and I suspect the majority of the users who want namespaces is to simply > group/organize their classes anyways. > Regards, > Jessie Hernandez Best regards, Marcus