Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:63429 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 63731 invoked from network); 16 Oct 2012 03:55:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Oct 2012 03:55:44 -0000 Authentication-Results: pb1.pair.com smtp.mail=tbprogrammer@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=tbprogrammer@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.219.42 as permitted sender) X-PHP-List-Original-Sender: tbprogrammer@gmail.com X-Host-Fingerprint: 209.85.219.42 mail-oa0-f42.google.com Received: from [209.85.219.42] ([209.85.219.42:55061] helo=mail-oa0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8C/48-07213-FBADC705 for ; Mon, 15 Oct 2012 23:55:43 -0400 Received: by mail-oa0-f42.google.com with SMTP id j1so6325277oag.29 for ; Mon, 15 Oct 2012 20:55:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=HSviLAtj9zDtUvIAY4NZxtypI22Z58PCjNl4wrsRQ0U=; b=PS/XbG6eZqFoSMBRSZu28tWUeQASiSnzzRLRYFqEHKH5oFjeoj/FZ4kAQB2fI3r1Ue HJImcww8U5exJsdzg26bDp0rC3RKsyC1Xq+0/ZN+6MpE35uzWMNAvDKlIjrM976BR5FW lLDhqGjAr/aRERXj4vq4Q0T0djmjczSEfxTwmtr+s/qrIsrgNfTzxVm7t8LCPxllRxmN n3rLPY6Ko30dsCU35J1LPER0JBoxp7Wj1tn6fVd2nHXru2Z9rEl6FewiXF+rHGQ+Dwaz Op8a55ora/XWZYITA7nU2+oCaJ5evZ4abC+hpnvFzu3APvjLz0aXpUKQMGOMKEMF/5Vx gkyw== Received: by 10.182.177.7 with SMTP id cm7mr1045745obc.20.1350359740840; Mon, 15 Oct 2012 20:55:40 -0700 (PDT) MIME-Version: 1.0 Received: by 10.76.11.170 with HTTP; Mon, 15 Oct 2012 20:55:20 -0700 (PDT) In-Reply-To: <507CD7ED.3000301@gmail.com> References: <9570D903A3BECE4092E924C2985CE485612B6466@MBX202.domain.local> <9570D903A3BECE4092E924C2985CE485612B655A@MBX202.domain.local> <9570D903A3BECE4092E924C2985CE485612B6654@MBX202.domain.local> <56FF073D-826C-444F-8843-9739E568919E@zerocue.com> <9570D903A3BECE4092E924C2985CE485612B69D2@MBX202.domain.local> <507CD7ED.3000301@gmail.com> Date: Mon, 15 Oct 2012 20:55:20 -0700 Message-ID: To: David Muir Cc: Clint Priest , Etienne Kneuss , Levi Morrison , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=e89a8f8396e3abfbfa04cc2520cb Subject: Re: [PHP-DEV] [PHP-DEV [RFC] Property Accessors v1.2 : Interfaces From: tbprogrammer@gmail.com (Jazzer Dane) --e89a8f8396e3abfbfa04cc2520cb Content-Type: text/plain; charset=ISO-8859-1 I'm going to agree with David here. It is most sensible to either allow properties AND accessors in interfaces, or don't allow either of them. __get/__set is a different subject that I'd rather not dig into while discussing this RFC. On Mon, Oct 15, 2012 at 8:43 PM, David Muir wrote: > On 16/10/12 13:37, Clint Priest wrote: > >> On Mon, Oct 15, 2012 at 6:02 PM, Clint Priest >>> wrote: >>> >>>> > >Because fundamentally interfaces are designed to explain a way of >>>> communicating and properties are symmetrical and non- >>>> >>> >observable. >>> >>>> > > >>>> > >The implementing class cannot "know" when a property has changed. >>>> >>> > >>> >Do you agree that there is nothing that distinguishes >>> > >>> >class A { >>> > public $v; >>> >} >>> > >>> >from >>> > >>> >class B { >>> > private $_v; >>> > public $v { get { return $this->v; }; set($n) { $this->v = $n; }} } >>> > >>> >when it comes to a client of B reading and writing to $b->v ? That's >>> the entire point of accessors: being able to seamlessly intercept >>> >usages of properties with custom code. >>> > >>> >If you define an interface saying interface A { public $v { get;set;} } >>> you are only saying to the user: objects of type A will have a >>> >property $v that you can read and write to. >>> >Whether it is a set of accessors or a property belongs to the >>> implementation detail of the class implementing A, the user should not >>> >be able to see a difference when interacting with the class, as he will >>> do it through $obj->v and $obj->v = ...; >>> > >>> >I can understand why we might not want that in PHP in order to simplify >>> the implementation, but it we follow logical reasoning I >>> >can't see why we shouldn't implement that. >>> > >>> >> I'm not sure I understand what you're getting at here Etienne, this >> thread was about interfaces but now you're talking about two classes... >> >> > From an interface standpoint, both classes implement the same property. > One as a literal property, the other as an accessor. The point being, from > the code consuming the class, a property and accessor are the same thing. > Interfaces are about contracts between an implementation and a consumer, so > the actual implementation is irrelevant. What matters is how the > implementation is accessed by the consumer. If it is via property syntax, > then it *is* a property, even though the actual implementation might be a > property, an accessor or (in theory) even __get/__set. > > Cheers, > David > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --e89a8f8396e3abfbfa04cc2520cb--