Em Sat, 21 Jul 2012 13:13:23 +0200, Pierre Joye <pierre....@gmail.com>
escreveu:
On Fri, Jul 20, 2012 at 12:20 AM, Sara Golemon <poll...@php.net> wrote:
Okay, well... the main pieces of feedback I'd give on it then is to not
change the behavior of the '!' modifier. That's bad BC.
Fully agreed, if we can avoid the introduction of yet another set of
#ifdef, then I'm all for it.
Rather, introduce
a new modifier for checking if a parameter was passed. Secondly, make
these two separate patches as the new modifier is a separate feature
from the single-arg parameter parsing.
Agreed here too.
In the interest of a meaningful discussion, please read the proposal and
the rest of the thread (or at least the other responses to the message you
were replying to).
To reiterate: this proposal has nothing with Stas' proposal and
passed/unpassed/default parameters except insofar as it would alleviate
the need for having a mechanism to detect whether a parameter was skipped.
One argument raised against skipparams was 'use NULL instead'. Ignoring
the fact that many functions have non-NULL default parameters, this is
difficult to do with non-string scalars in internal functions, which under
my proposal would no longer be the case.
In any case, my proposal is not at odds with Stas'. If you think 'default'
is useful in userland (where the problems the proposed changes address do
not exist), you will still find Stas' proposal compelling.
It is not redundant either. You may want to use null-or-scalar in
mandatory arguments. And if you want a skippable non-string scalar
argument in an internal function, you will nevertheless probably want to
assign it a default value (otherwise you'd have something without a
parallel in user-space -- a skippable argument without a default value),
and NULL will be the logical choice in many cases. Any wrapper in
userspace would look weird if you relied exclusively on skipparams.
Instead of:
function userland_wrapper($a, $b=null) {
return internal_func(2*$1, $b === null ? null : 2 * $b);
}
you would need:
function userland_wrapper($a, $b=null) {
$args = func_get_args();
$args[0] *= 2;
if (isset($args[1])) {
$args[1] *= 2;
} else {
unset($args[1]);
}
call_user_func_array('internal_func', $args);
}
--
Gustavo Lopes
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php