Function definition in multiple modules

Martin Drasar drasar at ics.muni.cz
Thu Mar 29 02:31:57 PDT 2012


On 29.3.2012 11:16, simendsjo wrote:
> 
> D has interface files, .di. These can be automatically generated by the
> compiler using the -H switch.
> 
> So you code your class normally:
> a.d:
> class A
> {
>     void a() {}
>     void b() {}
> }
> 
> $ dmd -H a.d
> $ cat a.di
> // D import file generated from 'a.d'
> class A
> {
>     void a()
> {
> }
>     void b()
> {
> }
> }

Hi,

I have probably not made myslef clear.

Let's say I have this D code:

interfaces.d:
interface IA
{
  void a();
}

interface IB
{
  void b();
}

myfunkyclass.d:
import interfaces;
class X : IA, IB
{
  void a()
  {
  }

  void b()
  {
  }
}

I would like to split the X class definition into two files. One file
would implement methods of interface IA and another of interface IB. So
it would be like this:

myfunkyclassIA.d:
class X : IA, IB
{
  void a()
  {
  }
}

myfunkyclassIB.d:
void b(X x)
{
}

Except using UFCS in this case does not work...

Martin


More information about the Digitalmars-d-learn mailing list