Newsgroups: php.internals
Path: news.php.net
Xref: news.php.net php.internals:38648
Return-Path: <waqner@gmx.net>
Mailing-List: contact internals-help@lists.php.net; run by ezmlm
Delivered-To: mailing list internals@lists.php.net
Received: (qmail 47562 invoked from network); 26 Jun 2008 20:47:50 -0000
Received: from unknown (HELO lists.php.net) (127.0.0.1)
  by localhost with SMTP; 26 Jun 2008 20:47:50 -0000
Authentication-Results: pb1.pair.com smtp.mail=waqner@gmx.net; spf=pass; sender-id=pass
Authentication-Results: pb1.pair.com header.from=waqner@gmx.net; sender-id=pass
Received-SPF: pass (pb1.pair.com: domain gmx.net designates 213.165.64.20 as permitted sender)
X-PHP-List-Original-Sender: waqner@gmx.net
X-Host-Fingerprint: 213.165.64.20 mail.gmx.net  
Received: from [213.165.64.20] ([213.165.64.20:57241] helo=mail.gmx.net)
	by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP
	id 08/C9-17914-47004684 for <internals@lists.php.net>; Thu, 26 Jun 2008 16:47:49 -0400
Received: (qmail invoked by alias); 26 Jun 2008 20:47:44 -0000
Received: from p5087BF4F.dip.t-dialin.net (EHLO p5087bf4f.dip.t-dialin.net) [80.135.191.79]
  by mail.gmx.net (mp066) with SMTP; 26 Jun 2008 22:47:44 +0200
X-Authenticated: #27239598
X-Provags-ID: V01U2FsdGVkX1+6DGAVD7e6fIJZYUEW/jE1JBTMdqazw2nW9Im7lr
	4MKyboCduaRsHS
To: internals@lists.php.net
Date: Thu, 26 Jun 2008 22:46:23 +0200
User-Agent: KMail/1.9.9
Cc: Christian Seiler <chris_se@gmx.net>,
 Dmitry Stogov <dmitry@zend.com>,
 Andi Gutmans <andi@zend.com>,
 Stanislav Malyshev <stas@zend.com>
References: <4856A547.3080801@gmx.net> <485B908D.7000106@zend.com> <4863C299.1080002@gmx.net>
In-Reply-To: <4863C299.1080002@gmx.net>
MIME-Version: 1.0
Content-Type: text/plain;
  charset="utf-8"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Message-ID: <200806262246.24193.waqner@gmx.net>
X-Y-GMX-Trusted: 0
Subject: Re: [PHP-DEV] [PATCH] [RFC] Closures and lambda functions in PHP
From: waqner@gmx.net (Alexander Wagner)

>   * I added tests (Zend/tests/closures_*.phpt) that ensure the correct
>     behaviour of closures.

I'd like to propose an additional test to ensure closures can all themselves:
<?php
$i = 3;

$lambda = function ($lambda) use ($i) {
    if ($i==0) return;
    echo $i--."\n";
    $lambda($lambda);
};

$lambda($lambda);
echo "$i\n";
?>
Expected output:
3
2
1
3

I see exactly one problem with the patch, which is that the above script 
shouldn't work without "use (&$i)".
I find it counterintuitive that the creation of the lambda creates a copy of 
$i, but all invocations of $lambda use a reference to the same $i.
For n calls to $lambda, there are only 2 copies of $i (one global, one static 
in $lambda) where I would expect n+1 copies.

Gesundheit
  Wag

-- 
Sieh dich, nimm Sorge.