Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:23302 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61129 invoked by uid 1010); 12 May 2006 12:34:36 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 61114 invoked from network); 12 May 2006 12:34:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 May 2006 12:34:36 -0000 X-Host-Fingerprint: 195.225.34.5 fw01.axit.nl Received: from ([195.225.34.5:28659] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 31/5F-19568-BD084644 for ; Fri, 12 May 2006 08:34:36 -0400 Message-ID: <31.5F.19568.BD084644@pb1.pair.com> To: internals@lists.php.net References: <785810036.20060511193536@ionzoft.com> Date: Fri, 12 May 2006 14:34:18 +0200 Lines: 50 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 X-Posted-By: 195.225.34.5 Subject: Re: private, protected, readonly, public From: r.korving@xit.nl ("Ron Korving") In C++ you'd use private for this. All object members are readable, but modifyability depends on the relation between the caller and the object. I don't quite understand why PHP is doing it differently. - Ron "Jason Garber" schreef in bericht news:785810036.20060511193536@ionzoft.com... > Hello internals, > > __get() and __set() are great, but 90% of the time, I find myself > using them to create public readonly properties. > > The only problem with this is it is horridly inefficient, consuming > at least 1 function call and one switch statement (or equiv) per > property read. > > Would it be possible to create a new object property attribute: > readonly > > class xx > { > readonly $bar; > } > > $o = new xx(); > > $o->bar = 10; > >>> FATAL ERROR > > > This way, PHP would allow reading (as if it were public), but only > allow writing from within the class. > > I think it could really boost performance of complicated application > logic that wishes to enforce good visibility. > > Comments? > > PS. What brought this up was some serious performance issues in a > piece of code that I am working with - most of which can be tied > back to __get() performance. > > -- > Best regards, > Jason Garber mailto:jason@ionzoft.com > IonZoft, Inc.