Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:20972 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88656 invoked by uid 1010); 1 Dec 2005 18:46:00 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 88640 invoked from network); 1 Dec 2005 18:46:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Dec 2005 18:46:00 -0000 X-Host-Fingerprint: 209.59.182.2 unknown Linux 2.4/2.6 Received: from ([209.59.182.2:48382] helo=amplex.webserversystems.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 20/C1-14828-8E44F834 for ; Thu, 01 Dec 2005 13:46:00 -0500 Received: from adei.com ([64.142.64.79] helo=[192.168.2.10]) by amplex.webserversystems.com with esmtpa (Exim 4.52) id 1EhtRO-0002kS-4R for internals@lists.php.net; Thu, 01 Dec 2005 13:45:58 -0500 Mime-Version: 1.0 (Apple Message framework v746.2) In-Reply-To: <438F0FC0.5070407@cschneid.com> References: <374c2968dd7f3d13c696037ef850256f@gravitonic.com> <2D.57.14828.3453E834@pb1.pair.com> <23.98.14828.81AAE834@pb1.pair.com> <438F0FC0.5070407@cschneid.com> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-ID: <14A191A2-69CF-49C4-B500-A749D7C4B51B@intuitivefuture.com> Content-Transfer-Encoding: 7bit Date: Thu, 1 Dec 2005 10:45:56 -0800 To: internals@lists.php.net X-Mailer: Apple Mail (2.746.2) X-Antivirus-Scanner: This message has been scanned by ClamAV - CLEAN. X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - amplex.webserversystems.com X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - intuitivefuture.com X-Source: X-Source-Args: X-Source-Dir: Subject: Re: [PHP-DEV] Named arguments revisited From: jared@intuitivefuture.com (Jared White) On Dec 1, 2005, at 6:59 AM, Christian Schneider wrote: > Ron Korving wrote: >> Named parameter example: > > Your example misses the main advantage of named parameters IMHO: > Sets of parameters you don't want to or can't explicitely list > because they are not know yet. > >> function adduser($params) >> { >> if (!is_array($params)) throw new Exception('No named >> parameters'); >> if (!isset($params['username'])) throw new Exception('Missing >> parameter: username'); >> if (!isset($params['password'])) throw new Exception('Missing >> parameter: username'); >> if (!isset($params['superuser'])) $params['superuser'] = false; >> // now do some stuff with $params >> } >> adduser(array('username' => 'root', 'password' => 'abcdefg', >> 'superuser' => true)); > > This is not how we use named parameters at all. If you have a > finite set of fixed parameters then positional parameters are > working just fine. Well, I wouldn't say that. The problem isn't that positional parameters don't work fine -- they do -- but that upon code inspection you don't know what those parameters are for unless you know the function/method API ahead of time. Sure, as you pointed out there are some juicy features you get with named parameters if you implement them throughly, but I still say its main selling point is that the calling code is its own API documentation. Regards, Jared