Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:89791 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 82597 invoked from network); 10 Dec 2015 14:45:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Dec 2015 14:45:13 -0000 Authentication-Results: pb1.pair.com header.from=bishop.bettini@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=bishop.bettini@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.54 as permitted sender) X-PHP-List-Original-Sender: bishop.bettini@gmail.com X-Host-Fingerprint: 74.125.82.54 mail-wm0-f54.google.com Received: from [74.125.82.54] ([74.125.82.54:35788] helo=mail-wm0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 50/B1-05164-7FF89665 for ; Thu, 10 Dec 2015 09:45:12 -0500 Received: by mail-wm0-f54.google.com with SMTP id u63so26967920wmu.0 for ; Thu, 10 Dec 2015 06:45:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:sender:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=xyWqQje9nkdnno6BV9pKqtMcAiCF3Zn6k0SFxcmm/Ws=; b=WAQKWmbfZBwYDdmSMVedSc8KGzpMUBteQ8dLsU7Jh3FYWb7AKmIIWyPwmhX9Bz9RuJ wNDzL2t/MuPmQpE4SwZiX1eTSc48j8OWG4N94V7QEt0qE3XN1EwpR11Z8shqlY2UEIqq A/ImYe4nJS7/rA4R7nUUHgWDI/KXXS63Vj6+s0Pu225lSzLMNOeMtowUWWzgzb2KGqYR hhK+dKTw6jf5kJO6Lr5mAIZPR5UBwyjSz8pRExhNsP4vCAvrmmRIKRrv0mtcC9n9qbBH s+ir+miPhsotvJOSh6zA/Yh10zRZWSkoGdpjn1f3V9ofpZK+OLZM31svL/IzzsHlz66A 5CAA== X-Received: by 10.28.68.133 with SMTP id r127mr19299357wma.71.1449758709029; Thu, 10 Dec 2015 06:45:09 -0800 (PST) MIME-Version: 1.0 Reply-To: bishop@php.net Sender: bishop.bettini@gmail.com Received: by 10.194.45.230 with HTTP; Thu, 10 Dec 2015 06:44:39 -0800 (PST) In-Reply-To: References: <348752699.466407212.1449572494594.JavaMail.root@zimbra71-e12.priv.proxad.net> Date: Thu, 10 Dec 2015 09:44:39 -0500 X-Google-Sender-Auth: DZ-pKKU8q7bYKGbsW6Qeib1NPio Message-ID: To: Dustin Wheeler Cc: flaupretre@free.fr, PHP internals Content-Type: multipart/alternative; boundary=001a1148db8edca2ff05268c4001 Subject: Re: [PHP-DEV] Class Friendship in PHP From: bishop@php.net (Bishop Bettini) --001a1148db8edca2ff05268c4001 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Thu, Dec 10, 2015 at 12:02 AM, Dustin Wheeler wrote: > > Both of these approaches acknowledge the problem-space of > "private collaborators". "Private collaborators" itself is perhaps > loaded terminology as it happens to reuse an already-defined concept > in this domain: `private`. The intent is to be able to express an > intimate relationship between two or more classes of object for some > justifiable domain-specific modeling reason. > Since friendship is about visibility, and "private" is already a well-defined term in discussions about visibility, I would avoid the term "private" in discussions about friendship unless you actually mean "private visibility". To me, the nut of the solution is expressed as: Class members declared as friend can be accessed by only those classes explicitly listed as being collaborators. > - I would extend the syntax to namespaces. For examples, '\MyNS\' (syntax > to dicuss) would declare every class in the '\MyNS' namespaces or > sub-namespaces as friends. Must support 'friend __NAMESPACE__' or somethi= ng > equivalent. This, coupled with a protected __construct() method would > provide something quite similar to package-private access, but more > extensible and powerful. > > > > Fran=C3=A7ois, would you be willing to describe more of the reasoning > behind this? Specifically "more extensible and powerful" [for what?]. > Also, I can't think of a better way to word that request, but see how > it can come across as a direct-challenge. Just want to say I'm > genuinely curious to what the intended outcome is and don't mean to > come across as "point-y". > One example comes to mind. Imagine you have a service "manager" class that accepts an abstract "worker" class. You then have several concrete worker implementations. It would be nice to be able to, at a namespace level, say all these workers are friends of the manager. Systems where you have pluggable drivers (eg databases) or lots of collaborating objects (charting systems) would benefit from a granular way to declare friendship. > I don't know that I would use friendship > as a means to make an entire package (namespace, in PHP's case) aware > of a single object. I think it's the other way around: a single object declares its friendship with an entire namespace. Looking forward to the RFC! --001a1148db8edca2ff05268c4001--