Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:38756 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 12566 invoked from network); 4 Jul 2008 09:18:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Jul 2008 09:18:15 -0000 Authentication-Results: pb1.pair.com smtp.mail=johannes@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=johannes@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 83.243.58.163 as permitted sender) X-PHP-List-Original-Sender: johannes@php.net X-Host-Fingerprint: 83.243.58.163 mail4.netbeat.de Received: from [83.243.58.163] ([83.243.58.163:43007] helo=mail4.netbeat.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B0/B2-14155-5DAED684 for ; Fri, 04 Jul 2008 05:18:14 -0400 Received: (qmail 21567 invoked by uid 507); 4 Jul 2008 09:18:08 -0000 Received: from ppp-82-135-93-166.dynamic.mnet-online.de (HELO ?192.168.1.102?) (postmaster%schlueters.de@82.135.93.166) by mail4.netbeat.de with ESMTPA; 4 Jul 2008 09:18:08 -0000 To: Dmitry Stogov Cc: Andi Gutmans , Lukas Kahwe Smith , Christian Seiler , php-dev List In-Reply-To: <486D1AD3.3080708@zend.com> References: <486B6960.4030705@gmx.net> <3F379336-B4DC-4495-AD76-3D52ED703E0E@pooteeweet.org> <486C7F5F.3080007@zend.com> <698DE66518E7CA45812BD18E807866CE01C3A902@us-ex1.zend.net> <486D1AD3.3080708@zend.com> Content-Type: text/plain; charset=UTF-8 Date: Fri, 04 Jul 2008 11:18:08 +0200 Message-ID: <1215163088.32294.9.camel@goldfinger.johannes.nop> Mime-Version: 1.0 X-Mailer: Evolution 2.22.2 (2.22.2-2.fc9) Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] [RFC] Closures: updated proposal and patch From: johannes@php.net (Johannes =?ISO-8859-1?Q?Schl=FCter?=) Hi, On Thu, 2008-07-03 at 22:30 +0400, Dmitry Stogov wrote: > I don't see big problems with closures. The patch is simple and stable. > It's main part isolated in zend_closures.c and it doesn't affect other > parts of engine. Changes too the languages always introduce some side effects and therefore we have too be careful there. Even stuff which is from engine point of view nice might have some effects on the userland which might not be too nice, just see the ongoing discussions about details about namespaces... But back to closures: I spent the last weeks with less mail reading and am still 112 mails on internals behind so maybe I missed something there but even short tests showed me things which might need cleanup: A tiny thing I saw is different naming in different places: php -r 'is_callable((function () {}), true, $name); var_dump($name);' string(6) "lambda" vs. php -r 'var_dump(function(){});' object(Closure)#1 (0) { } Do we really want to use both names in userland? Is a string "lamda" really the best represantation for callable_name? (this might even be an issue if somwbody has a function called lambda ... for whatever reason, oh just checked people even do: http://google.com/codesearch?hl=en&lr=&q=lang%3Aphp+%22Function+lambda(% 22&sbtn=Search ) Another issue I found during my short testing period today is reflection: In a previous position I had to deal with callbacks, for making the code more robust I checked the callback using reflection before accepting it, the code looks something like that: function setCallback($cb) { if (is_array($cb) { $r = new ReflectionMethod($cb); } elseif (is_String($cb)) { $r = new ReflectionFunction($cb); } else { throw new Exception(); } if ($r->getNumberOfRequiredParameters() != 2) { throw new Exception(); } /* ... morre checks of that kind ... */ } Now such a check isn't possible, all reflection information on the callback I can get is that it is an object of type Closure having a method __invoke() with zero required parameters. There's no further information on the function, so probably we need a ReflectionClosure class or something Both of them are tiny issues which can be fixed in a quite simple way (or be documented as expected) but my concern is that we'll find way more of them. So the final question is: Do we want to go in a higher pace to get things out and have other features ready which can be added early for a new release cycle or do we want to go a bit slower with the risk of stopping and probably going backwards, again. I'd prefer the first way (even so I do really like closures and wanted to have them for some loooong time...) > I expect more problems with GC GC can be problematic yes, but imo gc can either be disabled by default and documented as "use only with care for running your unit test suite" or completely dropped, even in a later stage if there are problems, I don't see there much potential for long going detail discussions. Even if it's, technically, more critical. johannes