Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82621 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 43715 invoked from network); 13 Feb 2015 16:41:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Feb 2015 16:41:09 -0000 Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.200 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.200 imap1-2.ox.privateemail.com Received: from [192.64.116.200] ([192.64.116.200:53301] helo=imap1-2.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 03/90-40724-3292ED45 for ; Fri, 13 Feb 2015 11:41:09 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id 0FEE2B00093; Fri, 13 Feb 2015 11:41:04 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at imap1.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap1.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 54xMkLy5nA3K; Fri, 13 Feb 2015 11:41:03 -0500 (EST) Received: from oa-res-26-240.wireless.abdn.ac.uk (oa-res-26-240.wireless.abdn.ac.uk [137.50.26.240]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id F30B0B00068; Fri, 13 Feb 2015 11:41:02 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2070.6\)) In-Reply-To: Date: Fri, 13 Feb 2015 16:41:00 +0000 Cc: marcio3w@gmail.com, PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: <5EF29B6C-D35B-47B8-8008-47B207B2840B@ajf.me> References: To: Nikita Popov X-Mailer: Apple Mail (2.2070.6) Subject: Re: [PHP-DEV][RFC][VOTE] Group Use Declarations From: ajf@ajf.me (Andrea Faulds) Hey, > On 13 Feb 2015, at 16:24, Nikita Popov wrote: >=20 > I'm in favor of this RFC. Honestly I don't really understand the = negativity > it is getting around here. >=20 > The ability to import multiple items from one namespace is a > well-established feature you'll find in many languages employing some = kind > of namespacing. I don't think the availability of what I lovingly call = "IDE > vomit" is a good reason to decline a feature - a programming language > should be able stand on its own and not require IDE assistance for > reasonable use. >=20 > The syntax seems pretty obvious as well - but maybe I just had too = much > exposure to Rust, which makes extensive use of the same syntax. My thoughts echo Nikita=E2=80=99s. I think this feature would be especially important if PHP gets function = autoloading (which it may yet gain in PHP 7 - a certain someone has been = working on it). Currently, sets of independent functions have to be = implemented as static classes. But with function autoloading, they=E2=80=99= d have to be imported independently, and that would lead to way too many = use statements. This feature is familiar to people who have used other languages, as = Nikita mentioned. In Python, I might do this: from somelibrary.math import sin, cos, tan, degrees, radians Simple, uncumbersome, readable. The equivalent in PHP is this: use function SomeLibrary\Math\sin; use function SomeLibrary\Math\cos; use function SomeLibrary\Math\tan; use function SomeLibrary\Math\degrees; use function SomeLibrary\Math\radius; Ouch. Not fun to type, not fun to read, takes up way more space than it = should. This is just a modest five functions, too - in many cases = you=E2=80=99d be importing more. But with Marcio=E2=80=99s proposal, we could instead write this: use function SomeLibrary\Math\{sin, cos, tan, degrees, radius}; Much better, no? I know which one I=E2=80=99d rather read and write. It=E2=80=99d be a real shame if this doesn=E2=80=99t pass. -- Andrea Faulds http://ajf.me/