Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:47779 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 31849 invoked from network); 4 Apr 2010 23:08:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Apr 2010 23:08:28 -0000 Authentication-Results: pb1.pair.com header.from=johannes@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=johannes@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 83.243.58.134 as permitted sender) X-PHP-List-Original-Sender: johannes@php.net X-Host-Fingerprint: 83.243.58.134 mailout2.netbeat.de Linux 2.6 Received: from [83.243.58.134] ([83.243.58.134:39952] helo=mailout2.netbeat.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 70/B0-41826-BEB19BB4 for ; Sun, 04 Apr 2010 19:08:28 -0400 Received: (qmail 16669 invoked by uid 89); 4 Apr 2010 23:04:55 -0000 Received: from unknown (HELO ?192.168.1.28?) (postmaster%schlueters.de@93.104.48.67) by mailout2.netbeat.de with ESMTPA; 4 Apr 2010 23:04:55 -0000 X-Originator: 9e51b244e0a38413ab6a9876e36ba9df To: Gregory Cc: Stanislav Malyshev , Hannes Magnusson , internals@lists.php.net, Rasmus Lerdorf In-Reply-To: <4BB91281.5070603@gregory.net> References: <745C5243-EB51-4D43-B036-8A34CDBBB547@gregory.net> <4BB68D61.2070301@lerdorf.com> <4BB6938F.7090404@zend.com> <4BB90DB7.6060706@zend.com> <4BB91281.5070603@gregory.net> Content-Type: text/plain; charset="UTF-8" Organization: php.net Date: Mon, 05 Apr 2010 01:08:15 +0200 Message-ID: <1270422495.8681.21.camel@guybrush> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Named Parameters From: johannes@php.net (Johannes =?ISO-8859-1?Q?Schl=FCter?=) Hi, I'm not fully convinced we really need it, I had some moments in the past where I wished they existed, but always found good solutions. That said: On Sun, 2010-04-04 at 18:28 -0400, Gregory wrote: > The question I have is if we are not copying the array semantics > anymore, whether we should have abc('a' => 3) or abc(a => 3). I > personally would prefer 'a' => 3 because that allows for variable > parameter names. Allowing variable parameter names means allowing any expression (else it gets messy with inconsistent rules) which means that we allow a very flexible syntax which might lead to code that's hard to understand. If you don't know which parameters you want to provide maybe an array is the better option. With such a syntax I expect more abuse than useful use of the feature. For do_something(parameter => 23); we have the benefit, that IDEs could easily validate that which prevents typos and provide aid. But then I'm not sure this fits to the language either as we always expect quoted names. And from the some distance this looks like a constant used used as parameter name, as in 'bar'); do_something(foo => 'bar'); ?> Another possible limitation there is that our parser won't allow keywords there. An example where this might be annoying might be something along these lines: createInstance($param1, $param2); } getInstance(class => 'my_class'); ?> Just some random thoughts, maybe somebody has a better syntax, maybe that's just me, johannes