Newsgroups: php.internals
Path: news.php.net
Xref: news.php.net php.internals:38442
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 71346 invoked from network); 20 Jun 2008 01:52:17 -0000
Received: from unknown (HELO lists.php.net) (127.0.0.1)
  by localhost with SMTP; 20 Jun 2008 01:52:17 -0000
Authentication-Results: pb1.pair.com header.from=waqner@gmx.net; sender-id=pass
Authentication-Results: pb1.pair.com smtp.mail=waqner@gmx.net; spf=pass; 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:41848] helo=mail.gmx.net)
	by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP
	id 0B/33-54491-F4D0B584 for <internals@lists.php.net>; Thu, 19 Jun 2008 21:52:16 -0400
Received: (qmail invoked by alias); 20 Jun 2008 01:52:12 -0000
Received: from p5087EECC.dip.t-dialin.net (EHLO p5087eecc.dip.t-dialin.net) [80.135.238.204]
  by mail.gmx.net (mp063) with SMTP; 20 Jun 2008 03:52:12 +0200
X-Authenticated: #27239598
X-Provags-ID: V01U2FsdGVkX19EM6UZm15EKwppw7K+AZnR60HRJvgZ7O+sgoBd36
	34i0akk6RYlhCi
To: internals@lists.php.net
Date: Fri, 20 Jun 2008 03:52:12 +0200
User-Agent: KMail/1.9.9
Cc: Stanislav Malyshev <stas@zend.com>,
 Christian Seiler <chris_se@gmx.net>
References: <4856A547.3080801@gmx.net> <200806200146.25898.waqner@gmx.net> <485B0014.9090901@zend.com>
In-Reply-To: <485B0014.9090901@zend.com>
MIME-Version: 1.0
Content-Type: text/plain;
  charset="utf-8"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Message-ID: <200806200352.13468.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)

On Friday 20 June 2008, Stanislav Malyshev wrote:
> * A closure must be able to call itself recursively (via a
> higher-order function typically)
> [Check, since you can use variable you assigned closure to inside the
> closure, if I understand correctly]

This is a matter of implementation rather than design, so it should be 
resolved by testing rather than by reading the spec ;-)

> Well, I don't see any other way if you use references. Variables _are_
> mutable in PHP.

They are also copied by default (passed by value). So if lexical used copies 
by default (and passed objects by reference), it would be consistent with all 
of php except for global. Let global be the outcast and be consistent with 
exerything else. As long as references are easily available, I think this is 
the much better trade-off. And it makes water slightly cheaper than beer.

> I know function()() is weird

And would become weirder if foo(1)(2) is implemented. +1 to that by the way, 
allowing dereferencing for methods ( $obj->method1()->method2(); ) but not 
for functions is kinda mean.

Maybe function( ) [ ] { } instead of function( ) ( ) { }
That way the different parts actually look different. Also, confusion with 
arrays should be pretty much impossible here, both for the parser and human 
readers.

I prefer "lexical", though. Functional programming is not the default paradigm 
in PHP, so rather err on the side of explicitness.

Gesundheit
  Wag

-- 
Remember, growing older is mandatory. Growing up is optional.