Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:39635 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 17797 invoked from network); 4 Aug 2008 16:45:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Aug 2008 16:45:09 -0000 Authentication-Results: pb1.pair.com header.from=ekneuss@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=ekneuss@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.44.30 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: ekneuss@gmail.com X-Host-Fingerprint: 74.125.44.30 yx-out-2324.google.com Received: from [74.125.44.30] ([74.125.44.30:48131] helo=yx-out-2324.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 18/71-28228-31237984 for ; Mon, 04 Aug 2008 12:45:08 -0400 Received: by yx-out-2324.google.com with SMTP id 3so160716yxj.83 for ; Mon, 04 Aug 2008 09:45:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender :to:subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references :x-google-sender-auth; bh=N3tMxeINOCX7TFnFV0Q670DUY+bw5dvsf7upjw/4jsk=; b=TCIKvfYnnR5JNNrb0SYsg86RcyUvckOhJeG5JUUERzkOv5RzPABnkRYLLh4jkMasLZ Tv44Vj28INLQy3yLP9pXwQBLWuy9dwoMudW1g9bTxE6q1CBmNfubreUt/WOpR2XPK80Y bxAdGvtHkBZDnUm25QxeHOIA8ORAuhCoXC4aY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references:x-google-sender-auth; b=nMV1drHnf/r9+afxLxJnzBNMC072IsFcsEVEyb+93XYf6Rdm/XkJQYiLYUvufTwJaZ lhM9N3IDZOLz9eglI3REhHAoOInZmxO8MqIvqfYUb4frGCSU+FxfMTBjMD3YURyJavBb laL1FkiXkRqgu+sac2VI5PX7NIfXhN2rTKZkA= Received: by 10.150.146.1 with SMTP id t1mr8558769ybd.81.1217868305201; Mon, 04 Aug 2008 09:45:05 -0700 (PDT) Received: by 10.150.197.14 with HTTP; Mon, 4 Aug 2008 09:45:05 -0700 (PDT) Message-ID: Date: Mon, 4 Aug 2008 18:45:05 +0200 Sender: ekneuss@gmail.com To: "Dmitry Stogov" Cc: "Christian Seiler" , "PHP Internals List" In-Reply-To: <48970FBC.4060401@zend.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <48970FBC.4060401@zend.com> X-Google-Sender-Auth: 724d443461b12eba Subject: Re: [PHP-DEV] Re: __invoke concerns From: colder@php.net ("Etienne Kneuss") Hello, On Mon, Aug 4, 2008 at 4:18 PM, Dmitry Stogov wrote: > Hi Christan, > > Could you please look into this patch. > I'm not sure if explicit declaration of Closure::__invoke() is good idea. As > it cannot provide proper argument information. > > May be the patch which you propose already solves this problem for > reflection. (I didn't have time to look into it). > After discussing it with Dmitry, I removed the reflection part from the patch, giving full reflection info on Closures seems like a better idea, even if it requires patching Reflection itself. Regards > Thanks. Dmitry. > > Etienne Kneuss wrote: >> >> Hello, >> >> On Sat, Aug 2, 2008 at 7:36 PM, Etienne Kneuss wrote: >>> >>> Hi, >>> >>> this is probably not the best time to raise concerns about __invoke >>> (closures) now that alpha1 is already realeased, but I believe it's >>> worth it. >>> >>> 1) I don't believe that having it thrown as another of those magic >>> method is a good idea. Rather, I'd like to have it represented by an >>> interface: Invokable. That way, type hints/checks can be done in user >>> land in a sane matter: >>> >>> function foo(Invokable $obj) { >>> $obj(); >>> } >>> >>> if ($foo instanceof Invokable) $foo(); >>> >>> etc.. >>> >>> 2) Do we really want __invoke's argument to be mapped to caller >>> arguments. Providing an array of arguments, ala __call(Static) sounds >>> more consistent. >>> class A { public function __invoke($arg) {var_dump($arg); }} $a = new >>> A; $a(1,2); // int(1), currently. IMHO it should be array(1,2) >>> >>> >>> 3) Do we really want to allow both static and non-static versions of >>> __invoke ? >>> class A { public static function __invoke($args) { .. }} $a = new A; >>> $a(); being a static call to __invoke doesn't make much sense to me. >>> >>> >>> I hope these issues can be discussed and maybe addressed before a >>> final 5.3 release. I'm willing to do patches for all three concerns if >>> I sense a positive feeling towards this. >>> >>> Regards, >>> >>> -- >>> Etienne Kneuss >>> http://www.colder.ch >>> >>> Men never do evil so completely and cheerfully as >>> when they do it from a religious conviction. >>> -- Pascal >>> >> >> After looking deeper into it, I noticed that this interface brings a >> lot of problems: >> >> 1) With the interface, the prototype is fixed. >> Which means that the following are no longer possible: >> >> Class A { >> public function &__invoke(&$a, $b, $c) { return $a; } >> } >> $a = new A; $e =& $a($b,$c, $d); >> >> 2) __invoke($args) seems more consistent, and would give a consistent >> prototype, but >> 2.1) references are no longer possible (1) >> 2.2) __invoke of actual closures/lambdas needs to map parameters for >> $a = function($b,$c){}; to work properly. I don't believe $cl = >> function($args){..} is something we want >> >> So, with those counter-concerns in mind, this Invokable interface is >> no longer implementable, IMO. >> >> However, I'd still like to make closures more flexible and >> internals-friendly by implementing zend_get_closure as a handler. >> The only (tiny) issue here is that we export a bit more >> closure-material in the engine, and it's no longer so much >> self-contained in zend_closures. >> >> Patches: >> http://patches.colder.ch/Zend/zend_get_closure_handler_53.patch?markup >> http://patches.colder.ch/Zend/zend_get_closure_handler_HEAD.patch?markup >> >> ps: this patches also expose the __invoke method for reflection. (Or >> is there an actual reason behind not exposing it? ) > > -- Etienne Kneuss http://www.colder.ch Men never do evil so completely and cheerfully as when they do it from a religious conviction. -- Pascal