Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:21502 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 71388 invoked by uid 1010); 13 Jan 2006 08:08:33 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 71373 invoked from network); 13 Jan 2006 08:08:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Jan 2006 08:08:33 -0000 X-Host-Fingerprint: 212.112.227.169 ipx11223.ipxserver.de Linux 2.5 (sometimes 2.4) (4) Received: from ([212.112.227.169:44021] helo=ipx11223.ipxserver.de) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id E6/A3-25674-FFF57C34 for ; Fri, 13 Jan 2006 03:08:31 -0500 Received: from localhost (localhost [127.0.0.1]) by ipx11223.ipxserver.de (Postfix) with ESMTP id D32B3DF011A; Fri, 13 Jan 2006 09:08:28 +0100 (CET) Received: from ipx11223.ipxserver.de ([127.0.0.1]) by localhost (ipx11223 [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 05599-04; Fri, 13 Jan 2006 09:08:18 +0100 (CET) Received: from [127.0.0.1] (i577B73E4.versanet.de [87.123.115.228]) by ipx11223.ipxserver.de (Postfix) with ESMTP id E9BB7DF00D7; Fri, 13 Jan 2006 09:08:17 +0100 (CET) Message-ID: <43C75FEE.7040908@php.net> Date: Fri, 13 Jan 2006 09:08:14 +0100 User-Agent: Thunderbird 1.5 (Windows/20051201) MIME-Version: 1.0 To: Andi Gutmans Cc: internals@lists.php.net References: <43C67431.9090003@prohost.org> <3A366ACB-20D4-42C7-BBAE-46F643E3A91F@intuitivefuture.com> <878581203.20060112153625@ionzoft.com> <7.0.0.16.2.20060112154219.029d06c8@zend.com> In-Reply-To: <7.0.0.16.2.20060112154219.029d06c8@zend.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by somedaemon at backendmedia.com Subject: Re: [PHP-DEV] Re: Named arguments revisited From: lsmith@php.net (Lukas Smith) Andi Gutmans wrote: > In my opinion, as Ilia stated passing an associative array does the job > quite well for the use-case where named arguments would be useful. > Sure it might be a tad-bit sexier that you don't have to write array() > but the truth is that the implementation would probably still use an > array. Unlike Ada which has extremely strict typing, in PHP in most > cases we wouldn't be able to optimize away the named parameters, meaning > that we'd probably do the array() trick anyway. You are argueing from a php internal level. Named parameters are useful for situations where you have alot of parameters. I think people have shown that this may not be the common case, but its still very much real. People have shown ways to handle default values fairly efficiently. However this still dances around the language level documentation. It also dances around the need for error handling entirely. Of course you could also hack in some checks using array_diff() to determine if there are any unwanted parameters and then trigger an error. Now we have not even addressed the potential for type hinted parameters. However this means adding a fair amount of LOC, that are much less obvious to read. Performance in this case is not the main factor, but if oyu add in a call to array_diff() with a !empty() if statement I think its hard to argue that the performance would be equal either. Also contrary to alot of the things we have added since php 5.x I think this language feature would be much more obvious and easy to grasp even without reading any documentation on it. As such it very much fits the PHP style and has very little risk of obfuscating the language. Now obviously there would have to be someone to implement it, but I see no "design" reason to not allow this feature in. regards, Lukas