On 2012-04-17, Stas Malyshev <smalys...@sugarcrm.com> wrote: > 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);
I actually had a need for either this or named parameters this past week, and as such would love to see one or the other in place. While I'd personally prefer named arguments, this approach would work in most places I've needed them. My one comment, which others have raised, is readability of multiple commas -- TBH, at first glance it has the appearance of a mistake. I think those suggesting a keyword such as "default" make a good point in this regard -- it makes it 100% clear that you want the default value for the argument in that position. This also presents an improvement over current usage, as you're not hard-coding values in your function calls themselves -- particularly as the defaults could change in future refactors. -- Matthew Weier O'Phinney Project Lead | matt...@zend.com Zend Framework | http://framework.zend.com/ PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php