rfc:skipparams
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:skipparams [2013/09/02 04:59] – changelog stas | rfc:skipparams [2013/09/02 21:46] – [Changelog] stas | ||
---|---|---|---|
Line 4: | Line 4: | ||
* Author: Stas Malyshev < | * Author: Stas Malyshev < | ||
* Status: Under Discussion | * Status: Under Discussion | ||
- | * Implementation: | + | * Implementation: |
===== Introduction ===== | ===== Introduction ===== | ||
Line 24: | Line 23: | ||
Of course, if we ever get implementation of named parameters, it may also solve this problem, but until we do, this can be a partial solution. | Of course, if we ever get implementation of named parameters, it may also solve this problem, but until we do, this can be a partial solution. | ||
- | Only optional parameters can be skipped this way, skipping non-optional one will produce the same error it does now when function is not given engough | + | Only optional parameters can be skipped this way, skipping non-optional one will produce the same error it does now when function is not given enough |
===== Implementation ===== | ===== Implementation ===== | ||
Line 30: | Line 29: | ||
On the engine level, it will be implemented by putting NULL in the place where the parameter is passed. Functions dealing with argument handling will be updated. | On the engine level, it will be implemented by putting NULL in the place where the parameter is passed. Functions dealing with argument handling will be updated. | ||
- | See example implementation above. | + | See example implementation above. |
===== User functions ===== | ===== User functions ===== | ||
Line 84: | Line 83: | ||
===== Internal API changes ===== | ===== Internal API changes ===== | ||
- | Parameters stored as zval** in the engine. For skipped parameter, the value stored is NULL instead of zval* to specific argument. | + | Parameters stored as zval** in the engine. For skipped parameter, the value stored is NULL instead of zval* to specific argument. The opcode putting NULL on the stack is implemented as znode type IS_UNUSED. |
zend_parse_parameter() would ignore parameters marked as default - meaning, it will not assign any value to the underlying variable. This is unless the parameter is marked as !, in which case the parameter would be nullified just as if null were passed. This means you can not have variables marked as ! with different behavior between null and ' | zend_parse_parameter() would ignore parameters marked as default - meaning, it will not assign any value to the underlying variable. This is unless the parameter is marked as !, in which case the parameter would be nullified just as if null were passed. This means you can not have variables marked as ! with different behavior between null and ' | ||
- | For variadic parameters like + and *, skipped parameters will be ignored and not included in the list as if they were not passed. | + | For variadic parameters like + and *, skipped parameters will be ignored and not included in the list as if they were not passed. In other words, + and * will never return NULLs among parameters. |
If certain function wants to disallow skipping parameters, it should use option ZEND_PARSE_PARAMS_NODEFAULT with zend_parse_parameters_ex(). In this case, skipped parameters will cause . For older APIs, zend_get_parameters_array_nodefault() is available which will fail with E_WARNING " | If certain function wants to disallow skipping parameters, it should use option ZEND_PARSE_PARAMS_NODEFAULT with zend_parse_parameters_ex(). In this case, skipped parameters will cause . For older APIs, zend_get_parameters_array_nodefault() is available which will fail with E_WARNING " | ||
- | ZEND_NUM_ARGS() is always the number of parameters in function call, so skipped parameters are counted. But trying to get a skipped parameter will produce NULL. | + | ZEND_NUM_ARGS() is always the number of parameters in function call, so skipped parameters are counted |
===== User request examples ===== | ===== User request examples ===== | ||
Line 104: | Line 103: | ||
* http:// | * http:// | ||
* http:// | * http:// | ||
+ | * http:// | ||
===== Issues raised ===== | ===== Issues raised ===== | ||
- | * Support for internal functions doing manual ZEND_NUM_ARGS() | + | * Support for internal functions doing manual ZEND_NUM_ARGS(). I've looked into all functions in the standard distribution, |
===== Changelog ===== | ===== Changelog ===== | ||
Line 112: | Line 111: | ||
* 2012-04-13 First draft. | * 2012-04-13 First draft. | ||
* 2012-07-07 Changed empty parameter to use ' | * 2012-07-07 Changed empty parameter to use ' | ||
- | * Added Zend API description | + | * 2013-09-01 |
rfc/skipparams.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1