Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:63428 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61668 invoked from network); 16 Oct 2012 03:43:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Oct 2012 03:43:50 -0000 Authentication-Results: pb1.pair.com smtp.mail=davidkmuir@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=davidkmuir@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.42 as permitted sender) X-PHP-List-Original-Sender: davidkmuir@gmail.com X-Host-Fingerprint: 209.85.220.42 mail-pa0-f42.google.com Received: from [209.85.220.42] ([209.85.220.42:48316] helo=mail-pa0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 22/E7-07213-4F7DC705 for ; Mon, 15 Oct 2012 23:43:50 -0400 Received: by mail-pa0-f42.google.com with SMTP id fa1so5556572pad.29 for ; Mon, 15 Oct 2012 20:43:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=5lxhgv/koAScZQNbKLHGmjKvGlDrrSI+4h4UFCWV1ww=; b=urmBzrSV35sTqyUUqaaGy9/vTIt2GlfEe0z36xGjvwOJFkDGTOAJU3ZRap2LyDsRlS TwR9eZWgfKsHsxgQIILiTe8NjOQVP+ZMFqNBbssi307lnFTg0xdBaVjAnZj9vw/eW3kE qr2mrT0sHjmc8IxR7cTwyL0d0yfK9OW8pgSrCa6/D2xFEvItVfRlLyrK58pN6qhnM4hi btqvtHweXYW0nq9SRGzSKrZkwfENU4KzMQZjZ9BgyWlxDB6WLR13KFiFxWVLBp/Ry0qv vr5yEen0YngVPt1/AjvXGCyFsGaGGW/A69BXjYTM1dllL9ArW2B/3GLbnbTpkUiN9495 XIPA== Received: by 10.68.115.75 with SMTP id jm11mr42973894pbb.28.1350359025870; Mon, 15 Oct 2012 20:43:45 -0700 (PDT) Received: from [192.168.1.181] (tmwpho1.lnk.telstra.net. [110.142.207.74]) by mx.google.com with ESMTPS id wo9sm10053794pbc.53.2012.10.15.20.43.43 (version=SSLv3 cipher=OTHER); Mon, 15 Oct 2012 20:43:45 -0700 (PDT) Message-ID: <507CD7ED.3000301@gmail.com> Date: Tue, 16 Oct 2012 14:43:41 +1100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121011 Thunderbird/16.0.1 MIME-Version: 1.0 To: Clint Priest CC: Etienne Kneuss , Levi Morrison , "internals@lists.php.net" References: <9570D903A3BECE4092E924C2985CE485612B6466@MBX202.domain.local> <9570D903A3BECE4092E924C2985CE485612B655A@MBX202.domain.local> <9570D903A3BECE4092E924C2985CE485612B6654@MBX202.domain.local> <56FF073D-826C-444F-8843-9739E568919E@zerocue.com> <9570D903A3BECE4092E924C2985CE485612B69D2@MBX202.domain.local> In-Reply-To: <9570D903A3BECE4092E924C2985CE485612B69D2@MBX202.domain.local> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [PHP-DEV [RFC] Property Accessors v1.2 : Interfaces From: davidkmuir@gmail.com (David Muir) 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