Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:21564 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37232 invoked by uid 1010); 18 Jan 2006 07:48:07 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 37217 invoked from network); 18 Jan 2006 07:48:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Jan 2006 07:48:07 -0000 X-Host-Fingerprint: 64.233.162.200 zproxy.gmail.com Linux 2.4/2.6 Received: from ([64.233.162.200:12683] helo=zproxy.gmail.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 24/78-32596-6B2FDC34 for ; Wed, 18 Jan 2006 02:48:06 -0500 Received: by zproxy.gmail.com with SMTP id o1so1706215nzf for ; Tue, 17 Jan 2006 23:48:01 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=VZ1FodmgCZKGio/6rGU/Gfb7NqZlR4SonGconACq3sVZlIWdUeM0rJL0pMq0HW09mfGBQUoL6DSszGrROC8iDGXAdXyc6e/CLZjTo0hXBimX9xWD5w+UDegNG5qrJrNGzkvNH0GXtDtHs6tgqT9jjsbXHupJY+DH9Ft8fw9lVno= Received: by 10.36.196.12 with SMTP id t12mr6424526nzf; Tue, 17 Jan 2006 23:48:01 -0800 (PST) Received: by 10.36.100.2 with HTTP; Tue, 17 Jan 2006 23:48:01 -0800 (PST) Message-ID: <90e24d4e0601172348k1275e5cey17ce74ace3ebadff@mail.gmail.com> Date: Tue, 17 Jan 2006 23:48:01 -0800 To: steve Cc: Zeev Suraski , internals@lists.php.net In-Reply-To: <57792e850601171808x540205b9ubc81e2f1475a3ae9@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <11370812947200000@9866357972520000.9866341568840000> <43C688AE.80403@php.net> <43C69B2A.8000802@php.net> <21.B4.29075.F75A6C34@pb1.pair.com> <54.A8.13436.BE6F9C34@pb1.pair.com> <7.0.1.0.2.20060115112107.06375638@zend.com> <57792e850601171808x540205b9ubc81e2f1475a3ae9@mail.gmail.com> Subject: Re: [PHP-DEV] Re: Named arguments revisited From: phpdev@gmail.com (Jeremy Johnstone) Just to throw in my two cents since every one else has (not that my 2 cents is worth anything more than just that), but isn't it as easy as doing something like the following: (using pseudo example from above) function db_connect($params) { $host =3D 'localhost'; $user =3D 'root'; $password =3D ''; $port =3D 3301; extract($params, EXTR_OVERWRITE); // ... more code here } This covers the default parameters in a clean fashion which is easy to understand and should be readable to anyone who knows PHP in even the slightest fashion. Now to the issue of type hinting, it's as simple as doing something like the following: if(!($obj instanceOf ClassName)) { throw new Exception(); } Then you have complete control of how the error is handled (be it exceptions, trigger_error(), etc). To me, it seems the options are a LOT more flexible using array syntax than using actual named parameters, but maybe that's just me. To each their own, but if it were me, it seems the above not only is easier to use / read, but also guaranteed to work on almost all versions of PHP (at least in the case of the first code snippet). -- --------------------------- Jeremy Johnstone http://www.jeremyjohnstone.com jsjohnst@php.net