Re: [PHP-DEV] Fast zend_parse_parameters API

[email protected] (Andrea Faulds)
Newsgroups php.internals
Message-ID <[email protected]>
On 4 Sep 2014, at 13:23, Bob Weinand <[email protected]> wrote:

> After a long time… back to our fast_zpp RFC.
> 
> Initially Dmitry proposed to have two different APIs, one for the fast version, one for current version:
> #if FAST_ZPP
>    /* new API */
> #else
>    /* old style zend_parse_parameters API */
> #endif
> 
> I don't really like the idea of having two different APIs, so I'd rather propose to use one same public API for both.
> That API should, depending on some compile-time flag (per file or globally in zend_API.h), either convert to the usual variadic style function, or expand to the new fast variant of API parsing (with directly inlining parameter type specific functions).
> 
> What do you think about having one unified API for both, instead of the current (like it's in some places in master branch currently)?
> (p.s.: The rewrite of the current API can be done safely via some PHP script I wrote)

This is actually quite an interesting idea. If you think about it, there’s no reason the macros couldn’t expand to zend_parse_parameters.

> 
> Also, there is the question about how to structure the API; we (I and Dmitry) basically have now two different proposals:
> 
> 
> ZEND_PARSE_PARAMETERS_START(3, 5)
>    Z_PARAM_ZVAL(regex)
>    Z_PARAM_ZVAL(replace)
>    Z_PARAM_ZVAL(subject)
>    Z_PARAM_OPTIONAL
>    Z_PARAM_LONG(limit)
>    Z_PARAM_ZVAL_EX(zcount, 0, 1)
> ZEND_PARSE_PARAMETERS_END_EX(return);
> 
> 
> OR
> 
> 
> zend_parse_parameters(ZPP_ZVAL(regex) ZPP_ZVAL(replace) ZPP_ZVAL(subject) ZPP_OPTIONAL ZPP_LONG(limit) ZPP_ZVAL_EX(zcount, ZPP_BY_REF), {
>    return;
> })
> 
> 
> We'd like to have some discussions about what API to use for the next years. If you have some better API, feel free to propose it.

Neither is that good, though I might prefer the first one.

Perhaps we should move this out of functions altogether, and instead have parameter types be attributes of the function? I’m not sure if it’s possible, but it would be awesome if we could just put the types where we have our parameter names in our info structs, and it would just magically call the C function with the right types.
--
Andrea Faulds
http://ajf.me/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.