Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88669 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 756 invoked from network); 4 Oct 2015 21:07:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Oct 2015 21:07:35 -0000 Authentication-Results: pb1.pair.com header.from=mike.php.net@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=mike.php.net@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.171 as permitted sender) X-PHP-List-Original-Sender: mike.php.net@gmail.com X-Host-Fingerprint: 209.85.213.171 mail-ig0-f171.google.com Received: from [209.85.213.171] ([209.85.213.171:36753] helo=mail-ig0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F2/00-00151-71591165 for ; Sun, 04 Oct 2015 17:07:35 -0400 Received: by igcrk20 with SMTP id rk20so48654245igc.1 for ; Sun, 04 Oct 2015 14:07:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=9P7wbFNc3kU0jqbejHfkOgeI0diyMsIzcVSG6O+I4j0=; b=stjUL25RRnTZJ+UiBJ9bH1bbc2eG0zjCIZ1Qcpy3ZXcN7kMKAuTcUBrI54MsIRASBO xUyzMiDuDeGDWYdMmq3WC9WHw6wb5DACBk5jZ/bfImGb942MNWREp1nSUZz/3nzk0SxP KuDodIT7Y3vMsC5BxnMfA7mP8oARkRYRwTe16POTNh7hT5kYZzzbTzQS6zimcdlXR08Z Zdg0CaH54A59Q9teM5CXHFKyU1h6EK2NnX7K4zPfvND4sPBBCi5ymYEb944E+v4VmRLK WeT2FxO7ABuoohLhF6k/7676Ece9ea48kJ2EVoD7aFu9eV/Gl7J/E8Ifa8ptX20kXLMN AKZQ== MIME-Version: 1.0 X-Received: by 10.50.111.167 with SMTP id ij7mr6022723igb.41.1443992852554; Sun, 04 Oct 2015 14:07:32 -0700 (PDT) Received: by 10.79.36.150 with HTTP; Sun, 4 Oct 2015 14:07:32 -0700 (PDT) Received: by 10.79.36.150 with HTTP; Sun, 4 Oct 2015 14:07:32 -0700 (PDT) In-Reply-To: <561182F5.2030508@gmail.com> References: <8D.64.31315.E67F0165@pb1.pair.com> <561182F5.2030508@gmail.com> Date: Sun, 4 Oct 2015 23:07:32 +0200 Message-ID: To: Stas Malyshev Cc: PHP Internals Content-Type: multipart/alternative; boundary=047d7b41447808ee1d05214dc9fe Subject: Re: [PHP-DEV] Re: [RFC] [DISCUSSION]: Closure from callable From: mike.php.net@gmail.com (Michael Wallner) --047d7b41447808ee1d05214dc9fe Content-Type: text/plain; charset=UTF-8 On 4 Oct 2015 21:50, "Stanislav Malyshev" wrote: > > Hi! > > > I don't like that it's a function. Closure is a class, classes can have > > static and instance methods, and closure() looks like something that > > should be a method on Closure. In fact, it creates a closure, which a > > constructor would usually do. If we want to make it avoid duplication, > > okay, then it could be a static method. But I'm unconvinced it should be > > a function. Constructors go in their classes, we don't leave them lying > > around as global functions. That's messy and inconsistent. > > Agree. Closure::fromCallable sounds like a good option. > 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. But the bigger question would be why you need more > specific type (Closure) instead of more generic (callable) and aren't > you overspecifying in that case? > > And if we're into performance optimization - which should almost never > be done on language construct level, because performance considerations > vary and language constructs are forever - then it would be much better > to look into tail call optimizations. That would solve the barrier > between [$this, "foo"] and function() { return $this->foo(); } in many > practical cases. > I think the origin of this intention is, that calling a callable just by `$callable()` does not work consistently -- see the othe RFC by Dan -- and that call_user_func() suffers from a (mythical?) performance issue. --047d7b41447808ee1d05214dc9fe--