Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37318 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37758 invoked from network); 30 Apr 2008 00:14:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Apr 2008 00:14:28 -0000 Authentication-Results: pb1.pair.com header.from=rquadling@googlemail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=rquadling@googlemail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 209.85.146.182 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: rquadling@googlemail.com X-Host-Fingerprint: 209.85.146.182 wa-out-1112.google.com Received: from [209.85.146.182] ([209.85.146.182:37688] helo=wa-out-1112.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1E/51-28930-1E9B7184 for ; Tue, 29 Apr 2008 20:14:26 -0400 Received: by wa-out-1112.google.com with SMTP id v27so258326wah.17 for ; Tue, 29 Apr 2008 17:14:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=/A7/YL22m48mvn6qY2Nw66fpxNHlYuTvhTYWKClr28A=; b=aFGqLfEUiDrzkY61cb0MF71Ww2ukJoQ1IAkm/EPJg059yQAZCjqPKFMXOiLelGH4vIEmPQxiGkWkWMZdjXXKQcvtub9y+mywg/X8bP1WZAB8UfscKMjgruAbu44PJBPOqZIqML82beaU+5FdmP8oHsaEsTtwqfu1FAyIt/GI3LE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=fTwFE43S6OnJ6HWL8Daf+nZzuifjtKUBWCVo6BF76qzjv0wT+pHaSxuU2V3QegeoqOTIdG38WK97KgdDAi5JUvyn14FtPDiH0+e7v3B9N6Au3mGEgHJOiWygsj7W03iIE3opDx0ez3cX0hgYYpFwSBLzQFD9vPFcvr/bnxpdiD4= Received: by 10.114.106.1 with SMTP id e1mr68126wac.95.1209514461936; Tue, 29 Apr 2008 17:14:21 -0700 (PDT) Received: by 10.114.209.15 with HTTP; Tue, 29 Apr 2008 17:14:21 -0700 (PDT) Message-ID: <10845a340804291714g7eb10362m17af4abecbadf0e4@mail.gmail.com> Date: Wed, 30 Apr 2008 01:14:21 +0100 Reply-To: RQuadling@GoogleMail.com To: "Robert Cummings" Cc: "John Carter -X (johncart - PolicyApp Ltd at Cisco)" , internals@lists.php.net In-Reply-To: <1209512914.7057.296.camel@blobule> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <48169695.9040803@omegavortex.net> <339714303.20080429114607@marcus-boerger.de> <27A086AB-E111-49C1-ABBD-28FB6E1677BD@procata.com> <48175A65.4070301@zend.com> <1209512914.7057.296.camel@blobule> Subject: Re: [PHP-DEV] Class Properties in Interfaces? From: rquadling@googlemail.com ("Richard Quadling") 2008/4/30 Robert Cummings : > > On Tue, 2008-04-29 at 20:04 +0200, John Carter -X (johncart - PolicyApp > > Ltd at Cisco) wrote: > > I think there's been two responses to this query: > > > > 1. We can't have properties in interfaces because interfaces don't have > > properties. I would say this is tautological and doesn't add anything. > > > > 2. Why would you need to? Getters and setters work. > > > > So I suppose to answer my question for myself, there's no real technical > > reason for not having properties in interfaces, but getters and setters > > work just fine and no-one (including me) really misses them. > > I have to agree. Enforcing existence of a property is just as much part > of an interface as enforcing the existence of a method. Why go down the > clutzy getter and setter method route when properties were meant to be > accessed. Why should code be made slower? Methods are at least an order > of magnitude slower than direct property access. > > Cheers, > Rob. > -- > http://www.interjinn.com > Application and Templating Framework for PHP There are some advantages. 1 - Read only / write only properties can be created more obviously, rather than having the logic spread thoughout the __magic_functions. 2 - Automatic document tools get a real benefit from having a defined mechanism to work from. Using a simple shape class, it is a toss up between $shape->getArea() vs $shape->area If PHP supported setters/getters in this way, then the interface for a shape would have a fCalcArea member function requirement. You may want to have the area updated upon the change of any of the dimensions. Ideally the interface should also have a read only property of area, but the support of properties in an interface is disputed here. In this limited example, it would seem useful. Richard. -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!"