Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60138 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 50732 invoked from network); 17 Apr 2012 23:56:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Apr 2012 23:56:02 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.42 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.213.42 mail-yw0-f42.google.com Received: from [209.85.213.42] ([209.85.213.42:51053] helo=mail-yw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7A/6D-21594-1130E8F4 for ; Tue, 17 Apr 2012 19:56:02 -0400 Received: by yhfq11 with SMTP id q11so3858206yhf.29 for ; Tue, 17 Apr 2012 16:55:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; bh=SGFaNaYifa6XXU+hGZJqXr3zvkXwXpp6eLHpgvd+eUo=; b=Gla0fwRBsm1RGJ3t6yKol9fVP1aLnPgPIJo67teF7oMY8XlgHvmh6f7I1G8wxn2D7H hX9M0OFH3VeuveQK46TbXFNoOKExJar5O1Pq+WxkUaNZS4GaX2EW6mmDIMfzG5Z9+E/z Q3eRRJTzbRhkiL8EljYLO5qdNwgUsk7VPbnajqdgalkyWoJWp/+S6P4QFv7jRufkrjHG uPjASWaQeP6gRiIQoPm87nSiUAsDtBnLkkq2fE+nriv7AKXjRS4P2lNhMH4kHslJIUJU T9+HZmLIBSDi0HiJsyPUw0/KI621VFDAd4pLKbNEOT76uGTkz23pmEyNpkfqmjaX9O55 laJQ== Received: by 10.236.193.101 with SMTP id j65mr148748yhn.47.1334706957574; Tue, 17 Apr 2012 16:55:57 -0700 (PDT) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.146.86.14 with HTTP; Tue, 17 Apr 2012 16:55:17 -0700 (PDT) In-Reply-To: <0CBF8A52-E369-4F31-9415-43126FA03904@welsh.co.nz> References: <4F8DF4B1.2040307@sugarcrm.com> <0CBF8A52-E369-4F31-9415-43126FA03904@welsh.co.nz> Date: Wed, 18 Apr 2012 08:55:17 +0900 X-Google-Sender-Auth: 6k6BObZ37A2pb6-JFurkHcNcDfs Message-ID: To: Simon J Welsh Cc: PHP Internals Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] [RFC] skipping optional parameters From: yohgaki@ohgaki.net (Yasuo Ohgaki) Hi, 2012/4/18 Simon J Welsh : > On 18/04/2012, at 10:54 AM, Stas Malyshev wrote: > >> Hi! >> >> 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); >> >> Implementation of it is here: >> https://github.com/smalyshev/php-src/tree/skip_params >> All things described in RFC seem to be working, please tell me if I >> forgot anything. If it's accepted I'll also add tests, etc. of course. > > > Hi > > I like this proposal. One thing pops out at me though. > > Since func_num_args() won't be able to be used to see if an argument is set, could a func_isset_arg() be added? So something like: > if(func_num_args() > 2) $value = func_get_arg(2); > would become: > if(func_isset_arg(2)) $value = func_get_arg(2); Good point. For func_get_arg(), having "undefined" is mandatory, otherwise we cannot tell if it is defined or not. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net