Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:28505 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 81893 invoked by uid 1010); 21 Mar 2007 00:02:31 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 81877 invoked from network); 21 Mar 2007 00:02:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Mar 2007 00:02:31 -0000 Authentication-Results: pb1.pair.com header.from=ceo@l-i-e.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=ceo@l-i-e.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain l-i-e.com from 67.139.134.202 cause and error) X-PHP-List-Original-Sender: ceo@l-i-e.com X-Host-Fingerprint: 67.139.134.202 o2.hostbaby.com FreeBSD 4.7-5.2 (or MacOS X 10.2-10.3) (2) Received: from [67.139.134.202] ([67.139.134.202:4562] helo=o2.hostbaby.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 89/23-48444-51670064 for ; Tue, 20 Mar 2007 19:02:30 -0500 Received: (qmail 82573 invoked by uid 98); 21 Mar 2007 00:02:31 -0000 Received: from 127.0.0.1 by o2.hostbaby.com (envelope-from , uid 1013) with qmail-scanner-1.25 (clamdscan: 0.88.7/2880. Clear:RC:1(127.0.0.1):. Processed in 0.108848 secs); 21 Mar 2007 00:02:31 -0000 X-Qmail-Scanner-Mail-From: ceo@l-i-e.com via o2.hostbaby.com X-Qmail-Scanner: 1.25 (Clear:RC:1(127.0.0.1):. Processed in 0.108848 secs) Received: from localhost (HELO l-i-e.com) (127.0.0.1) by localhost with SMTP; 21 Mar 2007 00:02:31 -0000 Received: from 216.230.84.67 (SquirrelMail authenticated user ceo@l-i-e.com) by www.l-i-e.com with HTTP; Tue, 20 Mar 2007 19:02:31 -0500 (CDT) Message-ID: <40259.216.230.84.67.1174435351.squirrel@www.l-i-e.com> In-Reply-To: <698DE66518E7CA45812BD18E807866CE18559A@us-ex1.zend.net> References: <86478A67-DCA2-4000-9EF0-DA4338E8389B@omniti.com> <45FDF031.4010508@zend.com> <45FE2312.1050506@zend.com> <45FED6D9.8030307@caedmon.net> <45FEDAE5.2010309@zend.com> <45FEE396.7040905@caedmon.net> <0757BDEA-65F5-4123-B647-060DCA84B4B0@omniti.com> <45FEEF52.1060002@zend.com> <1174336464.24632.110.camel@blobule> <45FEF9A5.4050409@zend.com> <1174338801.24632.124.camel@blobule> <45FEFDCE.7050100@zend.com> <1174339527.24632.129.camel@blobule> <45FF01FE.6070504@zend.com> <698DE66518E7CA45812BD18E807866CE185525@us-ex1.zend.net> <698DE66518E7CA45812BD18E807866CE18559A@us-ex1.zend.net> Date: Tue, 20 Mar 2007 19:02:31 -0500 (CDT) To: "Andi Gutmans" Cc: "Wez Furlong" , "Stas Malyshev" , "Robert Cummings" , "Sean Coates" , internals@lists.php.net Reply-To: ceo@l-i-e.com User-Agent: Hostbaby Webmail MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal Subject: RE: [PHP-DEV] PATCH: anonymous functions in PHP From: ceo@l-i-e.com ("Richard Lynch") On Mon, March 19, 2007 11:59 pm, Andi Gutmans wrote: > There are various ways to go about implementing this. While reading > your > email I've had another couple of ideas incl. some funky parameter > passing games. All these ideas are legit and have pros/cons but what's > most important is actually from a feature point of view, whether we > want > to do something, and if so what. > So I think the questions are: > a) Do we want to support another way to create anonymous functions ala > create_function, even if it doesn't allow binding to values (closures) > from the outer scope (which create_function() supports doing by value; > by embedding variables in the string). > b) If the answer is yes, then do we want to have a syntax (ala > $_SCOPE["i"] or similar)? If so, what does it do? Does it bind to > outer > variables or does it "embed" the values. If the latter, do we care > more > about the actual functionality or performance. > > I hope these questions are clear. I think we need to be very careful > when going down this route because some have already alluded that it > might be confusing and not quite the PHP spirit, on the other hand > there > are also valid reasons for doing it. In any case, if we go down this > route we should be crystal clear in what behavior we expect and need > to > feel comfortable that it doesn't have a high wtf-factor associated > with > it. > > I need to sleep on it and think about it a bit more tomorrow. > > Thoughts? I think any kind of anonymous function is going to have somewhat of a wtf factor. Adding in the full-blown closure and scoping definitions is geometrically more wtf factor. I realize that it's a really cool thing, and fun to mess with, and the CS Major / AI Researcher in me is screaming "go for it"... But the pragmatic PHP user and mailing-list-answer-guy inside me is saying "Hell no" :-) After a night's sleep... I think solving the common need for 99% of the people with a nice simple clean anonymous function is PHP way. Adding the complexity of closures and scoping rules is, imho, not the PHP way because it's just so esoteric and complex. If somebody has a real-life demonstrated NEED for the closures/scoping, by all means, bring it up. But, so far, it seems like it's been more "wow, this would be really geeky cool!"... There's nothing wrong with being geeky cool, but it's not something that should be thrown into all day every day workhorse of PHP core, imho. Of course, I've also figured out that maybe the reason that all this came up is that it's dead easy to write it with a full-blown closure/scope system, even if it's not real clear what the actual rules are, than it is to restrict it to dis-allow that... I dunno what to say to that, other than to, perhaps, leave the simple implementation there, and document the use of out-of-scope variables as "undefined"... Though that will probably end up with a bunch of scripters using out-of-scope vars with no clue what they just did and how morally wrong it was to use an intentionally undocumented feature. But if that's the best that can be done with the resources available, I think it would be a good compromise. Especially as it leaves open the possiblity of someday nailing down a complete clear definition of what the scoping rules turn out to be, with room for experimentation in the meantime without violating BC. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So?