Re: [RFC] Parameter skipping, take 3
| From: | Andrea Faulds | Date: | Mon, 05 Jan 2015 22:15:11 +0000 |
| Subject: | Re: [RFC] Parameter skipping, take 3 | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-80204@lists.php.net to get a copy of this message | ||
Hi Stas,
> On 5 Jan 2015, at 22:02, Stanislav Malyshev <smalyshev@gmail.com> wrote:
>
> For those who doesn't remember, quick reminder - it is about an ability
> to skip parameters in function calls so they'd take default value, like
> this:
> function foo($a, $b = true, $c = "abc") { ... }
> foo($x, default, $y); // $b gets to be true here
>
> In the last discussion I had a lot of "objections" to the tune of "we'd
> rather have named parameters". I like the idea of named parameters too,
> but this one does not contradict it - rather, it compliments it, and a
> lot of the extensions cleanup done in this patch also serves as a base
> for possible implementation of named params, if it happens (more on that
> in the RFC itself).
Yes, they complement one another. Both exist because of horrible APIs. But I don’t think we should
encourage horrible APIs.
I don’t want to end up with the Windows API, except in PHP style:
CreateWindowEx($foo, default, default, $bar, 0, 0, 100, 100, default, default, default, default);
For well-designed functions, there is no need to skip parameters, either with a default keyword or
with named parameters.
So it’s a firm -1 from me. The solution to horrid APIs isn’t to add kludges to the language that
make them slightly less painful. The solution is to fix them, or add new APIs, that are well
designed.
Thanks!
--
Andrea Faulds
http://ajf.me/