Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:43242 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79281 invoked from network); 4 Mar 2009 12:09:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Mar 2009 12:09:36 -0000 Authentication-Results: pb1.pair.com header.from=ionut.g.stan@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=ionut.g.stan@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.134.186 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: ionut.g.stan@gmail.com X-Host-Fingerprint: 209.85.134.186 mu-out-0910.google.com Received: from [209.85.134.186] ([209.85.134.186:39513] helo=mu-out-0910.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FA/11-07946-F7F6EA94 for ; Wed, 04 Mar 2009 07:09:35 -0500 Received: by mu-out-0910.google.com with SMTP id w1so1089783mue.3 for ; Wed, 04 Mar 2009 04:09:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=jYMRnirf4pQYtSvoFOZReRsHQRQ5rBN65bJ8Eqo1+qY=; b=wF1AExJypjPE4o+j3iRl4/LmFY6SKbDfwejVxYQTQGLSWl9g3nlyYZpFRxMEaSAlW4 dabLY84qm77h0AlAAXwO6cNslFzbyrKsBFqS/3HtoKR0j6w9pluYrAdp3Az2tbB72lco 5vG8MdwOiKCDP4iB2bZD5/5w8jPgib2PGV+Bc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=qid0XUiDavzAFPoZvYhnvDTeg5tJ25DFyqifyiJBNSDQ+x8BEW63PmOVYspAAWFBL4 RRHyLcev/l5DgZKOYvk5ya8SuMOdmngzRir/QxkuodczhsoBqJnGCtxM+DTOugQbGs/G 2aHeQlTF7ltYQuQgFw+MkVWpX0Rss76d5wejU= Received: by 10.103.251.3 with SMTP id d3mr4133629mus.72.1236168572196; Wed, 04 Mar 2009 04:09:32 -0800 (PST) Received: from ?10.0.0.187? (mail.cmbtravel.ro [84.234.105.22]) by mx.google.com with ESMTPS id j2sm4137009mue.24.2009.03.04.04.09.31 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 04 Mar 2009 04:09:31 -0800 (PST) Message-ID: <49AE6F18.2020006@gmail.com> Date: Wed, 04 Mar 2009 14:07:52 +0200 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1b3pre) Gecko/20090223 Thunderbird/3.0b2 MIME-Version: 1.0 To: RQuadling@googlemail.com CC: PHP Internals List References: <10845a340903040333g5fd001fdw73fc17eacbd968c9@mail.gmail.com> In-Reply-To: <10845a340903040333g5fd001fdw73fc17eacbd968c9@mail.gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Are there plans to allow anonymous functions as callbacks? From: ionut.g.stan@gmail.com ("Ionut G. Stan") You need PHP 5.3 for that. Here's the RFC: http://wiki.php.net/rfc/closures On 3/4/2009 13:33, 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. > > > A real alternative though would be to allow nested functions... > > function cube_array($a) { > function cube($n) { > return($n * $n * $n); > } > return array_map("cube", $a); > } > $a = array(1, 2, 3, 4, 5); > $b = cube_array($a); > print_r($b); > > Ideally, cube() would not be visible outside of cube_array(). Scoped functions. > > Regards, > > Richard Quadling. -- Ionut G. Stan I'm under construction | http://igstan.blogspot.com/