Re: [RFC][VOTE] Group Use Declarations

From: Date: Fri, 13 Feb 2015 18:09:21 +0000
Subject: Re: [RFC][VOTE] Group Use Declarations
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On Feb 13, 2015 8:41 AM, "Andrea Faulds" <[email protected]> wrote:
>
> Hey,
>
> > On 13 Feb 2015, at 16:24, Nikita Popov <[email protected]> wrote:
> >
> > I'm in favor of this RFC. Honestly I don't really understand the
negativity
> > it is getting around here.
> >
> > 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.
> >
> > 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’s.
>
> 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’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’d be
importing more.
>
> But with Marcio’s proposal, we could instead write this:
>
>     use function SomeLibrary\Math\{sin, cos, tan, degrees, radius};
>
> Much better, no? I know which one I’d rather read and write.
>
> It’d be a real shame if this doesn’t pass.

Fully agree here, with every said by Nikita and Andrea.

I feel again a gap between ppl using php, writing a lot of this code and
us. This is worrisome.

Cheers,
Pierre


Thread (45 messages)

« previous php.internals (#82635) next »