Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:43243 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80778 invoked from network); 4 Mar 2009 12:16:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Mar 2009 12:16:36 -0000 Authentication-Results: pb1.pair.com header.from=php-dev.list@daevel.net; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=php-dev.list@daevel.net; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain daevel.net designates 91.121.160.166 as permitted sender) X-PHP-List-Original-Sender: php-dev.list@daevel.net X-Host-Fingerprint: 91.121.160.166 scrubby.daevel.fr Linux 2.6 Received: from [91.121.160.166] ([91.121.160.166:36962] helo=scrubby.daevel.fr) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3E/61-07946-3217EA94 for ; Wed, 04 Mar 2009 07:16:36 -0500 Received: from 213-245-197-58.rev.numericable.fr ([213.245.197.58] helo=[192.168.1.3]) by scrubby.daevel.fr with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.68) (envelope-from ) id 1Leq1Y-0006EU-Aa for internals@lists.php.net; Wed, 04 Mar 2009 13:16:32 +0100 Message-ID: <49AE7125.7000108@daevel.net> Date: Wed, 04 Mar 2009 13:16:37 +0100 User-Agent: Mozilla-Thunderbird 2.0.0.19 (X11/20090103) MIME-Version: 1.0 To: PHP Internals List References: <10845a340903040333g5fd001fdw73fc17eacbd968c9@mail.gmail.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] Are there plans to allow anonymous functions as callbacks? From: php-dev.list@daevel.net ("Olivier B.") Alexey Zakhlestin a écrit : > On Wed, Mar 4, 2009 at 2:33 PM, Richard Quadling > wrote: > >> Hi. >> >> Quite a simple question (assuming I've got the terminology correct). >> >> Are there any plans to allow code like this (amended example taken >> from the array_map() documentation) ... >> >> > $a = array(1, 2, 3, 4, 5); >> $b = array_map(function($n){return($n * $n * $n)}, $a); >> print_r($b); >> >> For me, this is cleaner than having a use-once, namespace-polluting function. >> >> Currently, this is producing a parse error. >> > > It works. You have a typo. You need to put ";" after return (…) > > Hi, with PHP < 5.3, you can also use create_function() (http://www.php.net/create_function )