Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88672 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11318 invoked from network); 5 Oct 2015 00:38:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Oct 2015 00:38:25 -0000 Authentication-Results: pb1.pair.com header.from=danack@basereality.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=danack@basereality.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain basereality.com from 209.85.160.172 cause and error) X-PHP-List-Original-Sender: danack@basereality.com X-Host-Fingerprint: 209.85.160.172 mail-yk0-f172.google.com Received: from [209.85.160.172] ([209.85.160.172:35174] helo=mail-yk0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4E/41-00151-F76C1165 for ; Sun, 04 Oct 2015 20:38:24 -0400 Received: by ykdz138 with SMTP id z138so156860361ykd.2 for ; Sun, 04 Oct 2015 17:38:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=E/9ZHekvHIk/rI79jCVUl0Z/KycWfYLYTT58vsnkAPk=; b=Pwdl8A9l4jG2rnJ91l7UG0bsIUQqrMkeATw1Kdb2QZFRuQi49MRpv7WuAfLsmOVrpb qiFguJvxEaadL/dSvHpPN9i66kS0ZRsRxipSptCf7IaIi7+kqi4KhWMix/aNYsVZws4P K3naD8jFWCRDpJL1JUBfHEcDavL2t5mSkQDyefTiIxSYDm+sYmj3GuHSu5jTE+6qVMwL HgZ0PyxAAs2zFckIJqH1eMYDtHfPXAJYuKjjak1sS1XaO5ZbkCnPTRzGGwODQrSkzQ+E Kso3I2PV2ldFwA+BgP7uuRnBTap7NaJthSyXb3oMXcQQGMM7rB+ymzZPOyNwJXOlPIgQ lWAw== X-Gm-Message-State: ALoCoQnWIfVxvua4c25Ls5eZVOScQMt8rDF3R+wsnBH7pUtICvhO2R9lrPPteghvpPdbJchJdxXs MIME-Version: 1.0 X-Received: by 10.13.227.4 with SMTP id m4mr23653352ywe.72.1444005500456; Sun, 04 Oct 2015 17:38:20 -0700 (PDT) Received: by 10.37.76.137 with HTTP; Sun, 4 Oct 2015 17:38:20 -0700 (PDT) X-Originating-IP: [2.96.92.51] In-Reply-To: <5611B007.8080903@gmail.com> References: <8D.64.31315.E67F0165@pb1.pair.com> <561182F5.2030508@gmail.com> <5611B007.8080903@gmail.com> Date: Mon, 5 Oct 2015 00:38:20 +0000 Message-ID: To: Stanislav Malyshev Cc: Michael Wallner , PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Re: [RFC] [DISCUSSION]: Closure from callable From: danack@basereality.com (Dan Ackroyd) On 4 October 2015 at 23:02, Stanislav Malyshev wrote: > Hi! > > That being said, I'm not sure how much need is for this - i.e. you can > always make a closure by just doing function() { return $this->blah(); } > if you need it. As I said before (and as the RFC says), there are ways to work around not having it. But having to duplicate code and keep it in sync is a pain and indicates that something is missing from the language. > And if we're into performance optimization We're not. The performance stuff is nice side benefit, but it's not the main aim of the RFC which is to make life easier for people who want to create closures in PHP. > But the bigger question would be why you need more > specific type (Closure) instead of more generic (callable) IMO it's actually the other way round; closures are more generic than callables. To get the parameters of a closure via inspection you only ever need to use ReflectionFunction. To get the parameters of a callable, you need to figure out first what type of callable it is, and then either use ReflectionFunction or ReflectionClass + ReflectionMethod as appropriate. And also callables are just a bit insane currently: > Maybe we should fix $callable() then? :) Maybe we should! I announced a draft RFC a week ago: http://news.php.net/php.internals/88545 Only one person (off list) has given any feedback on it so far. I invite more feedback! Even if it's just "that's an amazing RFC Dan, you've covered every possible aspect of the changes that need to be discussed." that would still be good feedback to get. But as that RFC could only be introduced for PHP 8 at the earliest, and callable still won't be as easy to work with as closures, the feedback I have received is that people would very much appreciate having this RFC for 7.1 cheers Dan