Re: Argument unpacking - Multiple unpacks and trailing arguments

From: Date: Mon, 23 Sep 2013 19:45:17 +0000
Subject: Re: Argument unpacking - Multiple unpacks and trailing arguments
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-69295@lists.php.net to get a copy of this message
On 23/09/2013 20:33, Nikita Popov wrote:
The main open question (or at least the focus of the discussion) seems to be whether to allow multiple unpacks and trailing arguments.
I'm not sure I like the idea of multiple unpacks, were we to implement named parameters (if you did f(...(['a' => 2]), ...(['a' => 3])) you'd presumably have the $a argument overridden?), but I can't oppose it for linear arguments alone. I'm not sure about trailing arguments either. I'm not sure if there's really a good use case for them. I notice that we do not allow either in the variadics RFC, so I think it would make sense to be consistent with that. If someone really needs to do either of these, it would be a simple array_merge() away, and that might make the code clearer. I also note that Python doesn't allow either of these. I can't find why exactly, but I would assume there were good reasons behind it. So I think it would be best to allow neither of those, for the sake of consistency. (OT: I've also just discovered that Python supports "a, b, *c = someseq" for multiple assignment, perhaps we could see "list($a, $b, ...$c) = $someseq" support?) -- Andrea Faulds http://ajf.me/

« previous php.internals (#69295) next »