Friends?

Jonathan M Davis jmdavisProg at gmx.com
Fri Oct 19 11:36:59 PDT 2012


On Friday, October 19, 2012 20:01:20 Alex Rønne Petersen wrote:
> On 19-10-2012 08:23, Jacob Carlborg wrote:
> > On 2012-10-18 20:51, Philippe Sigaud wrote:
> >> I mean, the 'package' access modifier.
> > 
> > So did I.
> > 
> > class Foo
> > {
> > 
> > package void foo () {}
> > 
> > }
> > 
> > Would, according to the spec, imply a virtual method. But as Jonathan
> > said, this is a bug in the spec.
> 
> What? How is this not an implementation bug? An access modifier
> shouldn't have anything to do with whether a method is virtual. If
> people want to have a class hierarchy with virtual functions at package
> level, let them. This is the most ridiculous arbitrary restriction I
> have seen to date. :|

No. Access level in D has _everything_ to do with whether a function is 
virtual or not, because unlike C++, it provides no way to explicitly indicate 
virtual. In particular, private _must_ be non-virtual, or we have serious 
issues. Now, whether package in particular should be virtual or not is 
arguably arbitrary, but since the only reason to have virtual functions is 
inheritence, it _does_ make some sense that only public and protected 
functions would be virtual. You can go look for discussions on it in the main 
newsgroup though if you want to see Walter and Andrei's exact reasoning on the 
matter.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list