digitalmars.D.learn - Partial classes
- Mars (3/3) Jan 29 2012 Hello everybody.
- bearophile (4/6) Jan 29 2012 In D there are ways to compose classes, using static methods of interfac...
- Jonathan M Davis (4/6) Jan 29 2012 Not really, no. It's one file per module by design. However, you can use...
- bls (30/33) Jan 30 2012 As already said template mixins are close to partial classes.
- Mars (3/5) Jan 31 2012 Thanks everybody. I still hope support for partial classes may
- Jonathan M Davis (7/13) Jan 31 2012 Well, you can hope, but Walter is very much against the idea, so someone...
- bearophile (4/6) Jan 31 2012 Generally it's not wise to go too much against the style of a language. ...
- Mars (5/12) Jan 31 2012 "Need"? Nobody "needs" a feature that's basicly only cosmetic. In
Mars:Hello everybody.In D there are ways to compose classes, using static methods of interfaces, with "alias this", and even low-level ways like mixin(import("filename.d")), and so on. But currently there are no partial classes in D. Maybe partial classes will be added in future if their usefulness becomes evident :-) Bye, bearophile
Jan 29 2012
On Sunday, January 29, 2012 22:43:26 Mars wrote:Hello everybody.Not really, no. It's one file per module by design. However, you can use template and string mixins to add code from other files. - Jonathan M Davis
Jan 29 2012
On 01/29/2012 01:43 PM, Mars wrote:Hello everybody. MarsAs already said template mixins are close to partial classes. A snippet. HTH import std.stdio, std.cstream; void main(string[] args) { auto bar = new Bar(); writeln(bar.onClick()); // Lets the user press <Return> before program stops din.getc(); } mixin template FooMixin() { void initCommonControls() { } string onClick() { return "Clicked"; } } class Foo { mixin FooMixin; } class Bar : Foo { }
Jan 30 2012
On Monday, 30 January 2012 at 10:21:07 UTC, bls wrote:As already said template mixins are close to partial classes. A snippet. HTHThanks everybody. I still hope support for partial classes may come some day, to make this cleaner, but I guess it works.
Jan 31 2012
On Tuesday, January 31, 2012 11:37:24 Mars wrote:On Monday, 30 January 2012 at 10:21:07 UTC, bls wrote:Well, you can hope, but Walter is very much against the idea, so someone would have to have a very compelling argument to change his mind, and I don't expect that that will happen. The one file per module rule is viewed as too desirable to allow for something like partial classes where you're specifically splitting a module across files. - Jonathan M DavisAs already said template mixins are close to partial classes. A snippet. HTHThanks everybody. I still hope support for partial classes may come some day, to make this cleaner, but I guess it works.
Jan 31 2012
Mars:Thanks everybody. I still hope support for partial classes may come some day, to make this cleaner, but I guess it works.Generally it's not wise to go too much against the style of a language. What do you need partial classes for? Bye, bearophile
Jan 31 2012
On Tuesday, 31 January 2012 at 12:33:22 UTC, bearophile wrote:Mars:"Need"? Nobody "needs" a feature that's basicly only cosmetic. In some cases it makes the files cleaner, as you can split big classes into several files. I just like that^^ MarsThanks everybody. I still hope support for partial classes may come some day, to make this cleaner, but I guess it works.Generally it's not wise to go too much against the style of a language. What do you need partial classes for? Bye, bearophile
Jan 31 2012