Clarification about compilation model and the mapping of package names to directory.

Bruno Medeiros via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 29 09:11:21 PDT 2016


On 29/04/2016 15:50, Dicebot wrote:
> On 04/29/2016 05:32 PM, Bruno Medeiros wrote:
>> Imagine you have a module "main.d" with the line `import xxx.foo;`, and
>> you have a file "foo.d" with the module declaration `module xxx.foo;`.
>> Now imagine the files are laid out like this:
>>
>> src/main.d
>> src/foo.d
>>
>> Is this valid, should these files compile? Currently DMD will fail if
>> each file is compiled individually (because it expects `xxx.foo` to be
>> in "src/xxx/foo.d", *but* it will succeed if all files are supplied to
>> DMD in the same command-line.
>
> AFAIK yes, this is valid and shall compile (and there are quite some
> projects relying on it). There is simply a missing feature for separate
> compilation case to allow supplying import module paths manually.
>

"supplying import module paths manually" ? How would that even work? 
Suppose you want to compile main.d separately. You'd need to supply to 
the compiler an option for each module with non-standard path, such as 
`xxx.foo=foo.d;xxx.bar=bar.d`, etc..

Sounds like a terrible idea. The tool invoking dmd would have to keep a 
cache of these mappings. More complexity and for what benefit? That 
there are projects relying on it says nothing of whether is a good idea.

The DDT semantic engine does not support this kind of layout. I wonder 
if DCD or Mono-D support this (I don't have them handy to try it out).

-- 
Bruno Medeiros
https://twitter.com/brunodomedeiros


More information about the Digitalmars-d mailing list