shouldn't override be obligatory?

div0 div0 at users.sourceforge.net
Mon Mar 15 14:59:11 PDT 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jonathan M Davis wrote:
> div0 wrote:
> 
>> Strangely it doesn't give an error if A is an interface though.
> 
> Interfaces aren't overridden; they're implemented. You're providing 
> functionality, not replacing it. By marking a function with override, you're 
> clearly marking that it's polymorphic and intended to be so. If you force 
> override for all cases when a function is overridden, then you avoid issues 
> where you unknowingly override a function, changing the objects behavior. 
> That's not a problem with interfaces since there's no behavior to change. 
> The problem with interfaces is when you don't implement them completely, and 
> they complain plenty when that happens.
> 
> - Jonathan M Davis

True, but using override clearly documents what you doing in that class.
Otherwise you have to arse about looking through the interfaces to see
if an unmarked function is an implementation, which is the same end
result as unmarked overrides.

I vote for requiring override in all cases; I think it makes things
clearer. YMMV.

- --
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFLnq2vT9LetA9XoXwRApt6AJ90pOplStRil47vz86z21kqw3r/xgCbB/VW
aKiRACV/f3Y3fwHevLD8omo=
=xClh
-----END PGP SIGNATURE-----



More information about the Digitalmars-d mailing list