To stop a forward-reference problem you need to declare the type, but not implement it. Eg:

$ cat vector.d #-----------------------------------------------------
> module vector;
>
> class Vector(E) {
>   E[] data;
> }
>
> $ cat student.d #-----------------------------------------------------
> module student;
>
> import vector;

class Teacher;

> // define Student
> class Student {
>   void ask(Teacher teacher) {
>   }
> }
>
> // define Students
> alias Vector!(Student) Students;
>
> $ cat teacher.d #-----------------------------------------------------
> module teacher;
>
> import student;
>
> class Teacher {
>   Students students;
> }

It is not necessary to smash them all into one file.

Reply via email to