Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98309 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 22289 invoked from network); 15 Feb 2017 21:13:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Feb 2017 21:13:04 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.128.171 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.128.171 mail-wr0-f171.google.com Received: from [209.85.128.171] ([209.85.128.171:36205] helo=mail-wr0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F3/F2-01562-F54C4A85 for ; Wed, 15 Feb 2017 16:13:04 -0500 Received: by mail-wr0-f171.google.com with SMTP id k90so199138478wrc.3 for ; Wed, 15 Feb 2017 13:13:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=vSefLOYiKtSBFVLd0nKiV8LCBJeH72i2v/lmJGcg+XY=; b=CTAHjED2Be3LZOeTaeD8PtRjVVeKu/LyzqLwzjcUlx2x7EoR9GZXzjLV+CeASTckAN 8/5cEysTyOaQhEwV0f/W1UdXBDAXS3u/IjLS33N17WHb5ODCVBANXG1QOXqUBGaQ0BM8 syFmlkmUn/A4G67zTx/s45PQLz4eAliS7r1CEYRAd3eZCVyv7naCLvxL8csHyL8LN/SV m+OWdmUev5u+Bh0RdHZbiuUVRpPZ7REvVA8zE6bzhrKLVXc6A/TBpjWEmr5cOFDwl2Hr 8VaFRTQrk8KyMN84JERXOqp3ysd5JeQrF1L4EL4pIG8lsgYyVYeLzsJwHaQOIxWyBmeh 0sog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=vSefLOYiKtSBFVLd0nKiV8LCBJeH72i2v/lmJGcg+XY=; b=JJhw/Hn5SrzVLWrfhtmKodsjYKJ1e4imi6rN2lg/w4MIh6nHhgXQ7Vr1O5qJ0VEAPZ onNc3Ty+8LeE2uBxLUqmgYvowphtIqOZx6w/3wptGUpdEiUBgzxn2o1ictBsmNe1mkt2 EZG1NMLwHylhIbSK0Kthh6IQmEJrwg//yBXdZCFLjUEOcmP16kjauW2+0HhAmlvQmNcg hthbpLqMity6KyZrZfj6Hx8vL0rLt9q94ipP1sTshkgFwC9RfROlg6uEDiAR8rOJIhvb UaIMDzkSMy/A5hwh3lk4K3xUE/kNVhdwcKg3f/MGpKtqFi/s4rfG7CkHT1sz2rbei3Tg Qfkg== X-Gm-Message-State: AMke39nYpd8n7ImCU1AJtxEKlPfdYHz0ZM0d2CjG9lNypboMUatHdXVGuENth6TP/KJ8ctOnh1+SnbZmSwzruQ== X-Received: by 10.223.150.238 with SMTP id u101mr30143286wrb.175.1487193180786; Wed, 15 Feb 2017 13:13:00 -0800 (PST) MIME-Version: 1.0 Received: by 10.223.154.47 with HTTP; Wed, 15 Feb 2017 13:13:00 -0800 (PST) In-Reply-To: References: Date: Wed, 15 Feb 2017 22:13:00 +0100 Message-ID: To: Levi Morrison Cc: Dan Ackroyd , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=f403045f570e40daca0548982505 Subject: Re: [PHP-DEV] [RFC][DISCUSSION] Object type hint, now with added variance From: nikita.ppv@gmail.com (Nikita Popov) --f403045f570e40daca0548982505 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Tue, Feb 14, 2017 at 10:20 PM, Levi Morrison wrote: > On Tue, Feb 14, 2017 at 2:14 PM, Levi Morrison wrote: > > On Tue, Feb 14, 2017 at 11:55 AM, Dan Ackroyd > wrote: > >> Hi Levi, > >> > >> On 24 November 2016 at 08:58, Dan Ackroyd > wrote: > >>> Hi Levi, > >>> > >>> On 23 November 2016 at 01:25, Levi Morrison wrote: > >>> > >>>> For instance enumerations (or enums) are one possible type I can see > us > >>>> adding that may not be objects. > >>> > >>> I very much look forward to the RFC for enums, and have for some time= . > >>> When are you thinking of submitting it for discussion and voting? > >> > >> I can understand your concerns. At the same time, I hope you can > >> understand that people won't want to put off introducing features that > >> they want in the meantime. > >> > >> I think if you were able to give a timeline for when an Enum RFC could > >> be introduced, before the PHP 7.2 release, we could talk about whether > >> it would be right to hold off on this RFC for now. > >> > >> Otherwise I suggest Micha=C5=82 updates the voting options, and we ope= n the > >> voting in a week or so. > >> > >> cheers > >> Dan > > > > Let me clarify that I'm not against this object variance; there is > > nothing intrinsic about object variance that prevents enums (or > > typedefs/type aliases). Rather it's *how* it is achieving that > > variance that is an issue. This is something that should ship along > > with full covariance/contravariance and not be a special case which > > may unintended side-effects later (such as preventing enums without > > breaking BC). Does that make sense? > > Here's a concrete compatibility concern. Let's assume we have the > following code: > > interface Factory { > function make(...$args): object; > } > > class FooFactory { > function make(...$args): Foo; > } > > Currently the engine would not have to know anything about Foo to know > if it is a sub-type of object. It would not need to require it to even > be defined. > > However, if at some point in the future we add non-object types it may > now error or autoload. > > The way to avoid the compatibility concern is to implement this > feature the same way we wold implement full covariance, which would > similarly need to know about the types involved. > > Does that make more sense as to why the assumption that unknown types > are object types is an issue? > Thanks, this argument is convincing. Overall, I think the utility of the object typehint is very limited. If introducing an object typehint now will pose issues for an enum implementation later (which I consider significantly more important), I would prefer to defer its introduction until a later time. People have pointed out that there will still be ways to implement enums without breaking BC, either by prefixing enum type annotations with "enum", or by making enum values objects. These suggestions may have merit, but they should be evaluated on their *own* merit when the proposal comes up. We should avoid being forced into a corner where we have to chose a specific implementation due to BC concerns. Nikita --f403045f570e40daca0548982505--