Does anyone think C#'s partial would have any use in D?

Dukc ajieskola at gmail.com
Sun Dec 19 09:35:16 UTC 2021


On Sunday, 19 December 2021 at 06:30:08 UTC, Rumbu wrote:
>
> I suppose you wanted to say that D will benefit from it.
>
> It was already discussed in the past, you can search the forum 
> for it. The conclusion was that metaprogramming capabilities of 
> D are enough to not mandate the use of partial classes.

This, plus we have less need for that concept than C# does, 
because we can place functions on module scope. In C# classes are 
often used as namespaces for functions that are not conceptually 
member functions of anything, and in that case a partial class 
can make sense.

In D, if you have such a large class that it wants more than one 
file, that is a code smell. Move some of the (non-overridable) 
member functions out of it, or split it to smaller classes and/or 
structs.


More information about the Digitalmars-d mailing list