digitalmars.D - free method again, treat class as name space only
- davidl (19/19) Aug 07 2008 class A
- Lionello Lunesu (4/25) Aug 07 2008 What about a static function in a class? Isn't that basically "treating
- davidl (6/27) Aug 08 2008 That can't do what MI do.
- Ary Borenszweig (3/33) Aug 08 2008 Can you give a good example where the thing you want to do is useful? I
class A { void func(){ writefln("hello"); } } class B { void func(){ A.func(cast(A)cast(void*)this); } // sometimes people need this. } partial class is good, but it's likely to introduce a lot compiler bugs, and it's likely to increase the compile time. multiple inheritance is also nice, also likely to introduce compiler bugs, and multiple inheritance make the thing more obscure sometimes, while it needs to be clear. the solution I proposed is simple and compact. It can solve all what partial class & MI can solve. It won't much bring bad taste in syntax. -- 使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/
Aug 07 2008
davidl wrote:class A { void func(){ writefln("hello"); } } class B { void func(){ A.func(cast(A)cast(void*)this); } // sometimes people need this. } partial class is good, but it's likely to introduce a lot compiler bugs, and it's likely to increase the compile time. multiple inheritance is also nice, also likely to introduce compiler bugs, and multiple inheritance make the thing more obscure sometimes, while it needs to be clear. the solution I proposed is simple and compact. It can solve all what partial class & MI can solve. It won't much bring bad taste in syntax.What about a static function in a class? Isn't that basically "treating class as name space only"? L.
Aug 07 2008
在 Thu, 07 Aug 2008 21:35:41 +0800,Lionello Lunesu <lio lunesu.remove.com> 写道:davidl wrote:That can't do what MI do. While the way I proposed can. Because you send the `this` pointer in -- 使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/class A { void func(){ writefln("hello"); } } class B { void func(){ A.func(cast(A)cast(void*)this); } // sometimes people need this. } partial class is good, but it's likely to introduce a lot compiler bugs, and it's likely to increase the compile time. multiple inheritance is also nice, also likely to introduce compiler bugs, and multiple inheritance make the thing more obscure sometimes, while it needs to be clear. the solution I proposed is simple and compact. It can solve all what partial class & MI can solve. It won't much bring bad taste in syntax.What about a static function in a class? Isn't that basically "treating class as name space only"? L.
Aug 08 2008
davidl a écrit :在 Thu, 07 Aug 2008 21:35:41 +0800,Lionello Lunesu <lio lunesu.remove.com> 写道:Can you give a good example where the thing you want to do is useful? I see it as a hack into the OO system.davidl wrote:That can't do what MI do. While the way I proposed can. Because you send the `this` pointer inclass A { void func(){ writefln("hello"); } } class B { void func(){ A.func(cast(A)cast(void*)this); } // sometimes people need this. } partial class is good, but it's likely to introduce a lot compiler bugs, and it's likely to increase the compile time. multiple inheritance is also nice, also likely to introduce compiler bugs, and multiple inheritance make the thing more obscure sometimes, while it needs to be clear. the solution I proposed is simple and compact. It can solve all what partial class & MI can solve. It won't much bring bad taste in syntax.What about a static function in a class? Isn't that basically "treating class as name space only"? L.
Aug 08 2008