Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92451 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 46482 invoked from network); 19 Apr 2016 12:50:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Apr 2016 12:50:43 -0000 Authentication-Results: pb1.pair.com smtp.mail=pthreads@pthreads.org; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=pthreads@pthreads.org; sender-id=unknown Received-SPF: error (pb1.pair.com: domain pthreads.org from 209.85.161.178 cause and error) X-PHP-List-Original-Sender: pthreads@pthreads.org X-Host-Fingerprint: 209.85.161.178 mail-yw0-f178.google.com Received: from [209.85.161.178] ([209.85.161.178:34287] helo=mail-yw0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B5/40-43496-2A926175 for ; Tue, 19 Apr 2016 08:50:42 -0400 Received: by mail-yw0-f178.google.com with SMTP id j74so13676249ywg.1 for ; Tue, 19 Apr 2016 05:50:42 -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=fkYrKUJ+XyiRlkbVp4Ewz/QQWAVOPd68YFpguar12bo=; b=ACIcR1UYvGLXlhHC6gzgB7Xh7aOYHvme9MflkHwIRL0f9E1+TEmwV/yYF52i4UcwbN y5agTpOJy3a/xMXDQUxtWc1R0odv/3HsSK+C7VUS9WS4ZaEwkYFzWNRDYW7h2E6sT/lQ gTrieZYGkNx4taFkLKtIPc6GhG6wyxM5Kxb/c6PWkoRKpdl9tRQpaN4vcbJOiTF5SI2r kuZkGkIKSmaGFEq2pyqmfaU6jFEzL762EjpaHL9pvM04R+zFo6rGxhJtQZo94/IdVuHN R2L78l9NkNBhE/XR023DUzGV1HosVBVA0o/sfNhdwtVpiQquhuckHGviDaUELesSNhLx +oaQ== 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=fkYrKUJ+XyiRlkbVp4Ewz/QQWAVOPd68YFpguar12bo=; b=fjWpRGPZ/otJguxnOEluYZ8Q7cfqT/fIjZ6zcri2UpM2Ut8s3eYv9NfSW8SJ1Gp37u +hGVr7stDjXUjMN31ns2ZI0sZ7pnUZyTcLNSHbhYfIDKlIMWeohib71xCpwDLWIjBXKX RQGs+oslSIZYS6RJ0/DLJbGPMIMQHNWrHTnVb2pxV47Y8snCZPod169OgenelUrNBVYV L/i0VceGY6gkTDVjewa5pi5W0RpTHdCOpPrvJann0WrBtDSGNsKGUznvcWnkRDWEMMP/ /w4v1f+aCw7Rpg4/mRT5x+d6Rq7YYi9ldz+4kizNKHSOqvY3PM18J+/YrDv/Yzq8NbgE JJGw== X-Gm-Message-State: AOPr4FUT0pZVj8YB7xa2fhIanxS9Yvl51rhfoQK5dqeWX5zPQi5qJ+Zu7SPQ3suao2DtPD04JOV4RyuafCl2Yg== MIME-Version: 1.0 X-Received: by 10.37.223.210 with SMTP id w201mr1533432ybg.74.1461070238417; Tue, 19 Apr 2016 05:50:38 -0700 (PDT) Received: by 10.129.39.9 with HTTP; Tue, 19 Apr 2016 05:50:38 -0700 (PDT) X-Originating-IP: [109.159.6.57] In-Reply-To: References: Date: Tue, 19 Apr 2016 13:50:38 +0100 Message-ID: To: Dmitry Stogov Cc: PHP internals Content-Type: multipart/alternative; boundary=94eb2c088c888dd3420530d5ec68 Subject: Re: [PHP-DEV] RFC: Functional Interfaces From: pthreads@pthreads.org (Joe Watkins) --94eb2c088c888dd3420530d5ec68 Content-Type: text/plain; charset=UTF-8 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. Even when anon classes do have lexical scope, there is value in being able to implement these kinds of interfaces using only a function. The changes to the vm are restricted to a few lines, that's not seriously a problem, is it !? I don't see where I extend closure with an interface ... > 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 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 > --94eb2c088c888dd3420530d5ec68--