Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61731 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 40066 invoked from network); 25 Jul 2012 02:42:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Jul 2012 02:42:42 -0000 Authentication-Results: pb1.pair.com smtp.mail=reeze.xia@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=reeze.xia@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.42 as permitted sender) X-PHP-List-Original-Sender: reeze.xia@gmail.com X-Host-Fingerprint: 209.85.160.42 mail-pb0-f42.google.com Received: from [209.85.160.42] ([209.85.160.42:60346] helo=mail-pb0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 16/08-27263-12D5F005 for ; Tue, 24 Jul 2012 22:42:41 -0400 Received: by pbbrp12 with SMTP id rp12so663260pbb.29 for ; Tue, 24 Jul 2012 19:42:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:message-id:in-reply-to:references:subject:x-mailer :mime-version:content-type; bh=ju7o0BrqZY0X4YPzu5fsr0qFINLq+qKUHDTbQct/rbA=; b=VqNCvGUcdgEi4/npAlAjIaGZQWzL/tffSEpkgrAwMYsHflO3nH4kdEIly5Jw+/naZN kYvkAYmokc6XylLQ/4Ou6NG8EVU2vh1YLIKI03df0TM21einGmRE1Wlwj2qrGBMMmTI6 r0erOoEuylSO1XFuZ8JMLu6GuRYlEPWZRLGe87M7HxWrmCeo49EJxshAAAcXCmBMxZEd 4X4eSbbXTr8TkFp6gm9Q0eVy7Xh4eaOTg+9E+IDmtK31Lqawqe8dTSJnVaZ8DQmBMn70 y7pF+qxG3AkyXYpX60OyO7V3b/+W2Dxh/sMIesjFlsSo5Oz4x/IM6XzjqWk18ug5Cat4 1dDA== Received: by 10.68.238.166 with SMTP id vl6mr26715059pbc.96.1343184158735; Tue, 24 Jul 2012 19:42:38 -0700 (PDT) Received: from [172.22.234.186] ([61.135.169.76]) by mx.google.com with ESMTPS id gf3sm5063276pbc.74.2012.07.24.19.42.34 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 24 Jul 2012 19:42:37 -0700 (PDT) Date: Wed, 25 Jul 2012 10:43:33 +0800 To: Stas Malyshev Cc: PHP Internals Message-ID: <76992170DA45492DAD9EFFEBC4F791B9@gmail.com> In-Reply-To: <500EEA67.8060100@sugarcrm.com> References: <933A547D13294D10A802336D74E42DFE@gmail.com> <500EEA67.8060100@sugarcrm.com> X-Mailer: sparrow 1.6.3beta (build 1165) MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="500f5d55_62548fd8_d5f9" Subject: =?utf-8?Q?=E5=9B=9E=E5=A4=8D=EF=BC=9A_?=[PHP-DEV] [RFC] Proposal namespace importing with from syntax From: reeze.xia@gmail.com (Reeze Xia) --500f5d55_62548fd8_d5f9 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi Stas, =20 =E5=9C=A8 2012=E5=B9=B47=E6=9C=8825=E6=97=A5=E6=98=9F=E6=9C=9F=E4=B8=89=EF= =BC=8C=E4=B8=8A=E5=8D=882:33=EF=BC=8CStas Malyshev =E5=86=99=E9=81=93=EF=BC= =9A > Hi=21 > =20 > > from GlobalNamespace=5CSubSpace=5CThirdSace use Class1, Class2 as Ali= as2, =46orthSpace=5CClass3 as Alias3; > =20 > I'm not sure it's necessary. If you import a real lot of the classes > from the same namespace, just import the parent namespace. And this > =20 > =20 No, we can not import namespace directly for now : <=3Fphp namespace A =7B class B =7B=7D =7D namespace =7B use A; var=5Fdump(new B()); =7D Warning: The use statement with non-compound name 'A' has no effect in /U= sers/reeze/Opensource/php-test/php-src-master/a.php on line 7 if we wan to archive the goal of import anything. the only way is to decl= are the current namespace =20 as =22the parent namespace=22 we want to import from, eg: <=3Fphp namespace Zend =7B class B =7B=7D =7D namespace *Zend* =7B var=5Fdump(new B()); =7D but this is not preferred for use code declared as the library we used. > syntax makes less clear what is the true name of Class2 and also by > similarity to python syntax would lead people to think it does the same= > thing python one does - which it is not. > =20 > =20 Sorry, I didn't make myself clear. the example I posted is not correct. I= t didn't have to alias the imported classes. 'use' statement can alias the imported class too, the proposed 'from xx u= se yy' is almost =20 the same as 'use' The correct example should be: <=3Fphp // if we don't want to duplicated then the follow could be use GlobalNamespace=5CSubSpace=5CThirdSpace=5CClass1; use GlobalNamespace=5CSubSpace=5CThirdSpace=5CClass2; use GlobalNamespace=5CSubSpace=5CThirdSpace=5CClass3; // reduced to from GlobalNamespace=5CSubSpace=5CThirdSace use Class1, Class2, Class3 ; =3F> and if we need alias we could=EF=BC=9A <=3Fphp // reduce =20 use GlobalNamespace=5CSubSpace=5CThirdSpace=5CClass1; use GlobalNamespace=5CSubSpace=5CThirdSpace=5CClass2 as Alias2; use GlobalNamespace=5CSubSpace=5CThirdSpace=5C=46orthSpace=5CClass3 as Al= ias3; // to from GlobalNamespace=5CSubSpace=5CThirdSace use Class1, Class2 as Alias2,= =46orthSpace=5CClass3 as Alias3; =3F> Thanks stas. > =20 > =20 > -- =20 > Stanislav Malyshev, Software Architect > SugarCRM: http://www.sugarcrm.com/ > (408)454-6900 ext. 227 > =20 > =20 --500f5d55_62548fd8_d5f9--