Next revision | Previous revisionNext revisionBoth sides next revision |
rfc:zpp_improv [2013/01/02 14:22] – created cataphract | rfc:zpp_improv [2013/01/16 22:32] – [Voting] cataphract |
---|
The native function ''zend_parse_parameters()'' (henceforth zpp) is used by internal PHP functions to parse the function arguments into native types or to merely extract the zvals from the stack. It's a variadic function that takes a format string and a matching list of pointers that serve as output parameters. | The native function ''zend_parse_parameters()'' (henceforth zpp) is used by internal PHP functions to parse the function arguments into native types or to merely extract the zvals from the stack. It's a variadic function that takes a format string and a matching list of pointers that serve as output parameters. |
| |
The conversions that zpp does to transform the passed zvals into native types are not trivial. For instance, it can convert a string into a "long", but not all strings will be accepted and some will be accepted but will emit a warning. As many variables end up at some point as arguments to internal functions, the behavior of zpp ends affecting how PHP's users perceive PHP's type system to work. Consequently, consistency in internal function parameter parsing is highly desirable. As zpp behavior is not trivial, achieving such consistency depends on PHP internal functions' implementations using zpp. | The conversions that zpp does to transform the passed zvals into native types are not trivial. For instance, it can convert a string into a "long", but not all strings will be accepted and some will be accepted but will emit a warning. As many variables end up at some point as arguments to internal functions, the behavior of zpp ends affecting how PHP's users perceive PHP's type system to work. Consequently, consistency in internal function parameter parsing is highly desirable. As zpp behavior is not trivial, achieving such consistency depends on PHP internal functions' implementations using zpp correctly. |
| |
Unfortunately, zpp is also inflexible. One is restricted to a single format string, which makes implementing overloads difficult. Common solutions include calling zpp quietly several times until it succeeds (signaling a correct set of arguments) and fetching the zvals without conversion, following with explicit conversions (hopefully with convert_to_xx_ex(), not simply convert_to_xx()). These can cause several problems -- confusing error messages (or absence of them) and unanticipated side effects of failed zpp calls (which changes the arguments directly in the stack, as part as the conversion procedure, until it finds a failing condition) in the first case, and using casting behavior instead of zpp behavior in the second case (convert_to_int_ex() will happily and silently convert a resource into an integer). | Unfortunately, zpp is also inflexible. One is restricted to a single format string, which makes implementing overloads difficult. Common solutions include calling zpp quietly several times until it succeeds (signaling a correct set of arguments) and fetching the zvals without conversion, following with explicit conversions (hopefully with convert_to_xx_ex(), not simply convert_to_xx()). These can cause several problems -- confusing error messages (or absence of them) and unanticipated side effects of failed zpp calls (which change the arguments directly in the stack, as part as the conversion procedure, until it finds a failing condition) in the first case, and using casting behavior instead of zpp behavior in the second case (convert_to_int_ex() will happily and silently convert a resource into an integer). |
| |
===== Expose zend_parse_arg() as zend_parse_parameter() ===== | ===== Expose zend_parse_arg() as zend_parse_parameter() ===== |
| |
The mailing list discussion is available [[http://grokbase.com/p/php/php-internals/127j49y02w/zend-parse-parameters-improvements|here]]. | The mailing list discussion is available [[http://grokbase.com/p/php/php-internals/127j49y02w/zend-parse-parameters-improvements|here]]. |
| |
| ===== Voting ===== |
| |
| Voting ends not before Wednesday, January 16th 2013. The PHP language is not changed, so a 50%+1 majority is required. |
| |
| <doodle title="Accept these improvements for PHP 5.5?" auth="cataphract" voteType="single" closed="true"> |
| * Yes |
| * No |
| </doodle> |
| |
===== Changelog ===== | ===== Changelog ===== |
| |
- 2012-01-02: Initial revision | - 2013-01-02: Initial revision |
| - 2013-01-09: Opened voting |
| |