On 18 March 2012 04:47, F i L <witte2...@gmail.com> wrote:

> I'm a bit confused. Reading through the virtual function's docs (
> http://dlang.org/function.**html#virtual-functions<http://dlang.org/function.html#virtual-functions>)
> it says:
>
> "All non-static non-private non-template member functions are virtual.
> This may sound inefficient, but since the D compiler knows all of the class
> hierarchy when generating code, all functions that are not overridden can
> be optimized to be non-virtual."
>
> So if all functions are automatically optimized to non-virtual where
> applicable, then the "final" keyword is for conceptual access limitation
> only. This makes a lot of sense to me. Is there something I'm not getting
> that makes you want an explicit "virtual" keyword?
>

It's not dependable. Virtually everything meets those criteria and will be
virtual, but I want to be confident that NOTHING is EVER virtual, unless I
absolutely say so.
D knows nothing about the class hierarchy when generating code, I don't
know how it can make that claim? Anything that's not private can be
extended by another module, and only the linker could ever know out about
that.
Aside from that, I want a compile error if someone tries to randomly
override stuff. virtuals are a heinous crime, and should only be used
explicitly. It should not be possible for someone to accidentally create a
virtual.

Reply via email to