Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:40370 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 23061 invoked from network); 8 Sep 2008 19:09:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Sep 2008 19:09:59 -0000 Authentication-Results: pb1.pair.com header.from=jochem@iamjochem.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=jochem@iamjochem.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain iamjochem.com from 194.109.193.121 cause and error) X-PHP-List-Original-Sender: jochem@iamjochem.com X-Host-Fingerprint: 194.109.193.121 mx1.moulin.nl Linux 2.6 Received: from [194.109.193.121] ([194.109.193.121:49686] helo=mx1.moulin.nl) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8F/0A-13670-68875C84 for ; Mon, 08 Sep 2008 15:09:59 -0400 Received: from localhost (localhost [127.0.0.1]) by mx1.moulin.nl (Postfix) with ESMTP id ECCA6286D73; Mon, 8 Sep 2008 21:09:53 +0200 (CEST) X-Virus-Scanned: amavisd-new at moulin.nl Received: from mx1.moulin.nl ([127.0.0.1]) by localhost (mx1.moulin.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kQ-vIpFThRDF; Mon, 8 Sep 2008 21:09:48 +0200 (CEST) Received: from [10.0.13.104] (ip129-15-211-87.adsl2.static.versatel.nl [87.211.15.129]) by mx1.moulin.nl (Postfix) with ESMTP id 0C854286CA1; Mon, 8 Sep 2008 21:09:42 +0200 (CEST) Message-ID: <48C57877.6060400@iamjochem.com> Date: Mon, 08 Sep 2008 21:09:43 +0200 User-Agent: Thunderbird 2.0.0.16 (Macintosh/20080707) MIME-Version: 1.0 To: Stanislav Malyshev CC: Elizabeth M Smith , internals@lists.php.net References: <486FA5FB.1000300@php.net> <48C55855.4080602@zend.com> <48C5624A.1040901@zend.com> <48C56743.2060706@zend.com> <48C56DDF.3060301@iamjochem.com> <48C57296.6020200@zend.com> In-Reply-To: <48C57296.6020200@zend.com> X-Enigmail-Version: 0.95.6 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: towards a 5.3 release From: jochem@iamjochem.com (Jochem Maas) Stanislav Malyshev schreef: > Hi! > >> for the same reason you would want it with classes?? because you can >> do it with classes, no? and that seems acceptable to you, no? then >> functions >> should have the same privilege. > > Functions and classes are rather different things. Class represents, as > you know, group of data and behavior, function is much smaller. You have > maybe two dozens of built-in classes in PHP that reside in global space, > and many of them (like SPL) can be moved out relatively easily to own > namespaces. You have hundreds, if not thousands, of internal functions, > most of them can't be moved anywhere. So having functions imported into > global space is much less useful and much more dangerous than the same > for classes. guns are dangerous yet they are sold by the bucket load. either don't sell guns or let people decide how to use them, don't sell'em then dictate that they can't pull the trigger. > It is also much less useful from one more perspective - when you import > a class, you get a bunch of functions which represent functionality > unit. With single function you probably get only a small piece, so if > you use a library you probably have dozens of functions there. If you > think importing all of them into global space through "use" is a good > idea, I think you need to do some refactoring there. I won't be using namespaces in 'real life' code at all. I've never encountered a symbol clash on a class, function or constant in my code and the day I do I'll rename, search and replace to fix it ... as it stands namespaces offer me nothing but obtuse abstraction, increased code brittleness and general stress ... I can do without that lot, which is a pity because conceptually namespaces are a good idea, I'd love to be able to reduce my symbol pollution in the global scope and logically 'package' various functionality inside some a defined space. > It would grow to be > unmaintainable rather fast. I'd recommend putting them into a namespace > (if for some reason you have classes) and then just use Utility::func() I'm sorry is that a function in namespace Utility or a static method of class Utility? > - it's really not that bad. no it really is that bad, namespaces as they stand have merely moved the goalposts of symbol clashing somewhat whilst at the same time making code less understandable when reading/auditing [php] source code (e.g. load order dictating what exactly will be instantiated, the function-or-static-method WTF). I understand your concerns about performance, of course namespaces need to be performant in order to be truly usable in production BUT clear, usable functioning needs to take priority before performance is considered ... otherwise your putting the horse before the cart so to speak. Elizabeth and Greg have both stipulated the issues clearly - they need to be tackled or you will end up with something that is going to make the language less usable and not more so. as it stands now prefixing class names with a project specific string and using abstract classes to fake namespacing of functions is still a more usable way to go than implementing namespaced code. I don't supposed that's the intention?