Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:41736 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 24318 invoked from network); 6 Nov 2008 18:33:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Nov 2008 18:33:50 -0000 Authentication-Results: pb1.pair.com header.from=sv_forums@fmethod.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=sv_forums@fmethod.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fmethod.com from 69.16.228.148 cause and error) X-PHP-List-Original-Sender: sv_forums@fmethod.com X-Host-Fingerprint: 69.16.228.148 unknown Linux 2.4/2.6 Received: from [69.16.228.148] ([69.16.228.148:52978] helo=host.fmethod.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0B/D0-44653-D8833194 for ; Thu, 06 Nov 2008 13:33:50 -0500 Received: from [83.228.56.37] (port=1322 helo=pc) by host.fmethod.com with esmtpa (Exim 4.69) (envelope-from ) id 1Ky9fu-0001lS-9R for internals@lists.php.net; Thu, 06 Nov 2008 12:33:46 -0600 Message-ID: <91597FF883CD4BA3861A5C72134BCA56@pc> To: References: <4EA88C3A8A2747989925A5D21448FCE7@pc> <491333F2.5070105@zend.com> Date: Thu, 6 Nov 2008 20:33:33 +0200 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="windows-1251"; reply-type=response Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5512 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - host.fmethod.com X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - fmethod.com Subject: Re: [PHP-DEV] Call it: allow reserved words in a class or not? From: sv_forums@fmethod.com ("Stan Vassilev | FM") > Hi! > >> As you know, with the new convention, the parser will not encounter >> T_STRING "Zend\Validate\Interface" but rather: > > With namespaces, class name would not be Zend\Validate\Interface. Having > namespaces, it would make much more sense to make last component a > descriptive name, so you won't have code like this: > > if($object instanceof Interface) { // wtf am I checking here? > ... > > As for how exactly that descriptive name should look - I guess each > framework's developers that plan to support namespaces think about it hard > right now. I know ZF developers do :) Hi, Fully agreed. Though since we (PHP users) will all be using namespaces together, it makes much more sense that we have a paradigm, recommendation for namespace usage that all frameworks will follow. Maybe the ZF, Agavi, CI, CakePHP etc. authors should get together and craft a single recommendation list for people to use. It's not just a matter of consistency, it's a matter of makming the language work well with the recommended scenario and use patterns of namespaces. Two things are obvious: 1) What worked with underscores won't work with namespaces. 2) What scenario above with "instanceof Interface" isn't very likely. Why? Well imagine you want to use 5 classes in namespace foo\bar, called A, B, C, D, E (ex. foo\bar\A). In most any language with packaging system, to flatten the space you simply do this: use foo\bar\*; $a = new A(); $b = new B(); ... In PHP, due to lack of packaging system and knowledge of the user resources at parse time, instead we're painfully explicit: use foo\bar\A; use foo\bar\B; use foo\bar\C; use foo\bar\D; use foo\bar\E; $a = new A(); $b = new B(); Which makes this usage pattern with aliases much more likely to see: use foo\bar as fb; $a = new fb\A(); $b = new fb\B(); So your example above would rather be: use Zend\Validate as ZV; ... instanceof ZV\Interface; And this is why it's worth it to arrive at a single list of recommendations for namespace usage, and see what works there and what might not work, and tweak the language for it. Regards, Stan Vassilev