attribute bug?

goofwin artem.3a at gmail.com
Fri Nov 9 23:28:00 PST 2012


On Saturday, 10 November 2012 at 05:34:32 UTC, Jonathan M Davis 
wrote:
>> ...
>
> The language is more complicated if you can explicitly choose 
> whether a
> particular function is virtual or not. It also causes a number 
> of bugs. C++
> has issues with it all the time. It certainly _can_ be done, 
> but the language
> designers chose to go the Java route of making virtuality 
> implicit. On the
> whole, it's exactly what you want.
>
> Generally, public functions need to be virtual. If they don't, 
> you can mark
> them as final. And it makes no sense for a protected function 
> to be non-
> virtual. So, both of them are virtual.

I think that it is unsuccessful decision by the language 
designers, because object oriented code use virtual functions not 
much in most cases, thence it is useless and bad for performance 
or it causes developer to set public and protected functions as 
final explicitly very much.

> It doesn't really make sense for private functions to be 
> virtual. If you want
> them to be virtual, just use protected. And if private were 
> virtual, then that
> would really hurt performance, and everyone would be forced to 
> mark all of
> their private functions as final to avoid it. So, it just makes 
> more sense to
> make them non-virtual.
>
> package is more debatable, and some people have argued that it 
> should be
> virtual, but Walter Bright and Andrei Alexandrescu don't think 
> that it really
> makes sense to. I'd have to go digging through the archives for 
> the main
> newsgroup though to find a post where they discuss it to tell 
> you exactly what
> they said.
>
> - Jonathan M Davis

I agree with everything that you say about private functions and 
i agree with people who have argued that package functions should 
can be virtual.=)

Thanks for help and interesting discussion.

PS: Sorry for my bad English.


More information about the Digitalmars-d-learn mailing list