Partial classes
Max Samukha
maxsamukha at gmail.com
Mon Jun 25 14:07:27 PDT 2012
On Monday, 25 June 2012 at 20:31:18 UTC, Walter Bright wrote:
> On 6/25/2012 8:26 AM, 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?
>> 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.
>
> Are you talking about adding fields/functions to an arbitrary
> class without modifying the original definition of that class?
>
> If so, this would violate principles of encapsulation, and
> there'd be terrible consequences (as you could not rely on the
> class definition being the class definition without examining
> the entire code base).
>
> But, you can use UFCS to "add" member functions to an existing
> class.
>
> Adding data members can be done using the PIMPL technique,
> string mixins, or template mixins (but the original class needs
> to be designed for that).
He's talking about this:
http://msdn.microsoft.com/en-us/library/wa80x488(v=vs.80).aspx.
More information about the Digitalmars-d
mailing list