Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:33709 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13033 invoked by uid 1010); 5 Dec 2007 01:52:32 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 12987 invoked from network); 5 Dec 2007 01:52:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Dec 2007 01:52:31 -0000 Authentication-Results: pb1.pair.com smtp.mail=stas@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=stas@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 212.25.124.162 as permitted sender) X-PHP-List-Original-Sender: stas@zend.com X-Host-Fingerprint: 212.25.124.162 mail.zend.com Windows 2000 SP4, XP SP1 Received: from [212.25.124.162] ([212.25.124.162:19529] helo=mx1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 27/85-10080-85406574 for ; Tue, 04 Dec 2007 20:52:29 -0500 Received: from us-ex1.zend.com ([192.168.16.5]) by mx1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 5 Dec 2007 03:52:17 +0200 Received: from [192.168.16.91] ([192.168.16.91]) by us-ex1.zend.com with Microsoft SMTPSVC(6.0.3790.1830); Tue, 4 Dec 2007 17:52:14 -0800 Message-ID: <4756044D.5000803@zend.com> Date: Tue, 04 Dec 2007 17:52:13 -0800 Organization: Zend Technologies User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: Steph Fox CC: Gregory Beaver , Derick Rethans , PHP Developers Mailing List References: <4755E492.2080906@chiaraquartet.net> <4755FD27.3030802@zend.com> <064401c836de$e49dde10$e6dfc350@foxbox> In-Reply-To: <064401c836de$e49dde10$e6dfc350@foxbox> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 05 Dec 2007 01:52:14.0253 (UTC) FILETIME=[753CF5D0:01C836E1] Subject: Re: [PHP-DEV] Re: RFC: Dropping Namespace From: stas@zend.com (Stanislav Malyshev) > sense again. But Stas, consider (old dialect bc I need to update locally > sorry): > > import nstest::test as whatever; > > This works in the global space, right? Now along comes, say, Pierre or Right. > Derick or Marcus with this class they just have to add to an existing > (non-namespaced) core extension, and the obvious and perfect name for > this class happens to be 'whatever'. I upgrade PHP and suddenly I start > seeing Right again. The thing is this problem can not be solved. You can not both put all your classes into global namespace and expect them never to clash even when you name two of them by the same name. That's like you would talk in a language where all words would be "marklar" and expect me to understand you :) So what we can do is to avoid getting into such problem by using some rules. I'd propose these rules: 1. Namespace your libraries 2. Do not import the class name into global space, but only library name. Meaning, if your class is nstest::test, there's nothing wrong with saying just so, if you are concerned about clashes. That's not worse than you has nstest_test previously. But if you had PEAR::DB::Connection and PEAR::DB::Connection::Data and PEAR::DB::Connection::Exception and PEAR::DB::Query::Term and PEAR::DB::Query::Result, then you could do: use PEAR::DB as myDB; use PEAR::DB::Query as myQuery; and you'd have to do much less work: just myQuery::Term and myQuery::Result. > Now sure, I can fix that. I can search and replace all my instances of > 'whatever' in my code. How is that different from what we had before? If you insist on putting everything into globals space - it won't be. We just give you the option of not doing it. > Greg would say I should've namespaced this file, I know... but it's > possible to use import (OK, 'use' now) in the global space, so how are > you going to prevent people from doing that? I can't. I can only hope they would do it right, I can't force them to do it right :) -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com