Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60130 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 38342 invoked from network); 17 Apr 2012 23:23:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Apr 2012 23:23:18 -0000 Authentication-Results: pb1.pair.com header.from=j.boggiano@seld.be; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=j.boggiano@seld.be; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain seld.be designates 74.125.82.54 as permitted sender) X-PHP-List-Original-Sender: j.boggiano@seld.be X-Host-Fingerprint: 74.125.82.54 mail-wg0-f54.google.com Received: from [74.125.82.54] ([74.125.82.54:40709] helo=mail-wg0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 37/AA-21594-46BFD8F4 for ; Tue, 17 Apr 2012 19:23:17 -0400 Received: by wgbfg15 with SMTP id fg15so1914859wgb.11 for ; Tue, 17 Apr 2012 16:23:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type :content-transfer-encoding:x-gm-message-state; bh=4LjxTcFqt6BgvJ0Z14nAg+2uZ51haaiIV6fMD0enw2s=; b=dZIJlU2XBcUZdNE10jrAvAGtY+QyNDGHQ1xPpgGxoE0GlIeZJ/EW7XyWMFmnEaLyK5 xrbS5EmRmsrxuE4BD0SzEilz53mVNgCHfAX8PhMUgXxXH3baHuMjZL7j7f0fArL8WkZu /DwxUVmHWxbEdCgIq3jgv0F3llM3p7MKKgMFBq5AH+KMotk55LSQQCl1m1ic0SmVdqZ4 Q4yucVi1vhGJn+mT4Ipehlq4a62KqtA+z0lL4MPtPTUPwuZJHqi4oHHdRsbTIPogbVPO 2spgQb9Wbdun34LvRIx5UN+q5k6kSlZ+YB7Vp3juKcQWrpa8kmTpaQAuuLAbvEFozxFW R+Jw== Received: by 10.180.93.196 with SMTP id cw4mr692611wib.19.1334704994014; Tue, 17 Apr 2012 16:23:14 -0700 (PDT) Received: from [192.168.1.36] (77-57-163-132.dclient.hispeed.ch. [77.57.163.132]) by mx.google.com with ESMTPS id e6sm30299160wix.8.2012.04.17.16.23.13 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 17 Apr 2012 16:23:13 -0700 (PDT) Message-ID: <4F8DFB65.4020506@seld.be> Date: Wed, 18 Apr 2012 01:23:17 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20120327 Thunderbird/11.0.1 MIME-Version: 1.0 To: internals@lists.php.net References: <4F8DF4B1.2040307@sugarcrm.com> In-Reply-To: <4F8DF4B1.2040307@sugarcrm.com> X-Enigmail-Version: 1.4 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQk9ucxS9cEF0dgWIAyJgw1ymTvQpyfVn5jlXZxXdayKMqMB4ltvpFV3Y22OKDMYXejR+utv Subject: Re: [PHP-DEV] [RFC] skipping optional parameters From: j.boggiano@seld.be (Jordi Boggiano) On 18.04.2012 00:54, Stas Malyshev wrote: > One of the annoying things I've encountered in working with PHP was > dealing with functions having long optional parameter lists, especially > if you need to change only the last one - you have to copy all the > defaults. Full named params implementation would solve it, probably, but > before we have that here's an easier solution for part of the problem: > > https://wiki.php.net/rfc/skipparams > > Basically, it allows you to do this: > > create_query("deleted=0", "name",,, /*report_errors*/ true); Pretty cool especially since it avoids the problem when refactoring code of knowing whether the use of the default param was intentional or just as a filler to reach a later parameter. I do have two remarks though: - I hope it doesn't mean giving up on named args, because that would look way cleaner. - Would it be possible to allow trailing commas in combination to this? i.e. foo("arg",) would just call foo with "arg" and then the default value for the second arg if there is one, or just nothing. That would make multi-line function calls a bit cleaner, and more similar to arrays. Cheers -- Jordi Boggiano @seldaek - http://nelm.io/jordi