Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:63422 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 8678 invoked from network); 15 Oct 2012 16:33:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Oct 2012 16:33:42 -0000 Authentication-Results: pb1.pair.com header.from=ekneuss@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ekneuss@gmail.com; spf=pass; 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: ekneuss@gmail.com X-Host-Fingerprint: 209.85.220.42 mail-pa0-f42.google.com Received: from [209.85.220.42] ([209.85.220.42:38653] helo=mail-pa0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 05/30-07213-4EA3C705 for ; Mon, 15 Oct 2012 12:33:41 -0400 Received: by mail-pa0-f42.google.com with SMTP id fa1so5074943pad.29 for ; Mon, 15 Oct 2012 09:33:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=Ud9KCupt7c0fgGmdqB4USRQ35+jOV4CSGVGqU+wZKPk=; b=Dibt1KMDMUfvo+JP8eSQQ6fLCIX6K94Tl5kjuc4jYk9hiiEyd55qwBTrOarOYfwOww qjnsbv2dvL9aHpplyMPA4gyY7scCr9aGKBR+/rbQHiNfrw0pZzQewuw37dxJncS57XDr xggJyA1FrFB6k2f3NF+RjPZsEun7MGPeGzK6PtCwtGhYiAbPJXNNaPFbFt/lsgACQ6e3 2cxg3PQfiFYaaguir1CnZzTE+9deWBfcLzVQ+1IT58dv3WRSpQPmhVz6NpDYmkZ30P2b RDrnH6XyizL4LJIFr0Ubf9P1lSlccSoB0bFOcyGuu9TRThf8pcB7scJo8Lgp51GG9K7A gP2g== Received: by 10.66.85.227 with SMTP id k3mr34075758paz.79.1350318818441; Mon, 15 Oct 2012 09:33:38 -0700 (PDT) MIME-Version: 1.0 Sender: ekneuss@gmail.com Received: by 10.68.144.42 with HTTP; Mon, 15 Oct 2012 09:33:18 -0700 (PDT) In-Reply-To: <56FF073D-826C-444F-8843-9739E568919E@zerocue.com> References: <9570D903A3BECE4092E924C2985CE485612B6466@MBX202.domain.local> <9570D903A3BECE4092E924C2985CE485612B655A@MBX202.domain.local> <9570D903A3BECE4092E924C2985CE485612B6654@MBX202.domain.local> <56FF073D-826C-444F-8843-9739E568919E@zerocue.com> Date: Mon, 15 Oct 2012 18:33:18 +0200 X-Google-Sender-Auth: 8HvSNcg19X70vCrgkaYdcg32yNk Message-ID: To: Clint Priest Cc: Levi Morrison , "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [PHP-DEV [RFC] Property Accessors v1.2 : Interfaces From: colder@php.net (Etienne Kneuss) Hi, On Mon, Oct 15, 2012 at 6:02 PM, Clint Priest wrote: > Because fundamentally interfaces are designed to explain a way of communi= cating 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 =3D $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 =3D ...; 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. This discussion makes we wonder about another aspect of the patch that is unclear: class A { public $v =3D 2; } class B extends A { public $v { get { .. }; set { .. } }; } Will $b->v trigger the accessors, will it ignore them and access "v" in the properties table, or is overriding existing properties using accessors rejected during compilation? Best, > > -Clint > > On Oct 15, 2012, at 9:37 AM, "Levi Morrison" wr= ote: > >>> I *think* we are on the same page here, though I'm not sure what 'user'= is referring to (user of interface "implementer") or (user of class B). I= n any case, I don't believe that your class B would be allowed at present, = but if it is, then it should not be allowed because defining a property to = satisfy the requirements of an accessor is not right. >> >> According to whom? In my opinion, not allowing a property to satisfy >> the requirement of an accessor is wrong. --=20 Etienne Kneuss http://www.colder.ch