🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.vms
Article #162

Re: PHP "Features"

#162
From: Arne Vajhøj
Date: Sat, 14 Nov 2026 18:22
92 lines
3067 bytes
On 10/26/2026 9:21 PM, Dan Cross wrote:
> term% ruby
> class A
>    def foo
>      bar
>    end
> 
>   private
>    def bar
>      puts "Hello from A's bar"
>    end
> end
> 
> class B < A
>   private
>    def bar
>      puts "Hello from B's bar"
>    end
> end
> 
> a = A.new
> a.foo
> b = B.new
> b.foo
> Hello from A's bar
> Hello from B's bar

> In *this* language, `private` doesn't mean what it means in C++.

In Ruby it means object private instead of class private. And as
demonstrated in my other post then it is a OO encapsulation
disaster.

But the second example quoted here is actually not different from C++.
Because C++ interprets visibility as just that and does not
include overrideability.

#include <iostream>

using namespace std;

class A
{
private:
     virtual void bar() { cout << "Hello from A's bar" << endl; }
public:
     void foo() { bar(); }
};

class B : public A
{
private:
     void bar() { cout << "Hello from B's bar" << endl; }
};

int main()
{
     A *a = new A();
     a->foo();
     B *b = new B();
     b->foo();
     return 0;
}

also outputs:

Hello from A's bar
Hello from B's bar

It has very little practical impact as those C++
developers that really want to limit bar to A
just omit the virtual.

The construct of private virtual is still used though
because some very smart people have found out that
base classes with public non-virtual methods and
private pure virtual methods has some advantages.
It provides better encapsulation.

Anyway - it does not really relate much to the topic
at hand - just wanted to note that for this particular
example Ruby actually is like C++.

Arne







Technical Details
Message-ID: <11da8s3$25hpa$4@dont-email.me>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <11bcbi1$k068$1@dont-email.me> <11bjl55$shh$1@reader2.panix.com> <11bjlgb$37fah$1@dont-email.me> <11bjm3a$i12$1@reader2.panix.com> <11bouab$2dh$1@reader2.panix.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Arne Vajhøj <arne@vajhoej.dk>
Newsgroups: comp.os.vms
Subject: Re: PHP "Features"
Date: Sat, 14 Nov 2026 13:22:40 -0500
Organization: A noiseless patient Spider
Lines: 92
Message-ID: <11da8s3$25hpa$4@dont-email.me>
References: <11bcbi1$k068$1@dont-email.me> <11bjl55$shh$1@reader2.panix.com>
 <11bjlgb$37fah$1@dont-email.me> <11bjm3a$i12$1@reader2.panix.com>
 <11bouab$2dh$1@reader2.panix.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 14 Nov 2026 18:21:56 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="2279210"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19/QcXCEryqAwTZqG6MYfPDI+s1A0TnAGY="; posting-host="61d91260449277eb6ca39880cc2a736b"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:hrNJl8S/l3htSsoYLJSs/BjWjjs= sha256:PstT64PDDEzjWgMUnE09hr7kJpI496BcOl6U2MhWhLM=
	sha1:a6gp5Lm7Lx/mitmzbn4HZiwx+dY= sha256:IVmM7A+yVfw6IyXQdM3L3aZnrnRzwk+eCHoLT5nNwII=
In-Reply-To: <11bouab$2dh$1@reader2.panix.com>
Content-Language: en-US