Implicit const
Craig Black
craigblack2 at cox.net
Thu Apr 3 17:06:55 PDT 2008
"Frits van Bommel" <fvbommel at REMwOVExCAPSs.nl> wrote in message
news:ft3ndl$2eqg$1 at digitalmars.com...
> Craig Black wrote:
>> Just don't issue the warning if the function is overriden. The compiler
>> could be smart enough to do that.
>
> The compiler only looks at the files needed to compile the current module,
> i.e. all modules imported from it (directly or indirectly).
> So if a method is only overridden in files not imported from the one
> containing the base class, it has no way of knowing about it...
>
> For example:
> ----
> module a;
>
> class B {
> int foo() { return 42; }
> }
> ----
> module b;
>
> import a;
>
> class D : B {
> private int foo_value;
> int foo() { return foo_value; }
> }
> ----
> While compiling module 'a' above, the compiler doesn't look at module 'b',
> so it won't know about D overriding foo(). Or even that class D exists,
> for that matter.
Right. The D compiler has no way of knowing what functions are virtual
bases. But that's actually irrelevant. Virtual bases aren't the problem.
It's the override functions that need immunity from this error. I guess
what I should have said is:
Just don't issue the warning if the function is overriding another function.
The compiler could be smart enough to do that.
-Craig
More information about the Digitalmars-d
mailing list