Re: by-ref return & inheritance

From: Date: Fri, 08 Aug 2008 23:00:08 +0000
Subject: Re: by-ref return & inheritance
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-39784@lists.php.net to get a copy of this message
Hello Stanislav, Saturday, August 9, 2008, 12:40:34 AM, you wrote: > Hi! >> Yes, it breaks the principle. E.g. caller knows callee returns by ref - you >> break this, as easy as that. > I'm sorry I think you misunderstood my proposal. I proposed allowing > overriding this: > public function __get($name) > with this: > public function &__get($name) > but not the reverse. So if the caller known callee returns by ref - it > means it already expects the child class, not the parent class. Thus, it > does not break anything. > Is there any other problem that you see? What makes you think there won't be a problem with the reverse. The caller does not expect a reference but the calle returns one? In OOP the return value of the derived class' method must be an instance of the class defined by the base class' method or a subclasse of that. And so far we tream them different, rather than a reference is a subclass of a normal value or vice versa. Best regards, Marcus

« previous php.internals (#39784) next »