Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80206 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 81290 invoked from network); 5 Jan 2015 22:35:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Jan 2015 22:35:28 -0000 Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.199 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.199 imap11-2.ox.privateemail.com Received: from [192.64.116.199] ([192.64.116.199:54932] helo=imap11-2.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8F/8B-21693-DA11BA45 for ; Mon, 05 Jan 2015 17:35:26 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id 4B24B8800EF; Mon, 5 Jan 2015 17:35:23 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at imap11.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap11.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id pQ1qSSNTsITP; Mon, 5 Jan 2015 17:35:23 -0500 (EST) Received: from oa-res-26-240.wireless.abdn.ac.uk (oa-res-26-240.wireless.abdn.ac.uk [137.50.26.240]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 6FF108800E9; Mon, 5 Jan 2015 17:35:22 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.1 \(1993\)) In-Reply-To: <54AB0F3A.5020606@gmail.com> Date: Mon, 5 Jan 2015 22:35:20 +0000 Cc: PHP Internals Content-Transfer-Encoding: quoted-printable Message-ID: <06711056-CC82-41A6-BED9-FB87450C63BE@ajf.me> References: <54AB0A10.4010709@gmail.com> <54AB0F3A.5020606@gmail.com> To: Stanislav Malyshev X-Mailer: Apple Mail (2.1993) Subject: Re: [PHP-DEV] [RFC] Parameter skipping, take 3 From: ajf@ajf.me (Andrea Faulds) Hi Stas, > On 5 Jan 2015, at 22:24, Stanislav Malyshev = wrote: >=20 > Hi! >=20 >> Yes, they complement one another. Both exist because of horrible >> APIs. But I don=E2=80=99t think we should encourage horrible APIs. >=20 > You can create horrible APIs with this, but you can also create them > without this. This doesn't make it any more likely, it just makes > working with optional parameters easier. Sure, but things like this make such APIs easier to work with. That=E2=80=99= s not a good thing. >> For well-designed functions, there is no need to skip parameters, >> either with a default keyword or with named parameters. >=20 > I disagree with that and in general I disagree with the stance "I = don't > need this so the language does not need that=E2=80=9D. It=E2=80=99s not that I don=E2=80=99t need this=E2=80=A6 there are some = horrible APIs I=E2=80=99ve used which would be slightly (but only = slightly) more pleasant to use with this feature. But I don=E2=80=99t = think we should add features to the language to work around poor API = design. We should get better APIs instead. > We can and should have a > wider look than personal needs and preferences. There are many cases > where optional parameters have their place, and making them more > convenient is a good thing. There are places where optional parameters are good. I never said they = were bad. This RFC doesn=E2=80=99t help with optional parameters, it = helps with excessive numbers of them, or optional parameters with weird = default values. I don=E2=80=99t think that it is necessary to have = parameter skipping for a well-designed API. If the default values are = obvious and intuitive, as they should be, you don=E2=80=99t need = =E2=80=9Cdefault=E2=80=9D. If there is not an excessive number of = parameters, you don=E2=80=99t need =E2=80=9Cdefault=E2=80=9D. If your function takes so many arguments that you need =E2=80=9Cdefault=E2= =80=9D, you should probably reconsider your function=E2=80=99s = signature. If someone else=E2=80=99s function does so, you should = probably either fix it for them or write a wrapper function, so people = trying to read and maintain your code don=E2=80=99t gradually go insane. > As a witness to that, most of the languages > with this syntax model (I'm not talking about the likes of Lisp of > course) do allow optional parameters, and making it easy to work with > them is a very frequently requested (and implemented) feature. Well, some of the languages. Others have decided that named parameters = aren=E2=80=99t a good idea. > You can, > of course, say these all people are wrong and their code is horrible, > but this is the reality of what people want and what they use. They'll > do it whether you like it or not, but with this RFC it would be less > painful. For me, it is a clear win. I=E2=80=99m not sure if this RFC actually would make such functions that = much less painful. For functions with a lot of default parameters, = telling them apart is key. Seeing =E2=80=9CNULL, FALSE, FALSE, 0, = NULL=E2=80=9D may orient the user better when scanning a parameter list = than =E2=80=9Cdefault, default, default, default, default=E2=80=9D = would. Thanks! -- Andrea Faulds http://ajf.me/