Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92458 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 58491 invoked from network); 19 Apr 2016 13:29:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Apr 2016 13:29:39 -0000 Authentication-Results: pb1.pair.com header.from=pthreads@pthreads.org; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=pthreads@pthreads.org; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain pthreads.org from 209.85.161.180 cause and error) X-PHP-List-Original-Sender: pthreads@pthreads.org X-Host-Fingerprint: 209.85.161.180 mail-yw0-f180.google.com Received: from [209.85.161.180] ([209.85.161.180:36393] helo=mail-yw0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A4/D2-43496-1C236175 for ; Tue, 19 Apr 2016 09:29:37 -0400 Received: by mail-yw0-f180.google.com with SMTP id o66so16736115ywc.3 for ; Tue, 19 Apr 2016 06:29:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pthreads-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=qZjsc/jrZra+m8gMEeRJV5oRBGA246S7Oe/xCrZRFaE=; b=x0+mtsJG+Xj23sL2t39GoRgFKBbEh/rZdhRUqSOAzvu/R0hOx5YTcpYH2OCjXvFANm y/NtryWpNrMNTHqYOfTKqEfTl1XBtLyEgnF+VBC+LGUZsUdOtiIYA+WJi1gA84uFkFu/ CzJIfwhuzyKPianRQQm9Xq5hTuZD4PamEoDdr0jVTAJUdsaJ4xycjgYIK1hE5YryNhzF tzOBYQt9gO21i4Z5AC57caS0GytgHhGTPtR0snY4djlFKmkCah61KdnUtmGar+tXUfTa F1G/a/UkAdU6x7zZcmB1AEpQh18ah0JIDDWqmrtNpjHFja9fhuUB3gxlakP00dU1rQya xEcA== 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; bh=qZjsc/jrZra+m8gMEeRJV5oRBGA246S7Oe/xCrZRFaE=; b=X0pMhM2cmGekznsObrWNOMSAOIY1ZDlHa0ZpSyKg2h0bFJO17VaA/2Gt7vn+ZypJ6g 1Bup6w3Zn5dPZwTiHY4WxHQtAOb7+cVWmP5v3tF3M9uekw5IARK54UggBNvTxJX6skcG 8b9FHgzW1getbJS6x1+bzz6av4urj1vElRRTzJGgl89ch2kiebDyt6PANjWyWaGAS7O+ JM3WOpIAaz1KUgqRZn+R08uJ3gzVY2ANZueHgcsRoaNqM5k4fIawpDCCqOaG/TNjZIu/ cnZUzf7r7sS6UBWiKn5+4e7yak9AgBJNBaTAZHPDqw//nZiEpiyeNALZJwjfobNRztD4 nyhQ== X-Gm-Message-State: AOPr4FWk5GNIDQ2jUn/CFrQTAMTUr5kss8DBEQRuON3g/xDWKQXHPR43xbTlTmXlNKwDvBo0DIjIf7kMPZ1oqg== MIME-Version: 1.0 X-Received: by 10.13.217.84 with SMTP id b81mr1595477ywe.256.1461072574062; Tue, 19 Apr 2016 06:29:34 -0700 (PDT) Received: by 10.129.39.9 with HTTP; Tue, 19 Apr 2016 06:29:33 -0700 (PDT) X-Originating-IP: [109.159.6.57] In-Reply-To: <5716310B.4060104@zend.com> References: <5716310B.4060104@zend.com> Date: Tue, 19 Apr 2016 14:29:33 +0100 Message-ID: To: Dmitry Stogov Cc: PHP internals Content-Type: multipart/alternative; boundary=001a114fa8e0c4d30e0530d6776a Subject: Re: [PHP-DEV] RFC: Functional Interfaces From: pthreads@pthreads.org (Joe Watkins) --001a114fa8e0c4d30e0530d6776a Content-Type: text/plain; charset=UTF-8 > What value? Yes, shorter, more concise (from the programmers perspective) syntax. Right now, if you do a lot of work with Closures, you have to verify their interface, the value in having the engine do it for you seems really obvious. But also ... > I thought the same might be implemented through anonymous classes. An anonymous class cannot be rebound, they are obviously not the same thing. > I didn't take a deep look into the code. I'll wait until you have, I think :) Cheers Joe On Tue, Apr 19, 2016 at 2:22 PM, Dmitry Stogov wrote: > > > On 04/19/2016 03:52 PM, Joe Watkins wrote: > > Oh, it's confusing text in the RFC, using the word "Interface" ... that's > meant as a placeholder for InterfaceName. > > Cheers > Joe > > On Tue, Apr 19, 2016 at 1:50 PM, Joe Watkins > wrote: > >> Morning Dmitry, >> >> In your example, they will do the same thing. >> >> Anon classes don't have lexical scope, I have a patch for that, and an >> RFC, I'm just tidying it. >> > > OK. so this is not just a syntax sugar, but if you implement lexical scope > for anonymous classes it's going to be sugar. Right? > May be it's better to start from classes first? > > >> Even when anon classes do have lexical scope, there is value in being >> able to implement these kinds of interfaces using only a function. >> > > What value? just shorter syntax? or anything else? > > >> The changes to the vm are restricted to a few lines, that's not >> seriously a problem, is it !? >> > > I hope no. I didn't understand all details of proposal and I didn't take a > deep look into the code. > > >> I don't see where I extend closure with an interface ... >> > > I meant new field zend_execute_data *interface in zend_closure structure. > I thought the same might be implemented through anonymous classes. > > Thanks. Dmitry. > > > >> > zend_do_inheritance_ex(type, zend_ce_closure, 1); >> > zend_class_implements(type, 1, interface); >> >> Cheers >> Joe >> >> On Tue, Apr 19, 2016 at 1:01 PM, Dmitry Stogov < >> dmitry@zend.com> wrote: >> >>> >> interface IFoo { >>> public function method() : int; >>> } >>> >>> $cb1 = function () implements IFoo : int { >>> return 42; >>> }; >>> >>> $cb2 = new class implements IFoo { >>> function method() : int { >>> return 42; >>> } >>> }; >>> ?> >>> >>> Are $cb1 and $cb2 going to be the same (do the same)? >>> Is this just a new syntax sugar, or a really new feature? >>> >>> According to implementation, I think, you shouldn't extend >>> "zend_closure" with "interface". >>> If this is a sugar, lets implement it as a sugar (without VM changes). >>> >>> But may be I didn't understand the idea at all :) >>> >>> Thanks. Dmitry. >>> >>> >>> ________________________________________ >>> From: Joe Watkins >>> Sent: Monday, April 18, 2016 13:22 >>> To: PHP internals >>> Subject: [PHP-DEV] RFC: Functional Interfaces >>> >>> Morning Internals, >>> >>> Please review the following RFC: >>> >>> https://wiki.php.net/rfc/functional-interfaces >>> >>> An implementation is provided, and is testable on 3v4l. >>> >>> Review of the implementation from those of you that do that would be >>> good :) >>> >>> Cheers >>> Joe >>> >> >> > > --001a114fa8e0c4d30e0530d6776a--