Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60169 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 21122 invoked from network); 18 Apr 2012 08:31:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Apr 2012 08:31:20 -0000 Authentication-Results: pb1.pair.com smtp.mail=adamjonr@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=adamjonr@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.170 as permitted sender) X-PHP-List-Original-Sender: adamjonr@gmail.com X-Host-Fingerprint: 209.85.214.170 mail-ob0-f170.google.com Received: from [209.85.214.170] ([209.85.214.170:33926] helo=mail-ob0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 19/23-03614-7DB7E8F4 for ; Wed, 18 Apr 2012 04:31:20 -0400 Received: by obbup16 with SMTP id up16so2880668obb.29 for ; Wed, 18 Apr 2012 01:31:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=C8SRSRCZ/NTy9oq0p2npQ+jMcjUXBb81mVXZu8r6tJc=; b=hNCyluYKd4yKdpjIrFNzOvIGWygVjaDh+c9gJgqfbAa10laOJEaWQNfBpTlWVbM0KM iCRbkJOwZePkG5ehWKrUHimYWUE4S7VstQLavEsKsYbby3DeorE+cpPjk3I9Q1bCeffR pvZLzXkTMztZEvhwPKVqdseNn3vfMCyVp1BUhpP7YhbcGDZHLt1t110DPW+VvWD47M2T 1M+wOUACKI2bMdM1+8qvgZSZe6qcboTCvt/6m8aHNZX1BtTCbuo9pEFd69iaOJ2r86kK srrRiT/v0EPE3FA0wJEps2brTSY2zpBF40xlLtmmxeg8lY3/Q0vYCEMqKIf4glTyxdOT d0Ig== MIME-Version: 1.0 Received: by 10.60.20.10 with SMTP id j10mr1822506oee.33.1334737877430; Wed, 18 Apr 2012 01:31:17 -0700 (PDT) Received: by 10.182.43.74 with HTTP; Wed, 18 Apr 2012 01:31:17 -0700 (PDT) In-Reply-To: References: <4F8DF4B1.2040307@sugarcrm.com> Date: Wed, 18 Apr 2012 04:31:17 -0400 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=e89a8fb205bc0d708604bdefe1e1 Subject: Re: [PHP-DEV] [RFC] skipping optional parameters From: adamjonr@gmail.com (Adam Jon Richardson) --e89a8fb205bc0d708604bdefe1e1 Content-Type: text/plain; charset=ISO-8859-1 On Wed, Apr 18, 2012 at 1:56 AM, Alexey Shein wrote: > Hi! > > My opinion is that solution tries to overcome bad consequences of > legacy code, when it's not feasible to change something without > breakage a lot of code, although the real solution is to refactor > functions with long variable lists (as Uncle Bob says), maybe this > should be noted in documentation of this feature. > I disagree with the suggestion that the "real" solution is to refactor functions. Is a function with 3 parameters too long? function foo($val1, $val2 = true, $val3 = false) { /* code */} If I want to pass in a value to the third argument but keep the default value for the second argument, I have to look up what the default is and then paste/type it in as the second argument. Being able to just call foo($val1 = "something", , $val3 = true) lets me set a specific value for the 3rd argument without having to do any hunting down of the 2nd default value or copying/pasting/typing in the argument. From my perspective, this solution is more about maintaining defaults and improving developer experience than about problems with legacy code, and it holds value for any function that has more than one default value. Adam --e89a8fb205bc0d708604bdefe1e1--