Hi! Am 31.8.2013 um 01:39 schrieb Lazare Inepologlou <linep...@gmail.com>:
> > > 2013/8/31 Bob Weinand <bobw...@hotmail.com> > Hi! > > Am 31.8.2013 um 00:27 schrieb Lazare Inepologlou <linep...@gmail.com>: > > > 2013/8/30 Stas Malyshev <smalys...@sugarcrm.com> > > > >>> don't see a reason why one should explicitly disallow doing multiple > >>> unpacks. > >> > >> Because it makes very hard to understand what's going on and makes no > >> sense semantically. > >> > >>> As you can see, here two arguments are unpacked in one call. > >> > >> This is very special use case to be hidden in library functions, I don't > >> think we need to have language syntax specially directed at that, at the > >> cost of making it overall more complex and hard to understand. I can see > >> what "add all those params at the end" syntax mean. However having > >> something like ($a, ...$b, $c, ...$d, $e, $f, $g, ...$h) I have no idea > >> what's going on at all and what is sent where. > >> > >> > > I agree with Stas here. If an argument comes after an unpacked array, its > > position is not certain until runtime. This makes life difficult for static > > analysis tools, which is one of the reasons for introducing the new syntax. > > The alternative is for users to use what we have now: call_user_func_array > with some array_merge, which makes it as difficult for static analysis as the > new syntax does. This really is a non-argument. > > > > Please read carefully my argument. The alternative is to actually call the > function normally with the arguments expanded in the code. > > In other words, the alternative to this: > strpos( ...$array , 3 ); // which cannot be verified statically > > is this: > strpos( $array[0] , $array[1] , 3 ); // which is perfectly verifiable. > > > The power of this proposal is found when used with optional arguments (or > variadic arguments) which always come last anyway. > > > Lazare INEPOLOGLOU > Ingénieur Logiciel This also isn't anything it ever would write, because it just doesn't make any sense for two or three arguments. In my opinion you only should unpack arrays when it's at the end … AND when you can verify how many parameters will be inserted. Just shorter. Because writing: func($array[0], $array[1], $array[2], $array[3], $array[4], $array[5], $array[6], "value"); is just ugly to write and to read. if (count($array) == 7) func(...$array, "value"); is much more readable, I think. Bob Weinand