Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80894 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66844 invoked from network); 20 Jan 2015 20:09:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jan 2015 20:09:43 -0000 Authentication-Results: pb1.pair.com header.from=dev@mabe.berlin; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=dev@mabe.berlin; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mabe.berlin from 80.237.132.167 cause and error) X-PHP-List-Original-Sender: dev@mabe.berlin X-Host-Fingerprint: 80.237.132.167 wp160.webpack.hosteurope.de Received: from [80.237.132.167] ([80.237.132.167:51241] helo=wp160.webpack.hosteurope.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E1/63-49046-706BEB45 for ; Tue, 20 Jan 2015 15:09:43 -0500 Received: from dslb-146-060-205-089.146.060.pools.vodafone-ip.de ([146.60.205.89] helo=[192.168.178.30]); authenticated by wp160.webpack.hosteurope.de running ExIM with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) id 1YDf7M-00005h-RI; Tue, 20 Jan 2015 21:09:40 +0100 Message-ID: <54BEB604.9000705@mabe.berlin> Date: Tue, 20 Jan 2015 21:09:40 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: internals@lists.php.net References: <52243BA6.5040905@sugarcrm.com> <54B6C047.3070301@mabe.berlin> <48223964-2F90-4386-BD8F-934791E45EB4@welsh.co.nz> <9F083B4E-B603-4A1D-9F1D-C758D835B450@ajf.me> In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-bounce-key: webpack.hosteurope.de;dev@mabe.berlin;1421784583;d445bcd4; Subject: Re: [PHP-DEV] [RFC] Skipping parameters take 2 From: dev@mabe.berlin (Marc Bennewitz) Am 19.01.2015 um 19:48 schrieb Adam Harvey: > On 17 January 2015 at 18:04, Andrea Faulds wrote: >> For consistency with list(), we could also just put nothing: >> >> >> foo($bar, , $baz); >> >> Which is like: >> >> list($bar, , $baz) = $arr; >> >> Thoughts? > That was Stas's original, original proposal way back when. I argued > then for having "default" as a placeholder, and still would today — in > the case where a function with, say, ten optional parameters[0] is > being called and eight of them should be the default, I think it's a > bit rough for somebody inheriting that code to have to count commas. > Having a token increases readability, IMO, and costs us nothing except > a few keystrokes, which isn't going to break the camel's back in a > language that requires "function" each time you declare a function. > > Adam > > [0] Yes, that's probably poor API design. You and I both know someone > will do it, though. :) Pros & Cons _Simply skipping the argument out:_ pro: - same syntax as skipping entries used by `list` con: - hard to read and to differ from mistakes - not an option for inheritance _Using the keyword `default`:_ pro: - better to read and to differ from mistakes - usable on inheritance con: - different syntax as `list` - not possible as alternative syntax for `list` as it has no "default" naming _Using a special character:_ pro: - better to read and to differ from mistakes - usable on inheritance - possibly an alternative syntax for `list` (for consistency) con: - different syntax as `list` - Not a good character found for it, yet _Named Parameters:_ pro: - readability (If caller is not required to call as assoc array) - not an option for inheritance con: - paramter skipping is a side product with possible edge cases - Adds variable names to be part of the API - implementation complexity In my opinion plain skipping parameters is a nice addition to PHP even if named arguments will be introduced. A special character would indeed the best option but as long as there is no good character it's not an option. @Stas: Any news on using default on inheritance ? Marc