Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61619 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5872 invoked from network); 21 Jul 2012 12:11:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Jul 2012 12:11:36 -0000 Authentication-Results: pb1.pair.com smtp.mail=glopes@nebm.ist.utl.pt; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=glopes@nebm.ist.utl.pt; sender-id=unknown Received-SPF: error (pb1.pair.com: domain nebm.ist.utl.pt from 193.136.128.21 cause and error) X-PHP-List-Original-Sender: glopes@nebm.ist.utl.pt X-Host-Fingerprint: 193.136.128.21 smtp1.ist.utl.pt Linux 2.6 Received: from [193.136.128.21] ([193.136.128.21:60738] helo=smtp1.ist.utl.pt) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DE/62-27309-07C9A005 for ; Sat, 21 Jul 2012 08:11:30 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp1.ist.utl.pt (Postfix) with ESMTP id E2B32700044E; Sat, 21 Jul 2012 13:11:25 +0100 (WEST) X-Virus-Scanned: by amavisd-new-2.6.4 (20090625) (Debian) at ist.utl.pt Received: from smtp1.ist.utl.pt ([127.0.0.1]) by localhost (smtp1.ist.utl.pt [127.0.0.1]) (amavisd-new, port 10025) with LMTP id rCEaDZX-8+GB; Sat, 21 Jul 2012 13:11:25 +0100 (WEST) Received: from mail2.ist.utl.pt (mail.ist.utl.pt [IPv6:2001:690:2100:1::8]) by smtp1.ist.utl.pt (Postfix) with ESMTP id 8EE27700044D; Sat, 21 Jul 2012 13:11:25 +0100 (WEST) Received: from damnation (unknown [IPv6:2001:470:94a2:4:9d0b:38b:c1f7:a49]) (Authenticated sender: ist155741) by mail2.ist.utl.pt (Postfix) with ESMTPSA id A25C92023236; Sat, 21 Jul 2012 13:11:23 +0100 (WEST) Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: "Sara Golemon" , "Pierre Joye" Cc: "Nikita Popov" , "internals@lists.php.net" References: Date: Sat, 21 Jul 2012 14:11:18 +0200 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Organization: =?utf-8?Q?N=C3=BAcleo_de_Eng=2E_Biom=C3=A9di?= =?utf-8?Q?ca_do_I=2ES=2ET=2E?= Message-ID: In-Reply-To: User-Agent: Opera Mail/12.50 (Linux) Subject: Re: [PHP-DEV] zend_parse_parameters() improvements From: glopes@nebm.ist.utl.pt ("Gustavo Lopes") Em Sat, 21 Jul 2012 13:13:23 +0200, Pierre Joye escreveu: > On Fri, Jul 20, 2012 at 12:20 AM, Sara Golemon 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