Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37335 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 19811 invoked from network); 30 Apr 2008 06:51:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Apr 2008 06:51:33 -0000 Authentication-Results: pb1.pair.com header.from=robert@interjinn.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=robert@interjinn.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain interjinn.com from 66.11.173.122 cause and error) X-PHP-List-Original-Sender: robert@interjinn.com X-Host-Fingerprint: 66.11.173.122 unknown Received: from [66.11.173.122] ([66.11.173.122:56713] helo=interjinn.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EE/5D-28930-4F618184 for ; Wed, 30 Apr 2008 02:51:33 -0400 Received: from [192.168.1.3] (blobule.suds [192.168.1.3]) by interjinn.com (Postfix) with ESMTP id 5D19011FB6D; Wed, 30 Apr 2008 02:51:25 -0400 (EDT) To: Stanislav Malyshev Cc: internals@lists.php.net In-Reply-To: <4818139B.1080301@zend.com> References: <48169695.9040803@omegavortex.net> <1209512914.7057.296.camel@blobule> <10845a340804291714g7eb10362m17af4abecbadf0e4@mail.gmail.com> <7dd2dc0b0804291801m627a7c31h8dd796d7fa1d1257@mail.gmail.com> <1209518549.7057.313.camel@blobule> <7dd2dc0b0804292051o4fd5e77eu6f8faecad93c378a@mail.gmail.com> <1209528338.7057.349.camel@blobule> <7dd2dc0b0804292127p484d8c7g9cf852f0a79a8dc6@mail.gmail.com> <1209532046.7057.368.camel@blobule> <7dd2dc0b0804292222h29c8845k456f6546cbdbece6@mail.gmail.com> <1209535288.7057.406.camel@blobule> <4818139B.1080301@zend.com> Content-Type: text/plain Organization: InterJinn Date: Wed, 30 Apr 2008 02:51:26 -0400 Message-ID: <1209538286.7057.425.camel@blobule> Mime-Version: 1.0 X-Mailer: Evolution 2.12.1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Class Properties in Interfaces? From: robert@interjinn.com (Robert Cummings) On Tue, 2008-04-29 at 23:37 -0700, Stanislav Malyshev wrote: > > $hair = new Hair(); > > $hair->colour = 'brown'; > > You can do this without pre-defining any properties. yes but the following (as I'm you certainly know): echo $hair->colour generates an E_NOTICE if the property isn't defined. > > The above is a much less wordy way of doing the following: > > No, it is not the same. You can override what happens when you do > setColor - like send notification to some other object or set also > matching color for the shoes, etc. :) but you can't have any behavior > attached to setting value. But it is the same... I can override the behaviour in magic get/set methods if I want. But the point is not necessarily to override, only to ensure the property is defined by all users of the interface. One approach (the getter/setter approach) is more versatile downstream (in the possibly unlikely event that the semantics for the property need to change), the other approach is more efficient. > > This is a feature of a dynamic language, not a flaw in my argument. And > > Not having rigid definitions of properties is also a feature of dynamic > language ;) There's nothing rigid about what Jeremy proposed. He just asked why properties can't be part of an interface definition. I don't see why not, I've shown the equivalence of properties to getter/setter methods (in simple usage case anyways), and so I've argued the point. It's not a particularly necessary feature for me, but that doesn't negate his original question as to why they couldn't be supported. Anyways, I'll stop being noisy on the list now. Nothing more to add :) Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP