Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66398 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 55892 invoked from network); 1 Mar 2013 19:44:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Mar 2013 19:44:14 -0000 Authentication-Results: pb1.pair.com smtp.mail=dmgx.michael@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dmgx.michael@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.42 as permitted sender) X-PHP-List-Original-Sender: dmgx.michael@gmail.com X-Host-Fingerprint: 74.125.82.42 mail-wg0-f42.google.com Received: from [74.125.82.42] ([74.125.82.42:56824] helo=mail-wg0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C8/44-31226-D0501315 for ; Fri, 01 Mar 2013 14:44:14 -0500 Received: by mail-wg0-f42.google.com with SMTP id 12so19454wgh.5 for ; Fri, 01 Mar 2013 11:44:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=hPhsC3NtCd2+J4lnvsJ1m2zjYQuwwpKNX8iDiH0L5CE=; b=nj8TjR7wpCkMbdX2u+kiZE1hRpGk06+H434UBhL0kdTHrZXE52sayGarh0ayuRJBX9 c7hMoeLpZ58EtEQXt+9nkU9U2cRJxZa+g6v0fTkSPGveTwR+OCdxgtQ32v9Yo8S39sVJ CkppuTBe/xTMgA3noqLDzP1PEXw0/FsDWyjCjzf6rypcW+vYBXTwIu7x6sDRhFVycI/o EXJ9lUatHZdN6eqUkQEJuJIePaP3sw3d1JE7wo3NCvtmJvXimmc/xEmDdMtO3rmqrBT6 s+9iIahBKpWJkJlUyJHYNu+i0YFvCZFhN8qrC6Tjdwcb+0TiOY5k2wsExFk6JNP91MoK Nb9g== MIME-Version: 1.0 X-Received: by 10.180.94.135 with SMTP id dc7mr41352269wib.11.1362167051086; Fri, 01 Mar 2013 11:44:11 -0800 (PST) Received: by 10.194.1.3 with HTTP; Fri, 1 Mar 2013 11:44:10 -0800 (PST) In-Reply-To: References: <7E088EEC-ACB7-4977-BE00-CEA17ABD6EC3@me.com> Date: Fri, 1 Mar 2013 14:44:10 -0500 Message-ID: To: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=f46d04462e7a34710004d6e23b49 Subject: Re: [PHP-DEV] I would like to write an RFC for the addition of an internal keyword From: dmgx.michael@gmail.com (Michael Morris) --f46d04462e7a34710004d6e23b49 Content-Type: text/plain; charset=ISO-8859-1 My thoughts are that no additional keyword is necessary - allow protected and private to be used in this scopes. A protected element of a namespace can be accessed within that namespace or any sub-namespaces, and a private element would only be visible by code in the same namespace. Hence namespace A { protected class Bar(){} } namespace B { new \A\Bar(); // fails, protected. } namespace A\C { new \A\Bar(); // works, C is A's child. private class Foo(); } namespace A\C\D { new \A\C\Foo(); // fails, private and only reachable from \A\C } This accomplishes the same as the proposed keyword, and then some, and doesn't introduce the BC break of a new keyword. On Fri, Mar 1, 2013 at 6:11 AM, Julien Pauli wrote: > On Thu, Feb 28, 2013 at 12:40 PM, Lazare Inepologlou >wrote: > > > Hello, > > > > please read my comment inline... > > > > 2013/2/28 Sebastian Krebs > > > > > 2013/2/28 Jens Riisom Schultz > > > > > > > Hi everyone, > > > > > > > > (I got "hooked off" this discussion, so I have tried to keep up by > > > reading > > > > the digest... This makes it impossible for me to correctly interleave > > my > > > > comments, so I'll just "top post" or whatever the term is) (I'm sure > > this > > > > has been mentioned before but a forum would be so much more accesible > > > than > > > > this mailing list concept...) > > > > > > > > > > > > * In response to the argument that you want to be able to modify a > > > > framework or use it in an unintended manner: > > > > This would be possible by explicitly stating "namespace Framework;" > in > > a > > > > given php file. > > > > > > > > * In response to the argument that php has no assembly concept: > > > > I know this, but namespaces are as close as we get, and would > > effectively > > > > solve this. > > > > > > > > > > No. A namespace is in fact more or less just a prefix, that groups the > > > containing elements together. Beside the semantic meaning of grouping > > they > > > don't have any further abilities, or meaning. > > > Without knowing exact details I guess, that "internal" in C# is > primary a > > > technical thing, that allows a compiler further optimizations, because > he > > > definitely knows, that the function/method is only used within the > > assembly > > > and is not required to do anything to expose it to the outside? > > > > > > > > Regardless of the technical details, it is still a fine way of applying > > encaptulation so you can't say that it is only a technical thing. > > > > > > > > > > > > > > > * In response to the argument that php already has accessibility > > > > restrictions with private and protected: > > > > This is true, but it does not solve all problems. Often you need > > classes > > > > to interoperate in a way that can only be facilitated by making > > > > functionality public. Also, there is no way to make a private or > > > protected > > > > class (since php has no assembly concept), though what I propose > would > > > > likely birth the concept of private and protected classes as well. > > > > > > > > > > Maybe it's just me, but no: I've never had the need of what you > describe > > > and where a public method wasn't apropriate anway... At least for a > very > > > long time :D > > > > > > > > > > > > > > * In response to the argument that PHP does not restrict anyone from > > > > adding to a namespace: > > > > That is true, but say you were using Doctrine2. Would you ever make a > > php > > > > file with "namespace Doctrine2;" in it, unless you wanted to modify > > > > Doctrine2, and hence you knew what you were doing, or accepted the > > risks? > > > > > > > > > > Well, yes. But extending/overriding a components method _always_ > > requires, > > > that you know what you do, so why enforcing/encouraging hacks, instead > of > > > the good old "protected"? > > > > > > > > "Protected" is used for extending classes. There is no mechanism to > inherit > > and extend a namespace so "protected" is irrelevant here. > > > > > > > > > > > > > > > * In response to the concept of solving this through documentation: > > > > First off, this is not possible with the current phpdoc and phpdoc2 > > > > standards. Second off, problems like these should not be solved by > > > > documentation, imho, or of course I would not propose this. The C# > > > > designers seem to agree with me. And the Java designers, too (though > > they > > > > have no internal keyword they do have a way of hiding framework > > specific > > > > classes). > > > > > > > > > > > > > Actually Java has a concept that is identical to your proposal. The > default > > access modifier (when no access modifier is written) is the "package" > > modifier (=accessible from within the same package). > > > > Ha, it's been years since I'm asking for such a feature to come to PHP. > > I would love to see a package visibility in PHP, restricting access to > 'package'ed members (methods or attributes) to an object born from a class > of the same namespace. > Would really help some cases in frameworks or so :-) > > Just my2cents > > Julien > --f46d04462e7a34710004d6e23b49--