Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:32312 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 23645 invoked by uid 1010); 13 Sep 2007 13:43:42 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 23629 invoked from network); 13 Sep 2007 13:43:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Sep 2007 13:43:42 -0000 Authentication-Results: pb1.pair.com header.from=helly@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=helly@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 85.214.94.56 as permitted sender) X-PHP-List-Original-Sender: helly@php.net X-Host-Fingerprint: 85.214.94.56 aixcept.net Linux 2.6 Received: from [85.214.94.56] ([85.214.94.56:47237] helo=h1149922.serverkompetenz.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BD/96-18959-C8E39E64 for ; Thu, 13 Sep 2007 09:43:41 -0400 Received: from dhcp-172-28-204-149.zrh.corp.google.com (unknown [193.142.125.1]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by h1149922.serverkompetenz.net (Postfix) with ESMTP id 0453A1B360C; Thu, 13 Sep 2007 15:43:36 +0200 (CEST) Date: Thu, 13 Sep 2007 15:43:36 +0200 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <14896301.20070913154336@marcus-boerger.de> To: Andrew Shearer CC: Lukas Kahwe Smith , Robert Cummings , In-Reply-To: References: <27DA5A7A-276C-480F-A75C-7F64BB38316B@ashearer.com> <142319111.20070911112759@marcus-boerger.de> <1262949578.20070911172112@marcus-boerger.de> <17c19be0709110933m537df263pfae99322b8ae0b32@mail.gmail.com> <702402878.20070911185402@marcus-boerger.de> <1189531022.30041.88.camel@blobule> <421016323.20070912101332@marcus-boerger.de> <17c19be0709121053u617071beq8d420926f60db46f@mail.gmail.com> <46E82F23.2000506@pooteeweet.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [PATCH] array_get() From: helly@php.net (Marcus Boerger) Hello Andrew, if we go the array_get() route as a short half solution to hopefully make a lot of people happy (at least it would serve $_GET/_REQUEST etc needs). Then I think we should make it a bit more useable: Get the default or the multilevel subscription of $ar proto mixed array_get(array $ar, mixed index*, mixed $default) function array_get(array $ar) { $ret = $ar; for ($i=1; $i < func_num_args() - 1; ++$i) { $idx = func_get_arg($i); if (array_key_exists($idx, $ret)) { $ret = $ret[$idx]; } else { if (func_num_args() > 1) { return func_get_arg(func_num_args() - 1); } else { return NULL; } } } return $ret; } best regards marcus Thursday, September 13, 2007, 2:54:51 PM, you wrote: > On Sep 12, 2007, at 2:25 PM, Lukas Kahwe Smith wrote: >> Andrew Shearer wrote: >> >>> Meanwhile, array_get() provides the most-needed functionality >>> while avoiding >>> the issues that prevented ifsetor's acceptance. >> >> Aside from lack of BC hacks what is the issue? I remember some >> fussing about the name, but I find this a joke of an argument. You >> cant get much clearer a name than ifsetor(). >> >>> There's a backward compatibility problem with ifsetor: its special >>> syntax >>> means that there's no way to write a pure-PHP userland version of >>> it. The >>> effect is that there's no upgrade path for applications that have to >>> straddle both old and new versions of PHP, and practical >>> usefulness of >>> ifsetor would be delayed for years after release. >> >> >> I use ifsetor() type functionality on a daily basis. As such I >> would appreciate it if it would be an operator and would make its >> way not only into php 6, but also php 5.3. >> >> Marcus's half solution is not a solution to what I need. Andrew's >> solution gets close enough to solve my real world needs. Now if I >> could just see the slightest bit if a real argument against ifsetor >> (), I might even vote for array_get() (not sure if I appreciate the >> name though). >> >> regards, >> Lukas > I think we want the same thing. We both want the essential > functionality in PHP one way or another. If ifsetor was in the > running now, I'd support it. But after seeing the discussion and lack > of consensus on it since 2004, I'm sure that the best way to reach > the goal is to champion array_get(). > Other suggestions for the name are welcome, but the choice of it was > careful. array_get() has at least one precendent, the Python dict.get > () method, which works basically the same way. The fact that the same > name and function signature (give or take a reference) was also > suggested completely independently in a PHP wishlist item means it's > probably on the right track. > -- > Andrew Shearer > http://ashearer.com/ Best regards, Marcus