Re: [RFC] Named parameters
| From: | Nikita Popov | Date: | Mon, 09 Sep 2013 19:57:55 +0000 |
| Subject: | Re: [RFC] Named parameters | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-68979@lists.php.net to get a copy of this message | ||
On Sat, Sep 7, 2013 at 9:52 AM, Pierre Joye <pierre.php@gmail.com> wrote:
> In no particular order:
>
> . Warning: Cannot pass positional arguments after named arguments.
> Aborting argument unpacking in %s on line %d
>
> Would it make more sense to make it a fatal error? As the code will
> likely not work as expected, at all. It could be a bit too harsh but
> as it is a new feature, there is no BC impact and ensure good usage.
>
I agree that continuing the function call in that case is a bad idea, but I
also really dislike throwing fatal errors when dynamic constructors are
used. An exception would be optimal here (no continued function call, but
easily recoverable), but I know I'm not allowed to introduce those...
> . would it make sense to have an alternative zend API to fetch one or
> more argument using its name? I can see a couple of usages for such a
> function
>
I provide this function:
ZEND_API int zend_get_arg_num(zend_uint *arg_num_target, zend_function
*fn, char *name, int name_len, zend_ulong hash_value TSRMLS_DC);
Using it you can get the argument number from a parameter name and based on
that lookup the value of the argument as usual. Is that sufficient?
> - It would be nice to add (later once the RFC is more stable) docs
> about which impacts and changes are expected for extension developers
>
Yes, sure :)
- Do you have a fork for this RFC? Much easier to test, create snaps, etc.
>
Yes, it's the namedParams branch of my github fork:
https://github.com/nikic/php-src/tree/namedParams
Nikita