Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103600 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 33031 invoked from network); 12 Dec 2018 20:53:13 -0000 Received: from unknown (HELO mout.gmx.net) (212.227.15.18) by pb1.pair.com with SMTP; 12 Dec 2018 20:53:13 -0000 Received: from [192.168.2.103] ([79.222.37.159]) by mail.gmx.com (mrgmx002 [212.227.17.190]) with ESMTPSA (Nemesis) id 0Lm3H7-1h6Bt90V05-00Zfdb; Wed, 12 Dec 2018 18:20:38 +0100 To: Levi Morrison Cc: internals References: Message-ID: Date: Wed, 12 Dec 2018 18:20:41 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.3.3 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:HSnVD1eYoJZn5vZfADR72BSo9Qig6lV5DKJ0eW3x99lwUMSHyHz +st3CUzA6IMupgn+UUrrrAf3Pj7PkVr/TmxSgH0pzGnbXKz2QBbSBnTczblRxHEolwMx6PI JNG/M2gSOvM64HTWksLGEnqErnvZbu7YTez5ObQxSNqGGnrPlxVarcmc763tpqWSemq5ZnC 1yqGBmy80KqodpxtGGgIA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:3t7mzM4vw4U=:OkbPsHyLBvLTdqi1MSGc70 BKyFQ530Xdj6BhI+SwHHEDBfj6W2WG5YpqmScx8QR+uSlfruQ71HUsiWrBYaebMrEcyRHQFer x6/Z3PC1Eu4E4DGJmCRxk16qPaAkkPsp8VxcHBCDVoMLE1n/gYaWzunN6ogvIAThAbAk04HzK R3KKPeiRHFpQroylJQFYtyF2hupNRVtEUIyRvW8m+smH1Lla31ogFO77wHhEye9DMO2kpqrhO LR5QB8J6FPCTKDUfnIBFw+UEiWlAFDUJ/KjO8YQU6e/p+PMGyB7UMomqIhxWhUVdrfgtR+fw1 3qTbKcsUDgSrIFHfm/1YILDD7K9Ft8s1fLhKcuisO+IhOObd5PhcYxf0DhQaEbvKT30smbZ+E wBHGChoMNIzNshF6Rd0OhRcfBNcu2AWiczQ6LgZEcJBMnpgOrl7uMvk8FWuIeiTeN8OSFRKZ8 HXg8LXIZ9XUKkNU7qGzu20QZjs2w+OfLHOI6/tX4R0Bts6SuVbWXOMOWUexikQDud6iNlVjVM F5wKSWexk7qkPnIi6Wxcv1nSvrga52mxeV0KP+tM5qgZg0nxm3yhoYV0kivbR0UPmt1bkjc/s TF44LR8x/OucstYU0qzEg/yceNf93az90g9elLH1NSr0LjSUUShwgkMXPoTaNh9W58V4SNSwT 7tG15O57H+NUalsh2u/Vg40nANgNGTu/mAZuJjP9vyvmDHyp3Yhf9S1Y8irEPTRPLx4rJ4JS2 Y0jYRNcBwXCM8ZtXbzdnxZPpGuB6zgRAEg75eSslvTQkAWhmBR91I18LPSyeaWoznXlTmpqHq jdRpxXS72EKS4omDuhl8ZwtF3s1YLpdt3O5vjZGZ5PQsj7WIpMBYXz0Q8t3RpgeCcdRjLXj6S cD1RmVZriige302HxO3sU4prv6KxknC6NHHFJ3MlumnkusU4OSKlbOndDD0u6h Subject: Re: [RFC][Discuss] Covariant return- and contravariant parameter- types From: cmbecker69@gmx.de ("Christoph M. Becker") On 12.12.2018 at 17:28, Levi Morrison wrote: > On Wed, Dec 12, 2018 at 4:25 AM Christoph M. Becker wrote: >> >> On 11.12.2018 at 21:34, Levi Morrison wrote: >> >>> On Mon, Nov 26, 2018 at 2:25 PM Levi Morrison wrote: >>> >>>> I am happy to announce my latest RFC, [Covariant Returns and >>>> Contravariant Parameters][1], is open for discussion. If you do not >>>> recognize those terms then hopefully the introduction coupled with the >>>> [examples][2] will help. […] >>>> >>>> [1]: https://wiki.php.net/rfc/covariant-returns-and-contravariant-parameters >>>> [2]: https://wiki.php.net/rfc/covariant-returns-and-contravariant-parameters#examples >>> >>> It has been two weeks now. If you want to provide any feedback, or >>> follow-up on anything from the discussion, please do so soon. I hope >>> to put this to vote before the end of the year. >> >> Thanks for working on this, Levi. Highly appreciated! >> >> I may have missed this, but otherwise I'd be quite surprised that nobody >> had commented on: >> >> | Therefore, by-reference parameters are still contravariant, […] >> >> Call-by-reference is not seldom used to provide out-parameters, but >> these should not be contravariant according to LSP. Therefore, it might >> be best to keep by-reference parameters invariant. > > Christoph, we cannot make any guarantees about the type of the > variable when the function returns because the type of the parameter > is only checked on function entry, and not also on function exit, e.g. > > function array_baz(array &$in) { > $in = 1; > } > $array = []; > array_baz($array); // valid > var_export($array); // 1 > > I do think we ought to have "out" parameters some day which would > prevent this behavior (as well as have some other benefits), but that > is out of scope for this RFC. The RFC notes that if we had "inout" > parameters that they would need to be invariant. It also says that > "out" parameters would be invariant, but they may be covariant > depending on the exact semantics specified -- all that can be handled > in the RFC that proposes it. I was not aware of this – thanks for the explanation. In my opinion, yet another good reason to avoid references. > I will add this example (or maybe a better one) to the RFC. Thanks for > bringing it up. Thanks. Also documented now: . -- Christoph M. Becker