Re: [RFC][VOTE] Group Use Declarations
| From: | Marcio Almada | Date: | Thu, 12 Feb 2015 13:21:02 +0000 |
| Subject: | Re: [RFC][VOTE] Group Use Declarations | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-82532@lists.php.net to get a copy of this message | ||
> Thanks for the RFC!
> We discussed a little bit with the Hoa [1]'s and fruux [2]'s community
and we have a question.
> Why not pretending we have an array of symbols, something like:
> use Foo\Bar\[Baz, Qux];
> instead of
> use Foo\Bar\{Baz, Qux};
> This is a list vs. block debate. While I personally would go for
>
{ and
}, here we declare a list, so we guess the array syntax
> would be more tailored.
> Thoughts?
Hi,
This is an interesting one. During research, the [ and ] syntax was
considered for a while but it quickly felt apart for the following reasons:
1. Most people considered on PHP the array construct is a very important
building block and therefore we should avoid to multiplex or reuse its
syntax in multiple contexts. This becomes more clear in cases involving
conflict resolutions:
use Foo\Bar\[Baz *as* Buz, Qux\Quaz *as* Quiz];
2. Block syntax seemed more versatile and prone to reuse because we already
have the traits conflict resolution syntax:
http://php.net/manual/en/language.oop5.traits.php#language.oop5.traits.conflict
The reasoning for using commas to delimit imported entities and not ; is
that current use declaration syntax is a comma separated list:
use function foo\math\sin, foo\math\cos, foo\math\cosh;
Hence the {..., ...} syntax seemed the most tailored to feel similar and
obvious for most of the current PHP userbase, based on all experiments:
use function foo\math\{ sin, cos, cosh };
use function Foo\Bar\{ A, B as Baz, C };
I hope that the given information is useful to your decision process. Good
voting!
Sincerely,
Márcio Almada.