Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79267 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16511 invoked from network); 28 Nov 2014 09:31:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Nov 2014 09:31:39 -0000 Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.220.169 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.220.169 mail-vc0-f169.google.com Received: from [209.85.220.169] ([209.85.220.169:51097] helo=mail-vc0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 95/B8-59154-AF048745 for ; Fri, 28 Nov 2014 04:31:39 -0500 Received: by mail-vc0-f169.google.com with SMTP id hy10so2881741vcb.0 for ; Fri, 28 Nov 2014 01:31:36 -0800 (PST) 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:content-type; bh=f3xTJhL1C4dP+zAGzl6EMNMKQD2qjqZVynRCdN7ZE5k=; b=cEECBFZ06BV42Ufl+7bJVzjuPBfkKKJW1Cl93DxCEYf9L5Np0D+lZmPM0PyJSzAUG6 F+aWQSogB1tck/x5vQ4j5nmaQTN8PjbtR24wshQut6RqCwm2Lck18Cswuvw/5IzeTi9S BxN0uUpPz31sD5bTe7ArC8YObqrUidunoKTusU0ZoW28YyFmCWxD6ZoDz03twR1LQu4G KTu3yVd/J6oQO+AbQ0J7c2Bz+TVXVreu1WAPUMN2+LHLa9x3xRL/HDsPVLB1w8dKVuXY n8YRYrIJHbPftqJ5Bzk2f9r4c9iOKz+1dk26rhrUi0giN/YMudbBrBwKUKReqSO7Kruv F9HA== X-Gm-Message-State: ALoCoQmMkW7hgvzZOmawypE0l4ECRlPPC4V4nMw5wyL+7h/BSzJZfg+h2i95uK02b5fOoTKwG9DRDVPkBzz21KMp/23KB0QuG+vInRXiHaag9f+qar/Fjcsgvtt4qgtcfubLClrPdpBx4e1kuzj7/J2frM7Lk6Xqqg== MIME-Version: 1.0 X-Received: by 10.52.117.161 with SMTP id kf1mr18388324vdb.65.1417167096350; Fri, 28 Nov 2014 01:31:36 -0800 (PST) Received: by 10.52.176.231 with HTTP; Fri, 28 Nov 2014 01:31:36 -0800 (PST) In-Reply-To: <5477010E.4000000@gmail.com> References: <5477010E.4000000@gmail.com> Date: Fri, 28 Nov 2014 13:31:36 +0400 Message-ID: To: Rowan Collins , Levi Morrison Cc: PHP Internals Content-Type: multipart/alternative; boundary=bcaec547cbdd5da49d0508e7ed93 Subject: Re: [PHP-DEV] [RFC][Discussion] Return Type Variance Checking From: dmitry@zend.com (Dmitry Stogov) --bcaec547cbdd5da49d0508e7ed93 Content-Type: text/plain; charset=UTF-8 I prefer option (3) - invariant return types. Actually, return type compatibility check should follow all the rules for parameter type compatibility check (may be even reuse or share the code). This solution may be implemented efficiently and consistently. It also must be enough for 99% use cases. Thanks. Dmitry. On Thu, Nov 27, 2014 at 1:46 PM, Rowan Collins wrote: > Levi Morrison wrote on 25/11/2014 17:08: > >> 1. Do covariant return types; check them at definition time >> 2. Do covariant return types; check them at runtime >> 3. Do invariant return types; check them at definition time >> > > I guess there's also option 4 - do "weak invariance", as we do with > parameters: any combination of types is actually allowed, but any variance > raises an E_STRICT notice. (This is only true with class inheritance; > interface implementation is strictly invariant, raising a fatal error if > the declaration is not typehinted identically.) > > I think my preference would be to implement return types with strict > invariance (option 3) initially, in order to keep the implementation and > discussion simple, and get the syntax baked into the language. > > Then immediately look into solutions for covariant return types, and > possibly also contravariant parameter types (relaxing the fatals for > interface implementation, and maybe raising the remaining cases above > E_STRICT for class inheritance). > > If a good solution and implementation can be found in time for 7.0, then > all the better, but if not, it can be added in 7.1, and no code written for > the hints added in 7.0 would fail. > > Regards, > -- > Rowan Collins > [IMSoP] > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --bcaec547cbdd5da49d0508e7ed93--