Re: RE: [RFC] Fast Parameter Parsing API
| From: | Andrea Faulds | Date: | Mon, 26 May 2014 08:24:08 +0000 |
| Subject: | Re: RE: [RFC] Fast Parameter Parsing API | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-74486@lists.php.net to get a copy of this message | ||
On 26 May 2014, at 08:17, Zeev Suraski <zeev@zend.com> wrote:
> I think the main challenge is the fact it turns what today is a one-liner
> (albeit a bit obscure) into a long multi-line all-caps gig. I’ve tried to
> think about alternatives but so far came short with something that
> elegantly solves the problem, short of using C++ which I think goes too far
> in the context of what we’re trying to achieve.
Perhaps it could be simplified? Something like this:
ZEND_PARSE_PARAMETERS(Z_PARAM_ARRAY, input, Z_PARAM_LONG, offset, Z_PARAM_OPTIONAL, Z_PARAM_ZVAL,
z_length, Z_PARAM_BOOL, preserve_keys);
That’s still rather unwieldy, though. Maybe Z_PARAM could be shortened to ZP_? Then we’d have
this:
ZEND_PARSE_PARAMETERS(ZP_ARRAY, input, ZP_LONG, offset, ZP_OPTIONAL, ZP_ZVAL, z_length, ZP_BOOL,
preserve_keys)
That’s not so bad, right? That would be parsing at runtime instead of with macros, though. Maybe
this?
ZEND_PARSE_PARAMETERS(ZP_ARRAY(input), ZP_LONG(offset), ZP_OPTIONAL, ZP_ZVAL(z_length),
ZP_BOOL(preserve_keys))
Except, at least if we’re only using C89, we can’t use a nice function-like macro syntax here.
You’d also still need to explicitly state numbers of arguments. The first and second proposals are
nice because they requires none of this due to runtime parsing, but it would be no faster than
zend_parse_parameters.
Does anyone have a good idea?
--
Andrea Faulds
http://ajf.me/