Re: RE: [RFC] Fast Parameter Parsing API

From: Date: Mon, 26 May 2014 08:43:06 +0000
Subject: Re: RE: [RFC] Fast Parameter Parsing API
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-74489@lists.php.net to get a copy of this message
I more or less like the last option, and actually it's similar to Bob original proposal. But I see two disadvantages: 1) It'll relay on macros with variable arguments and it may be not portable across all compilers. 2) It uses nested macros and it may make a nightmare for finding source of some syntax mistake in user code. Thanks. Dmitry. On Mon, May 26, 2014 at 12:24 PM, Andrea Faulds <ajf@ajf.me> wrote: > > 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/ > > > > >

« previous php.internals (#74489) next »