Proposition for change in D regarding Inheriting overloaded methods
Christopher Wright
dhasenan at gmail.com
Thu Aug 9 05:01:42 PDT 2007
Steven Schveighoffer wrote:
> If there is a class A, which is a base class of class B, where A defines a
> method foo(args), and B does not define foo(args), then the compiler should
> fail to compile B indicating that the user must define B.foo(args) by
> override or by alias.
And if you don't want to provide access to those overloads? If, for
instance, the new overload computes something that was previously passed
in as an argument, but due to your changes, you cannot compute that
argument. With your solution, I'd have to override that method and have
it throw an exception. And put it in the docs that the method shouldn't
be used.
How about having a strong and weak override? A strong override hides all
overloads of the function it overrides, while a weak one hides only the
overload that matches it. Then it's unambiguous, and only a matter of
defining syntax. After all, Walter doesn't implicitly know whether each
individual programmer wants to allow inherited overloads to work, and
neither does dmd, unless they're explicitly told.
More information about the Digitalmars-d
mailing list