Thread overview
Re: package access specifier not usable within a class
Sep 09, 2011
Jonathan M Davis
Sep 09, 2011
Jonathan M Davis
Sep 09, 2011
Andrej Mitrovic
September 09, 2011
On Friday, September 09, 2011 03:05:05 Andrej Mitrovic wrote:
> abstract class Foo
> {
>     package void test();
> }
> 
> class Bar : Foo
> {
>     override package void test() { }
> }
> 
> function test.Bar.test cannot override a non-virtual function
> 
> TDPL says package can only be used at class-level (i.e. package class Bar : Foo), outside classes or inside a struct.
> 
> I want to hide a virtual method from client code, but another free function in a different module but in the same package as these classes needs access to that method. Are there any technical reasons why package is not allowed for virtual methods?

Neither private nor protected functions are ever virtual at this point, though it is likely that that will be changed to match TDPL. There are a number of bugs on the matter. Among them are

http://d.puremagic.com/issues/show_bug.cgi?id=4542 http://d.puremagic.com/issues/show_bug.cgi?id=3581 http://d.puremagic.com/issues/show_bug.cgi?id=3258

- Jonathan M Davis
September 09, 2011
Thanks. I'll refactor my code to eliminate the need for package in this case. I was going to use it as a quick workaround anyway. :)
September 09, 2011
On Thu, 08 Sep 2011 21:23:00 -0400, Jonathan M Davis <jmdavisProg@gmx.com> wrote:

> Neither private nor protected functions are ever virtual at this point,

Jonathan meant to say neither private nor *package* functions.

protected functions are virtual.

-Steve
September 09, 2011
On Friday, September 09, 2011 07:15:09 Steven Schveighoffer wrote:
> On Thu, 08 Sep 2011 21:23:00 -0400, Jonathan M Davis <jmdavisProg@gmx.com>
> 
> wrote:
> > Neither private nor protected functions are ever virtual at this point,
> 
> Jonathan meant to say neither private nor *package* functions.
> 
> protected functions are virtual.

LOL. Ouch. Thanks for the correction. Yes private and package are not virual. Protected definitely is. It would be pretty useless otherwise.

- Jonathan M Davis