Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:90341 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 90110 invoked from network); 8 Jan 2016 03:59:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Jan 2016 03:59:34 -0000 Authentication-Results: pb1.pair.com header.from=mdwheele@ncsu.edu; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=mdwheele@ncsu.edu; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain ncsu.edu from 209.85.215.53 cause and error) X-PHP-List-Original-Sender: mdwheele@ncsu.edu X-Host-Fingerprint: 209.85.215.53 mail-lf0-f53.google.com Received: from [209.85.215.53] ([209.85.215.53:33484] helo=mail-lf0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 18/56-55593-3243F865 for ; Thu, 07 Jan 2016 22:59:33 -0500 Received: by mail-lf0-f53.google.com with SMTP id m198so20647953lfm.0 for ; Thu, 07 Jan 2016 19:59:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ncsu-edu.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=sfAivNOh+buulohUuY1jkmvaOQx+2ocjLqdoK9ymo6A=; b=gQI3aWT4SqRJepl1/eHINl972pmRMUFcopLgeW2f98LIdeE7zmGDp5HOlkeGTYjrbH fu2A0JXoqZTfXPGG1TXcwoIhKpBizzCPz4JDbH9Qg4Oyr9olagzVnyrvEbWmj7OHbhVz 8lsSCa3UF5NVWT86O4ZYZihjQktc20Ig+EQoX4LTaNjn8jbUX29Z+3kKZ/xVA2VtB6RE v0AroMr2VsB4XNBp4mrHCBPLlkHIa87cBLGvKd78NgWwHQXrAgf8jM6+qJ/ehxaTFUjH jhTegsGUbwa7n49IJPYXtjdxcrtF28TPiZucPWrhKHH7EEoy28HpIJJIYYDxgUXyt7vg lx9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=sfAivNOh+buulohUuY1jkmvaOQx+2ocjLqdoK9ymo6A=; b=Dq6I9DBXL8RdZUe/Ph4UwfQ3UbBagfpGQuHjQVlSsASE8uSUWij5kT+tOJxg5xQx+O u1OVJPTAUjgQMtzQX0ALYXjBBfmIduSLmwPqnzyBoIb5HYrcQZmkxiWUEowPRU0l3Vau 3uGU3ilM6W2KD/OeAYqI99e3IP+R+1aTyxbQWYh8M/0owO/V26AOtGGwtwwXtkkMpfaH KMotcBcVCrM981TvJPjzNcl5l/dRNoi8xKqlbSEPdlMkoTQSX1kUQ0xT/ouB8PDX2Ifu ihYABMpNrdZQPbLNwY9NBmTy6UI9YZKUOLv3sX+jFOBCwK0gx2zM1nLvjBbS4p+ogIJx yawg== X-Gm-Message-State: ALoCoQmdQkNh33BVt6LpPx/psV76gxcC1Ax5Q9upGibidfNgQB0WMh3+ubwvzirTwfi37jiYXjYdJlVfwWrHwJMnAFzPTRk9fBkkFbgToGIGg2L2wEGTaDo= MIME-Version: 1.0 X-Received: by 10.25.151.71 with SMTP id z68mr20447180lfd.122.1452225568589; Thu, 07 Jan 2016 19:59:28 -0800 (PST) Received: by 10.112.108.198 with HTTP; Thu, 7 Jan 2016 19:59:28 -0800 (PST) In-Reply-To: <568F11FB.10106@php.net> References: <568F11FB.10106@php.net> Date: Thu, 7 Jan 2016 22:59:28 -0500 Message-ID: To: =?UTF-8?Q?Fran=C3=A7ois_Laupretre?= Cc: PHP internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] Class Friendship From: mdwheele@ncsu.edu (Dustin Wheeler) Hi Fran=C3=A7ois, On Thu, Jan 7, 2016 at 8:33 PM, Fran=C3=A7ois Laupretre = wrote: > > * There is another inheritance property I didn't include in my initial > article, and I think that should be described : > > class Base { > friend BaseFriend; > protected $base_prop; > static protected $base_static; > } > > class Derived extends Base { > protected $derived_prop; > static protected $derived_static; > } > > class BaseFriend { > > public function display() > { > $d =3D new Derived(); > > var_dump($d->base_prop); // OK > var_dump(Derived::$base_static) // OK > > var_dump($d->derived_prop); // Error > var_dump(Derived::$derived_static); // Error > }} > > I try to express it with words : a friend of a base class can access the > properties and methods of this base class through a derived instance. THe > same for static properties and methods through a derived class. I know it= 's > not very clear but the example should be better. Actually, that could be = a > sub-chapter of the 'Friendships are not inherited' property. I agree. This should be added. Reviewing this now, I also realize that I've unintentionally worded things to suggest that only protected *properties* (not methods) are accessible to friend classes. This is incorrect. I will be adjusting wording to replace occurrences of "properties" with "members". I will likely find a way of peppering that into the examples as well. What do you think about wording above the examples (which would include elements quoted above) to the effect of "In addition, protected members of Base are also accessible *through* Derived". This would make this one larger example, with the last code block demonstrating the rule you've described. > > * After thinking more about it, I now think we should allow some sort of > friendship inheritance but only in one way : while a Friend of Base is no= t a > friend of Derived, a DerivedOfFriend class would also be a friend of Base > (it inherits the 'friendship' property from its 'Friend' base class). I > think this would be more natural and avoid several limitations. It also > allows to respect the Liskov Substitution Principle, which is probably a > good thing (but I'm not an expert there ;). > This is interesting. I'm going to need to think on this a bit more but I understand what you're saying. If included, I want to have a good example of when I would grab for this. Additionally, we can always leave ourselves open to this in the future as well. I'm neither for or against this right now. I'm going to reserve further comment here for now. If you have an application of this property in-mind, I am interested. > > * In the RFC Impact / To Reflection API chapter, I think there's a > copy/paste error. 'Trait' should probably be replaced with 'Friend'. > I've amended this in v0.2.1. Indeed, it is a copy/paste error from the documentation regarding how ReflectionClass supports query on attached Traits. > > * While it's fine to explore future scope, detailing it too much brings t= he > risk that people focus on this part and reject the whole RFC. That's just= an > advice because I also preferred exploring every aspects of the subject, > I agree. I left it in for discussion to see if I got exactly that feedback, haha. There are a lot of details, already, in explaining the feature and its properties. Near the tail-end of the document, the reader probably is at "information overload". The chapter on combining friendship types is easily removed as it really doesn't add anything non-obvious. I think it would be reasonable to remove examples from other future work and pare down from there. I wonder if it is valuable (or not) to justify the future scope rather than simply list future work that could be done. In fact, this chapter started out as a simple bullet-ed list. > > * Voting choices : It's generally preferred that RFCs are as opinionated = as > possible. So, a single approve/reject vote is preferred. In the RFC, you > explain that you chose that, unlike C++, friends access protected propert= ies > only, not private ones. So, there 's no reason, IMO, to vote for this. > That's *your* RFC. People read it to get an opinion to approve/reject, no= t > to make technical choices. The risk when proposing too many choices is to > look hesitating. An RFC must find the right compromise between humility a= nd > self-confidence, but hesitation is not an option. > You're the third person to make a similar comment regarding striking that balance. I'm glad to get the feedback as this is definitely new waters for me. I am confident in the decision to disallow friend access to private members and believe that is the best decision for this RFC. I'll remove the additional voting choice. > > Well, I hope you won't get me wrong, I'm just trying to help and that's o= nly > suggestions. That's your RFC, your work, your decisions. Anyway, that's a > very good work and I hope it will be approved. > Fran=C3=A7ois, I very much appreciate your suggestions and look forward to discussing this more. Thanks, -Dustin --=20 Dustin Wheeler | Software Developer NC State University m: mdwheele@ncsu.edu | w: 5-9786 "If you don't know where you're going, it's easy to iteratively not get the= re."