Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:28553 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 68020 invoked by uid 1010); 22 Mar 2007 15:12:53 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 68005 invoked from network); 22 Mar 2007 15:12:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Mar 2007 15:12:53 -0000 Authentication-Results: pb1.pair.com smtp.mail=cschneid@cschneid.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=cschneid@cschneid.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain cschneid.com from 195.141.85.117 cause and error) X-PHP-List-Original-Sender: cschneid@cschneid.com X-Host-Fingerprint: 195.141.85.117 uf1.search.ch Linux 2.4/2.6 Received: from [195.141.85.117] ([195.141.85.117:43572] helo=smtp.rim.ch) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2F/C2-46365-4FC92064 for ; Thu, 22 Mar 2007 10:12:53 -0500 Received: from localhost (localhost [127.0.0.1]) by rolig.search.ch (Postfix) with ESMTP id 3282E1EED73; Thu, 22 Mar 2007 16:12:49 +0100 (CET) Received: from smtp.rim.ch ([127.0.0.1]) by localhost (search.ch [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 13986-05; Thu, 22 Mar 2007 16:12:48 +0100 (CET) Received: from [192.168.1.72] (ultrafilter-i [192.168.85.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by rolig.search.ch (Postfix) with ESMTP id 2114A1EECBF; Thu, 22 Mar 2007 16:12:48 +0100 (CET) Message-ID: <46029CEF.8000003@cschneid.com> Date: Thu, 22 Mar 2007 16:12:47 +0100 User-Agent: Thunderbird 1.5.0.10 (X11/20060911) MIME-Version: 1.0 To: Michael Walter CC: internals@lists.php.net References: <86478A67-DCA2-4000-9EF0-DA4338E8389B@omniti.com> <45FF01FE.6070504@zend.com> <698DE66518E7CA45812BD18E807866CE185525@us-ex1.zend.net> <698DE66518E7CA45812BD18E807866CE18559A@us-ex1.zend.net> <40259.216.230.84.67.1174435351.squirrel@www.l-i-e.com> <877e9a170703220436l267d2648jc99aaaf9cccecfdd@mail.gmail.com> <46028001.7060204@cschneid.com> <877e9a170703220719w4badd5a6y4345b508b3866131@mail.gmail.com> <46029216.9090205@cschneid.com> <877e9a170703220754u6cd52b66gf3fe056491c6c921@mail.gmail.com> In-Reply-To: <877e9a170703220754u6cd52b66gf3fe056491c6c921@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: amavisd-new at search.ch Subject: Re: [PHP-DEV] PATCH: anonymous functions in PHP From: cschneid@cschneid.com (Christian Schneider) Michael Walter wrote: > A simple real-life example is: > function pick($member) > { > return create_function('$x', 'return $x->'.$member.';'); > } > > which could be used e.g. in > array_map(pick('age'), $people). > Arguably, in this case you could as well write: > array_map(function($p) {return $p->age;}, $people); > but I believe it is easy to see how the problem generalizes. Funnily enough you already show how this can currently be done. My point would be to make simple things simple and keep complicated things possible. As it is right now. So I'd use array_map(function($p) {return $p->age;}, $people); or usort($a, function($a, $b) { return strcmp($a->lastname, $b->lastname); }); to do Stefan Walk's example. But something like your pick function using create_function if I *really* wanted something more fancy. - Chris