Partial classes

Timon Gehr timon.gehr at gmx.ch
Mon Jun 25 09:51:28 PDT 2012


On 06/25/2012 05:26 PM, Manu wrote:
> I suspect this isn't possible in a compiled language like D, but I
> wonder anyway, has anyone considered partial classes in D? Are they
> technically possible?
> How would they work? Would it depend on link-time code generation?

Ideally yes, but it should be possible to initialize the relevant data 
structures at program load time. (druntime is already able to locate 
class type infos by their fully qualified names, so it should be
feasible.)

> I can imagine an implementation where each 'part' occupies a separate
> allocation, and some pointer in Object or somewhere like that (somewhere
> near the typeinfo pointer) binds them together.
>
> I often find myself wanting to add some extra pizazz to classes using
> template/mixin magic, but I may not have control over the original code
> where it is defined...

How can you declare the class as partial if you do not have control
over the original code?

> C# at least can do this, and it's very useful in many situations...

I think the blocking issues are in the frontend: partial classes
as done in C# require the 'namespace' feature. D conflates modules and
name spaces.


More information about the Digitalmars-d mailing list