digitalmars.D.bugs - D Inheritance bug - test.d
- D Trebbien (28/28) Jan 07 2005 class A
- John Reimer (9/37) Jan 07 2005 This isn't a bug. This is the way D name resolution works. If you want...
- Thomas Kuehne (11/11) Jan 07 2005 -----BEGIN PGP SIGNED MESSAGE-----
- Thomas Kuehne (11/14) Jan 07 2005 Arg... shouldn't switch languages that often ...
- John Reimer (15/37) Jan 07 2005 I know the example looks like an error in method overloading, but
- Simon Buchan (14/51) Jan 07 2005 Hmm.... Not wanting to open a can of worms here, but I can see both side...
- David L. Davis (46/74) Jan 08 2005 D Trebbien : Below may be a way to do what you what without an alias.
- Simon Buchan (9/66) Jan 14 2005 /* added */ alias void super.test(int) void test(int); // Is this the
- David L. Davis (6/7) Jan 14 2005 Simon Buchan: :P Please, feel free to cough up better cure besides the a...
- D. Trebbien (3/93) Mar 10 2005 This is a great solution (and makes more sense to me in terms of OO
class A { void test(int val) { } } class B : A { void test() { } } int main(char[][] args) { B b=new B(); b.test(6); return 0; } (this code is attached for reference) test.d(18): function test () does not match argument types (int) test.d(18): Error: expected 0 arguments, not 1 begin 0644 test.d ` end
Jan 07 2005
D Trebbien wrote:class A { void test(int val) { } } class B : A { void test() { } } int main(char[][] args) { B b=new B(); b.test(6); return 0; } (this code is attached for reference) test.d(18): function test () does not match argument types (int) test.d(18): Error: expected 0 arguments, not 1This isn't a bug. This is the way D name resolution works. If you want to be able to use class A's test() from a B object, you'll have to define an alias to it that brings it into B's namespace. You might like to do a search of this newsgroup for a more detailed explanation of why D does name resolution this way. A fair bit of discussion about this has already taken place. Later, John
Jan 07 2005
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Added to DStress as: http://dstress.kuehne.cn/run/run/overload_12.d http://dstress.kuehne.cn/run/run/overload_13.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFB3wDh3w+/yD4P9tIRAnxdAJ40vwfHWMHBhN/csXXqMUlcPd1TggCgkknb zgVBfFPug071TTrk5SlLY8c= =6HHY -----END PGP SIGNATURE-----
Jan 07 2005
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1Added to DStress as: http://dstress.kuehne.cn/run/run/overload_12.d http://dstress.kuehne.cn/run/run/overload_13.dArg... shouldn't switch languages that often ... http://dstress.kuehne.cn/nocompile/overload_12.d http://dstress.kuehne.cn/nocompile/overload_13.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFB3wPW3w+/yD4P9tIRAp6GAJ9mtlp4QwXfJ4q+G0kbL8GDhazNqACgyXUc Bx3GLWkPGMkgr68d2HlOFn0= =mipW -----END PGP SIGNATURE-----
Jan 07 2005
Thomas Kuehne wrote:-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1I know the example looks like an error in method overloading, but doesn't overloading specifically refer to use of methods with the same name (with different parameters) within the same class. D doesn't automatically bring superclass methods of the same name into the subclass's name space (or whatever you call it) by design. Since this is part of D's design, this is not a issue of incorrect overloading (though, I'm sure, some people wish it were). I remember this D "feature" being haggled over in detail. Some OOP programmer's found the D mechanism distasteful, especially those that came from a Java background. But, I believe Walter has indicated ferverently that this is the way D was designed and the only sane way for the language to work. Correct me if I'm wrong. Later, JohnAdded to DStress as: http://dstress.kuehne.cn/run/run/overload_12.d http://dstress.kuehne.cn/run/run/overload_13.dArg... shouldn't switch languages that often ... http://dstress.kuehne.cn/nocompile/overload_12.d http://dstress.kuehne.cn/nocompile/overload_13.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFB3wPW3w+/yD4P9tIRAp6GAJ9mtlp4QwXfJ4q+G0kbL8GDhazNqACgyXUc Bx3GLWkPGMkgr68d2HlOFn0= =mipW -----END PGP SIGNATURE-----
Jan 07 2005
On Fri, 07 Jan 2005 16:20:03 -0800, John Reimer <brk_6502 yahoo.com> wrote:Thomas Kuehne wrote:Hmm.... Not wanting to open a can of worms here, but I can see both sides of this, clear and clean syntax, or in-your-face lists of all overloaded fuctions, so you KNOW what could be called. However, with no implicit casting of classes, and the fact that non-overloaded functions are still brought in, I would have to go with not requiring aliasing. Huge volumes of aliases for overloading probably means you're doing something wrong, in any case. Could this just be the default private access? I think that probably was just cut for space. -- "Yes, the american troops have advanced further. This will only make it easier for us to defeat them" - Iraqi Information Minister Muhammed Saeed al-Sahaf-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1I know the example looks like an error in method overloading, but doesn't overloading specifically refer to use of methods with the same name (with different parameters) within the same class. D doesn't automatically bring superclass methods of the same name into the subclass's name space (or whatever you call it) by design. Since this is part of D's design, this is not a issue of incorrect overloading (though, I'm sure, some people wish it were). I remember this D "feature" being haggled over in detail. Some OOP programmer's found the D mechanism distasteful, especially those that came from a Java background. But, I believe Walter has indicated ferverently that this is the way D was designed and the only sane way for the language to work. Correct me if I'm wrong. Later, JohnAdded to DStress as: http://dstress.kuehne.cn/run/run/overload_12.d http://dstress.kuehne.cn/run/run/overload_13.dArg... shouldn't switch languages that often ... http://dstress.kuehne.cn/nocompile/overload_12.d http://dstress.kuehne.cn/nocompile/overload_13.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFB3wPW3w+/yD4P9tIRAp6GAJ9mtlp4QwXfJ4q+G0kbL8GDhazNqACgyXUc Bx3GLWkPGMkgr68d2HlOFn0= =mipW -----END PGP SIGNATURE-----
Jan 07 2005
In article <crmrb6$2slf$1 digitaldaemon.com>, D Trebbien says...class A { void test(int val) { } } class B : A { void test() { } } int main(char[][] args) { B b=new B(); b.test(6); return 0; } (this code is attached for reference) test.d(18): function test () does not match argument types (int) test.d(18): Error: expected 0 arguments, not 1 begin 0644 test.d ` endD Trebbien : Below may be a way to do what you what without an alias. Output: C:\dmd>bin\dmd class_inhert2.d C:\dmd\bin\..\..\dm\bin\link.exe class_inhert2,,,user32+kernel32/noi; C:\dmd>class_inhert2 A.test( in int iVal="6" ) Called. B.test() Called. C:\dmd> David L. ------------------------------------------------------------------- "Dare to reach for the Stars...Dare to Dream, Build, and Achieve!"
Jan 08 2005
On Sun, 9 Jan 2005 01:47:42 +0000 (UTC), David L. Davis <SpottedTiger yahoo.com> wrote:In article <crmrb6$2slf$1 digitaldaemon.com>, D Trebbien says.../* added */ alias void super.test(int) void test(int); // Is this the syntax?class A { void test(int val) { } } class B : A {<snip>void test() { } } int main(char[][] args) { B b=new B(); b.test(6); return 0; }<snip> The cure is worse than the disease... -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Jan 14 2005
In article <opskk2ado1stcuho simon>, Simon Buchan says...The cure is worse than the disease...Simon Buchan: :P Please, feel free to cough up better cure besides the alias approach, which of course adds it's very own set of problems. Thus far, you haven't added anything positive to this topic...maybe it's time you did. :)) ------------------------------------------------------------------- "Dare to reach for the Stars...Dare to Dream, Build, and Achieve!"
Jan 14 2005
David L. Davis wrote:In article <crmrb6$2slf$1 digitaldaemon.com>, D Trebbien says...This is a great solution (and makes more sense to me in terms of OO design). Thanks David L.class A { void test(int val) { } } class B : A { void test() { } } int main(char[][] args) { B b=new B(); b.test(6); return 0; } (this code is attached for reference) test.d(18): function test () does not match argument types (int) test.d(18): Error: expected 0 arguments, not 1 begin 0644 test.d ` endD Trebbien : Below may be a way to do what you what without an alias. Output: C:\dmd>bin\dmd class_inhert2.d C:\dmd\bin\..\..\dm\bin\link.exe class_inhert2,,,user32+kernel32/noi; C:\dmd>class_inhert2 A.test( in int iVal="6" ) Called. B.test() Called. C:\dmd> David L. ------------------------------------------------------------------- "Dare to reach for the Stars...Dare to Dream, Build, and Achieve!"
Mar 10 2005