Re: Partial classes

2012-01-31 Thread Mars

On Monday, 30 January 2012 at 10:21:07 UTC, bls wrote:

As already said template mixins are close to partial classes.
A snippet. HTH
Thanks everybody. I still hope support for partial classes may 
come some day, to make this cleaner, but I guess it works.


Re: Partial classes

2012-01-31 Thread Jonathan M Davis
On Tuesday, January 31, 2012 11:37:24 Mars wrote:
 On Monday, 30 January 2012 at 10:21:07 UTC, bls wrote:
  As already said template mixins are close to partial classes.
  A snippet. HTH
 
 Thanks everybody. I still hope support for partial classes may
 come some day, to make this cleaner, but I guess it works.

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 Davis


Re: Partial classes

2012-01-31 Thread bearophile
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


Re: Partial classes

2012-01-31 Thread Mars

On Tuesday, 31 January 2012 at 12:33:22 UTC, bearophile wrote:

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


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^^


Mars


Re: Partial classes

2012-01-30 Thread bls

On 01/29/2012 01:43 PM, Mars wrote:

Hello everybody.
Quick question, is there anything like C#'s partial classes in D?

Mars


As 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
{

}


Partial classes

2012-01-29 Thread Mars

Hello everybody.
Quick question, is there anything like C#'s partial classes in D?

Mars


Re: Partial classes

2012-01-29 Thread bearophile
Mars:

 Hello everybody.
 Quick question, is there anything like C#'s partial classes in D?

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


Re: Partial classes

2012-01-29 Thread Jonathan M Davis
On Sunday, January 29, 2012 22:43:26 Mars wrote:
 Hello everybody.
 Quick question, is there anything like C#'s partial classes in D?

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