keyword arguments?
| From: | Daniel Crookston | Date: | Wed, 23 Jun 2004 15:04:43 +0000 |
| Subject: | keyword arguments? | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-10728@lists.php.net to get a copy of this message | ||
It looks like the last time this was discussed was October of 2003, over
the course of about five emails. I don't see anything in the archives
about it since then. Here's what I'd like to suggest.
some_function($a, 'B', :check TRUE)
function some_function($first, $second, :check $key1 = FALSE, :foo $key2)
{
if ($key1) {
lala;} elseif ($key2 > 0) {
blabla;} } Sticking a : in front of the variable name, either in the calling code or the function declaration, makes it a keyword argument. Keyword arguments are always optional, and [could|should] default to something handy like FALSE or 0. (Maybe make their defaults settable in php.ini?) I would implement this myself, but even after reading George Schlossnagle's fantastic book, I'm still not wizardly enough to do so. If someone could point me in the right direction, though... Thanks for listening, Daniel