[Issue 7259] New: Explicit annotation for method hiding
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jan 9 12:50:55 PST 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7259
Summary: Explicit annotation for method hiding
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at eml.cc 2012-01-09 12:50:54 PST ---
I'd like to see D care more about this, method hiding:
class Foo {
string name = "c1";
static void foo() {}
}
class Bar : Foo {
string name = "c2";
static void foo() {} // silent method hiding
}
void main() {}
In such situations I'd like D to require the use of a "new" keyword as C# does
(as with 'override', it first becomes a warning):
class Foo {
string name = "c1";
static void foo() {}
}
class Bar : Foo {
string name = "c2";
static new void foo() {} // method hiding is now visible
}
void main() {}
The point here is to make the purpose and meaning of the code more explicit.
---------------------
See also an answer by Jesse Phillips:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=154448
>> Override usage is going to be (hopefully soon) compulsory in D
>> (currently you need -w to see an error). So that code without
>> both static and override is going to be refused :-)
>
> I guess the question I was getting at, currently there is no way
> to "hide" a non-static member function like you would do in C#
> with 'new.' Is that intended once 'override' is required? and if
> not why have 'new' usable for static methods?
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list