View mode: basic / threaded / horizontal-split · Log in · Help
June 14, 2012
Re: Package and virtual functions
On 2012-06-14 00:48, Jonathan M Davis wrote:
> On Thursday, June 14, 2012 00:32:45 BLM768 wrote:
>> For some reason, whenever I declare a method with package
>> visibility, it becomes non-virtual. Is this normal behavior, or
>> is there a bug in DMD 2.059?
>
> Only public and protected functions can be virtual. private and package
> functions are never virtual. This is by design.
>
> - Jonathan M Davis

The docs say:

"All non-static non-private non-template member functions are virtual."

To me that says that methods marked with "package" are virtual. It's 
been like that in the documentation forever. So I don't know if "by 
design" is correct. I also know that package methods have never been 
virtual so I don't know what the actual design is.

This is a common, annoying, problem with D: What is correct when DMD, 
the documentation and TDPL all are different?

http://dlang.org/function.html#virtual-functions

-- 
/Jacob Carlborg
June 14, 2012
Re: Package and virtual functions
On Thursday, June 14, 2012 08:30:26 Jacob Carlborg wrote:
> On 2012-06-14 00:48, Jonathan M Davis wrote:
> > On Thursday, June 14, 2012 00:32:45 BLM768 wrote:
> >> For some reason, whenever I declare a method with package
> >> visibility, it becomes non-virtual. Is this normal behavior, or
> >> is there a bug in DMD 2.059?
> > 
> > Only public and protected functions can be virtual. private and package
> > functions are never virtual. This is by design.
> > 
> > - Jonathan M Davis
> 
> The docs say:
> 
> "All non-static non-private non-template member functions are virtual."
> 
> To me that says that methods marked with "package" are virtual. It's
> been like that in the documentation forever. So I don't know if "by
> design" is correct. I also know that package methods have never been
> virtual so I don't know what the actual design is.
> 
> This is a common, annoying, problem with D: What is correct when DMD,
> the documentation and TDPL all are different?
> 
> http://dlang.org/function.html#virtual-functions

I believe that Walter has stated that it's on purpose that package be non-
virtual. I know that Andrei thinks that, since he's said as much when the 
topic has come up. And from discussions on the matter, I believe that it's 
fairly clear that the current behavior is going to stay.

Regardless, the docs clearly need to be fixed.

- Jonathan M Davis
Next ›   Last »
1 2
Top | Discussion index | About this forum | D home