Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:33570 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 23203 invoked by uid 1010); 2 Dec 2007 00:59:56 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 23187 invoked from network); 2 Dec 2007 00:59:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Dec 2007 00:59:56 -0000 Authentication-Results: pb1.pair.com smtp.mail=ekneuss@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ekneuss@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 72.14.246.241 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: ekneuss@gmail.com X-Host-Fingerprint: 72.14.246.241 ag-out-0708.google.com Received: from [72.14.246.241] ([72.14.246.241:59961] helo=ag-out-0708.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 13/E3-24257-98302574 for ; Sat, 01 Dec 2007 19:59:54 -0500 Received: by ag-out-0708.google.com with SMTP id 31so3054307aga for ; Sat, 01 Dec 2007 16:59:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:references:x-google-sender-auth; bh=9JWBblmZDniVTnYwGwNZToDzFwmiqDzNh/nuMTdNY7Q=; b=EGcqMsyRtsaOZj+RJP5pv9/ilEKXKtw75kntkA2G444zJxzVRXEcuPUT1QqBvnT3/EV8WY562yXh7CfMvj6sjwuN4hlma2spFiv086BJ6yVlCUuMdPuTC5by6yLOktaFUJIdISh+wviIcl+oL88WtqO+w7DmEs9MemlW6K2f5Ak= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:references:x-google-sender-auth; b=jci8iTSm807vVppbzS+Bte0jDG88+EPuT+KtLyanoUxL5j26/oxwPveEsNgBHB3tBJsje49d9sUJLFEDlzCapyA5wpNHrSHydO5TvPffXTruqMPw7mxODzhYwZMMscLb7EtNC9xp1v73xlAxm1ecVWd2Ih3iDtEMbZNJstc0mXQ= Received: by 10.70.80.14 with SMTP id d14mr19224wxb.1196557190355; Sat, 01 Dec 2007 16:59:50 -0800 (PST) Received: by 10.70.41.7 with HTTP; Sat, 1 Dec 2007 16:59:50 -0800 (PST) Message-ID: Date: Sun, 2 Dec 2007 01:59:50 +0100 Sender: ekneuss@gmail.com To: RQuadling@googlemail.com Cc: "Jingcheng Zhang" , "=?ISO-8859-1?Q?Johannes_Schl=FCter?=" , "Marco Kaiser" , internals@lists.php.net In-Reply-To: <10845a340712011238t79472d34h1736403c416c65b5@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_4426_11737708.1196557190344" References: <474ff865.0d135e0a.4536.ffffa229@mx.google.com> <1196441832.1563.19.camel@johannes.nop> <10845a340712011238t79472d34h1736403c416c65b5@mail.gmail.com> X-Google-Sender-Auth: a75ff57e62bb7f28 Subject: Re: [PHP-DEV] private properties .... From: colder@php.net ("Etienne Kneuss") ------=_Part_4426_11737708.1196557190344 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello, On Dec 1, 2007 9:38 PM, Richard Quadling wrote: > On 01/12/2007, Jingcheng Zhang wrote: > > Well, yes, "private" denies accessing from other class(including its > child > > class), this is what "encapsulation" means. But when refering to > > inheritance, why forbids private properties/methods being *extended* to > > child classes? This is what I mean, as the following example: > > > > > class p { > > protected $foo = 'foo'; > > private $bar = 'bar'; > > } > > class c extends p { > > public function f() { > > $o = new p(); > > $o->foo = 'FOO'; // Correct, "foo" is protected property of p > and > > thus allow accessing from child class > > This is not allowed. $o is in a different context (I think that's the > right way of describing this) and as such has no access to the private > or protected members of $o. Just because it $o is created within class > c, it is not related. Again, the context check is based on the class and not on the instance, which is "correct" (same behavior in other OO languages like java, scala, or C++) I believe what he means is that private properties are simply masked, allowing one user to dynamically create an "overloaded" property, like: class A { private $a; } class B extends A{ private $a; // allowed, but I guess what he wants is to have that optional public function foo() { $this->a = 3; } } Having this optional is a bad thing because: 1) it reduces the readability 2) the access type of the dynamically created B::$a would be ambiguous. So, you should always explicitly define the overloaded property, and the language shouldn't be modified to allow such concept. Please take this to php_generals as this is not really the right place anymore. Regards -- Etienne Kneuss http://www.colder.ch Men never do evil so completely and cheerfully as when they do it from a religious conviction. -- Pascal ------=_Part_4426_11737708.1196557190344--