circular deps

Manfred Nowak svv1999 at hotmail.com
Fri May 18 05:46:35 PDT 2007


Scott wrote

> Whats the correct way to use imports

The correct ways in the given case are at least

- to compile by `dmd mat3 main'
- to change the import declaration in "main.d" so that
  `mat3' is imported before `vec3'
- to change the position of the import declaration in "vec3.d" so
that it follows lexically the definition of type `Vec3' 

All these ways enable the compiler to destroy the cyclic importing
in the given case. 

But according to the specs the compiler is indeed buggy.
The specs say:
| The order in which ImportDeclarations occur has no significance.

With your slightly modified example the compiler continues to emit
errors if the import declaration `import vec3, mat3, quat;' is
changed to
import vec3;
import mat3;
import quat;

But the error vanishes on changing the order to
import mat3;
import vec3;
import quat;

This is the proof that the order indeed has a significance for the 
compiler.

-manfred



More information about the Digitalmars-d mailing list