Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49221 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 97593 invoked from network); 7 Aug 2010 03:25:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Aug 2010 03:25:48 -0000 Authentication-Results: pb1.pair.com smtp.mail=glopes@nebm.ist.utl.pt; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=glopes@nebm.ist.utl.pt; sender-id=unknown Received-SPF: error (pb1.pair.com: domain nebm.ist.utl.pt from 193.136.128.21 cause and error) X-PHP-List-Original-Sender: glopes@nebm.ist.utl.pt X-Host-Fingerprint: 193.136.128.21 smtp1.ist.utl.pt Linux 2.6 Received: from [193.136.128.21] ([193.136.128.21:50909] helo=smtp1.ist.utl.pt) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 16/B3-21239-A32DC5C4 for ; Fri, 06 Aug 2010 23:25:47 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp1.ist.utl.pt (Postfix) with ESMTP id B0EE8700E8AC; Sat, 7 Aug 2010 04:25:43 +0100 (WEST) X-Virus-Scanned: by amavisd-new-2.6.4 (20090625) (Debian) at ist.utl.pt Received: from smtp1.ist.utl.pt ([127.0.0.1]) by localhost (smtp1.ist.utl.pt [127.0.0.1]) (amavisd-new, port 10025) with LMTP id QMUpMI2+AIaR; Sat, 7 Aug 2010 04:25:43 +0100 (WEST) Received: from mail2.ist.utl.pt (mail.ist.utl.pt [IPv6:2001:690:2100:1::8]) by smtp1.ist.utl.pt (Postfix) with ESMTP id 6F3AF7000456; Sat, 7 Aug 2010 04:25:43 +0100 (WEST) Received: from cataphract-old.dulce.lo.geleia.net (52.152.108.93.rev.vodafone.pt [93.108.152.52]) (Authenticated sender: ist155741) by mail2.ist.utl.pt (Postfix) with ESMTPSA id 390F12007324; Sat, 7 Aug 2010 04:25:43 +0100 (WEST) Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes To: "Etienne Kneuss" , "internals@lists.php.net" References: <1272386738.870.32.camel@guybrush> <4C599C17.5050505@smashlabs.com> <4C5B3B1F.9090905@sugarcrm.com> <4C5C1AA6.2010902@smashlabs.com> <4C5C2139.8040800@smashlabs.com> <20100807024842.GA12929@mig9.immomigsa.ch> <20100807025525.GA13055@mig9.immomigsa.ch> Date: Sat, 07 Aug 2010 04:25:38 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Organization: =?iso-8859-15?Q?N=FAcleo_de_Eng=2E_Biom=E9dica_?= =?iso-8859-15?Q?do_IST?= Message-ID: In-Reply-To: <20100807025525.GA13055@mig9.immomigsa.ch> User-Agent: Opera Mail/10.60 (Win32) Subject: Re: [PHP-DEV] ArrayAccess::offsetGet not returning a ref From: glopes@nebm.ist.utl.pt ("Gustavo Lopes") On Sat, 07 Aug 2010 03:55:25 +0100, Etienne Kneuss wrote: >> >> Returning a ref is an additional constraint, meaning that it would >> actually be covariance, and not contravariance. But yes, it makes >> sense. > Yes, you are right. To put it another way: a subclass should be able to * Relax the preconditions * Strengthen the post-conditions I actually noticed this shortly after sending the e-mail, but hoped no one else would :p > Actually, after rereading what you said and the proposed diff, I'm not > sure it makes sense. It should _not_ be consistent with arguments. > > A method subtype may relax the parent prototype by not requiring a > ref for an argument. This is fine and it's indeed contra-variant. Again, my mistake. The if before was indeed about arguments... > However, the return value of a method subtype should be able to return a > ref even if the parent prototype doesnt. However, if the parent requires > a ref, the child should too. Which is covariant. > I'm confused, this was what exactly what I suggested. The condition I suggested is this (proto is the parent, fe the child): if (proto->common.return_reference && !fe->common.return_reference) { return 0; } So it returns an error condition if the parent returns a reference and the child doesn't. It's the check on the arguments that's wrong in this sense. However, I think invariance should be required here. The thing is, passing an argument by reference is actually also a post-condition -- if we pass an argument by reference, we're going to do something with it. In fact, invariance is required for the non-"rest" part of the arguments: if (fe->common.arg_info[i].pass_by_reference != proto->common.arg_info[i].pass_by_reference) { Again, sorry for the confusion. -- Gustavo Lopes