Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61737 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 57532 invoked from network); 25 Jul 2012 06:43:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Jul 2012 06:43:10 -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:36302] helo=mail-pb0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 01/CA-27263-C759F005 for ; Wed, 25 Jul 2012 02:43:09 -0400 Received: by pbbrp12 with SMTP id rp12so978196pbb.29 for ; Tue, 24 Jul 2012 23:43:05 -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=USC47YmHPLOFUaahZDqKgOsJJD7gmOg0xHEb6CP24jQ=; b=Cj87rWcqEomYMM3SslIKNSBhZWH43totjL+ucT/4EiZAM3lyGb+FYfH4VI8Hgu6vqA aPT8vXQXfifIMFJypte3daiTDHXYpEQAB6sp2dDRIJRgNinsNssdkX/IVgibO4NRaTa5 5qr5su8gE/0BZkGnBDacftH7+o8d75pwoIPE2QB0vWvQQb7tvNHrs3v3n3SDd8NDY+vK DedgmVIyLxrNg69KuZw+BUdQ0tbepr2OUJ4+Otn1RK0UK9AyDREgp3buT02RF9c7iqg+ L/MnUdHOekfSueNcZQKF1elTj1bTw2XMTPMdFcZGUXYuOEfVPztqn5xVyFB02TLqDQj5 1vzA== Received: by 10.68.238.68 with SMTP id vi4mr50671884pbc.123.1343198585231; Tue, 24 Jul 2012 23:43:05 -0700 (PDT) Received: from [172.22.234.186] ([61.135.169.76]) by mx.google.com with ESMTPS id oo6sm13760866pbc.22.2012.07.24.23.43.01 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 24 Jul 2012 23:43:04 -0700 (PDT) Date: Wed, 25 Jul 2012 14:43:58 +0800 To: Laruence Cc: Stas Malyshev , PHP Internals Message-ID: <4437FDA5E11542ECA9CAE622B6070F32@gmail.com> In-Reply-To: References: <933A547D13294D10A802336D74E42DFE@gmail.com> <500EEA67.8060100@sugarcrm.com> <76992170DA45492DAD9EFFEBC4F791B9@gmail.com> <500F82AB.30508@sugarcrm.com> X-Mailer: sparrow 1.6.3beta (build 1165) MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="500f95ae_327b517e_e1f3" Subject: =?utf-8?Q?=E5=9B=9E=E5=A4=8D=EF=BC=9A_?=[PHP-DEV] Re: =?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) --500f95ae_327b517e_e1f3 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi, =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=8B=E5=8D=881:27=EF=BC=8CLaruence =E5=86=99=E9=81=93=EF=BC=9A= > Hi: > =20 > is there any really usage=3F I didn't see before. I don't think every Yes, eg: https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/O= RM/EntityRepository.php=23L24 it could be: from Doctrine=5CCommon=5CCollections use ExpressionBuilder, Criteria, Arr= ayCollection, ExpressionBuilder; The Motivation is that I found many projects that use namespace have the = problem of repeat type the same namespace again and again. =20 > python feature is proper for PHP. PHP is not python. > =20 > =20 I think it could be useful to reduce duplication, but not copy everything= from Python. like many useful features we borrowed from other languages ;-) > =20 > -1 on this R=46C > =20 > +1 for Stas > =20 > and one more thing, BC break. Yes, introduce new features may break things, eg the new trait,insteadof = in 5.4, and maybe =20 the comming finally, yield etc. but if it is desired, I think it may wort= h it. =20 Thanks for your feedback=21 > =20 > there are many ORM or DB warpper libraries defines =60from=60 method, l= ike: > =20 > =24db->select()->from(); > =20 > thanks > =20 > On Wed, Jul 25, 2012 at 1:22 PM, Stas Malyshev wrote: > > Hi=21 > > =20 > > > No, we can not import namespace directly for now : > > =20 > > Of course you can. You just missing on what namespace import means in= > > PHP, it's not like Java (though a bit like Python). > > =20 > > > <=3Fphp > > > namespace A =7B > > > class B =7B=7D > > > =7D > > > =20 > > > namespace =7B > > > use A; > > > =20 > > > var=5Fdump(new B()); > > > =7D > > > =20 > > =20 > > =20 > > use A is a no-op, just as the warnings tell you. You can just write A= =5CB. > > It's only 2 characters more. If your A is longer, then you can alias = it > > to something shorter. > > =20 > > > and if we need alias we could=EF=BC=9A > > > <=3Fphp > > > // reduce > > > use GlobalNamespace=5CSubSpace=5CThirdSpace=5CClass1; > > > use GlobalNamespace=5CSubSpace=5CThirdSpace=5CClass2 as Alias2; > > > use GlobalNamespace=5CSubSpace=5CThirdSpace=5C=46orthSpace=5CClass3= as Alias3; > > > =20 > > =20 > > =20 > > You could just do > > use GlobalNamespace=5CSubSpace=5CThirdSpace as Spc; > > =24a =3D new Spc=5CClass1(); > > =20 > =20 > =20 > =20 Hi Stas, =20 That is what I am trying to propose, maybe it could be more DRY=3F thanks :) > > =20 > > =20 > > -- > > Stanislav Malyshev, Software Architect > > SugarCRM: http://www.sugarcrm.com/ > > (408)454-6900 ext. 227 > > =20 > > -- > > PHP Internals - PHP Runtime Development Mailing List > > To unsubscribe, visit: http://www.php.net/unsub.php > > =20 > =20 > =20 > =20 > =20 > -- =20 > Laruence Xinchen Hui > http://www.laruence.com/ > =20 > =20 --500f95ae_327b517e_e1f3--