Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88668 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96388 invoked from network); 4 Oct 2015 19:50:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Oct 2015 19:50:22 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.49 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.220.49 mail-pa0-f49.google.com Received: from [209.85.220.49] ([209.85.220.49:32952] helo=mail-pa0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 36/49-31315-CF281165 for ; Sun, 04 Oct 2015 15:50:22 -0400 Received: by pacex6 with SMTP id ex6so154741718pac.0 for ; Sun, 04 Oct 2015 12:50:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type:content-transfer-encoding; bh=DDVLvGCSKmW0xx6Dxt0+jCrPGugyrTL/0PpUKdzM+Dk=; b=Nr+2elAOnnkVS+KCcMoX90rmzWQCQHE8+oL40xjOdJnebjKM3W07ATqWRlikWgc/Nn SlI6Xa5qwJ4eh7gVjHIX+1JoGaLMjkQPG0MZ98Obmusht+dWmFGbTQdoZdQa/a/SmKKl dRRtE//5vm357Wo9VYEf2k9VsfmvPLzrAbc+KQpecvghFA0fMH9t2ETPigbMH/hY7Meo 2ClorIWl70QoCVVBRGXuTgWaxDkEgEf+5H7OBzmO8ytT4fz+bo5a5KdBz55tIGsDUVSO LvbwOPYNGeZFN9L8K7lXzfcOO8mqwngiWKH0YQyIgGnWitk2R3i81Lh0VdYbV9RV0HG3 HESw== X-Received: by 10.66.253.229 with SMTP id ad5mr35046154pad.101.1443988216790; Sun, 04 Oct 2015 12:50:16 -0700 (PDT) Received: from [192.168.2.102] (108-66-6-48.lightspeed.sntcca.sbcglobal.net. [108.66.6.48]) by smtp.gmail.com with ESMTPSA id we9sm23499442pab.3.2015.10.04.12.50.15 for (version=TLSv1/SSLv3 cipher=OTHER); Sun, 04 Oct 2015 12:50:15 -0700 (PDT) To: internals@lists.php.net References: <8D.64.31315.E67F0165@pb1.pair.com> X-Enigmail-Draft-Status: N1110 Message-ID: <561182F5.2030508@gmail.com> Date: Sun, 4 Oct 2015 12:50:13 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <8D.64.31315.E67F0165@pb1.pair.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: [RFC] [DISCUSSION]: Closure from callable From: smalyshev@gmail.com (Stanislav Malyshev) 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. -- Stas Malyshev smalyshev@gmail.com