Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79221 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 85910 invoked from network); 27 Nov 2014 10:47:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Nov 2014 10:47:31 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.178 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.178 mail-wi0-f178.google.com Received: from [209.85.212.178] ([209.85.212.178:64172] helo=mail-wi0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 56/11-15115-24107745 for ; Thu, 27 Nov 2014 05:47:30 -0500 Received: by mail-wi0-f178.google.com with SMTP id hi2so7870917wib.5 for ; Thu, 27 Nov 2014 02:47:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=cgMYFhkX8T4U5FvAXiGOyLCaKPkfyAGf/PRVv/Nywq4=; b=QKGzTf8nGo0inVCO4O8rEZWww/u2gaEEKzizOZFMGFcHjj041+zwvBRksyW7VCXYKj NqBM5nQ8vUa7lELoP9/GgcrnSQuUdMTCvbAx6vdF8OojPqKMs8jzszNUsrC7CPtT8brT Y7iMiXMyo6z1oAooTfF5XmIAE2AWEKs/p7qxL2YOF7uYRvO4iamtPAisqeXr3dQbBsE1 0VKpHpZg3o/doctqaE60GWzJz4dkr1t6EJ7cV1lfMzHLtnlFz9Io2dWeS9JajxptGnnl 2W615A7GbnyqaP6XodUzWQLsb1IFLOlyeXfX1gtUzZtDCFJttS9EiwuwcE86/la+uq4L uyVw== X-Received: by 10.180.11.97 with SMTP id p1mr34428898wib.22.1417085247427; Thu, 27 Nov 2014 02:47:27 -0800 (PST) Received: from [192.168.0.148] ([62.189.198.114]) by mx.google.com with ESMTPSA id cp4sm10151025wjb.16.2014.11.27.02.47.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Nov 2014 02:47:26 -0800 (PST) Message-ID: <5477010E.4000000@gmail.com> Date: Thu, 27 Nov 2014 10:46:38 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC][Discussion] Return Type Variance Checking From: rowan.collins@gmail.com (Rowan Collins) 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]