Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:48182 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4548 invoked from network); 3 May 2010 21:35:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 May 2010 21:35:03 -0000 Authentication-Results: pb1.pair.com smtp.mail=tjerk.meesters@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=tjerk.meesters@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.170 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: tjerk.meesters@gmail.com X-Host-Fingerprint: 209.85.160.170 mail-gy0-f170.google.com Received: from [209.85.160.170] ([209.85.160.170:57870] helo=mail-gy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 46/81-09795-6814FDB4 for ; Mon, 03 May 2010 17:35:02 -0400 Received: by gyf2 with SMTP id 2so1396288gyf.29 for ; Mon, 03 May 2010 14:34:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=suAE0KDLc4CKdGZe1iRSHSpRzPUEmlZiFqe5w1rMMD0=; b=X7TGO3ytaLXNddpNcQE/1jNgqLT9Y/WR4Zr4lDzuhu08PlMaZ28ZAzGMFl7uvoYTCr BHrgoJDXBi3jQne3oJXUlLqc5czEbPefu89U4tKwI3w2P7cB4rehvI171YDAOrwWSZEk KEW9qmQZu9ZBiFTlxLFQ4sj9DtihZBiy9Wubs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=UJs68vSFRPvypWUCiDU64svYJNxs+sYeqIGvacvXZkLBS5WP+RqBt0+CXpQaxHQYKP NqCICG18hMMi/ZuBh5BssY7sGHIVbT7J7yixm0N11pWFVXQ36biuOq+xuSThO/Kpn+sO UJnkNDVt6qXOT0J0kukODCEOiuG7y31uqvltE= MIME-Version: 1.0 Received: by 10.150.172.7 with SMTP id u7mr10172060ybe.248.1272922499504; Mon, 03 May 2010 14:34:59 -0700 (PDT) Sender: tjerk.meesters@gmail.com Received: by 10.150.51.15 with HTTP; Mon, 3 May 2010 14:34:59 -0700 (PDT) In-Reply-To: <4BDEEEDA.1050806@cschneid.com> References: <4BDEC91F.9080305@easyflirt.com> <4BDEEEDA.1050806@cschneid.com> Date: Tue, 4 May 2010 05:34:59 +0800 X-Google-Sender-Auth: e0d3a74d7f5c148d Message-ID: To: Christian Schneider Cc: "mathieu.suen" , PHP internals Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Re: Closure local return From: datibbaw@php.net (Tjerk Anne Meesters) On Mon, May 3, 2010 at 11:42 PM, Christian Schneider wrote: > mathieu.suen wrote: >> May be it could be interesting to have a syntax for returning from the >> define scope. >> For example. >> >> $findedElment =3D $myList->selectIfAbsent($fooo, function(){ >> =A0 =A0 return 'No item founded'; //Retrun from the define scope >> }) >> //Do somthing with $findedElment > > I think you actually misunderstand the difference in > http://en.wikipedia.org/wiki/Closure_%28computer_science%29#Differences_i= n_semantics > > The way I read if the difference is wether it returns from the closure > function or the surrounding function *calling* it. Not the *defining* sco= pe. Mathieu is right in that it would return from the defining scope, but it's important to note that when the closure is called the function that defined the closure is still on the stack. Consider the following example: function f() { return function() { return; } } $c =3D f(); $c(); If the semantics of Smalltalk were to apply, this would give an error, because it's impossible to return from f() when the closure is being called. > > And no, it doesn't make sense in the PHP context IMHO. I second that ;-) In terms of clarity I find that the ECMAScript implementation is much clearer. > > - Chris > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --=20 -- Tjerk