It makes me sick!

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Aug 1 07:29:28 PDT 2017


On Tuesday, 1 August 2017 at 14:20:00 UTC, Steven Schveighoffer 
wrote:
>> But the fix here is to fix the bizarre package.d design. Don't 
>> break the zip for cases like mine where adding files is a key 
>> feature of it.
>
> How should it be fixed?

Well, my preference would be to treat it just like any other 
module: the compiler has a search path, but if it opens a file, 
the module name is definitive.

So we can keep the search path: `datetime.di`, then `datetime.d`, 
then `datetime/package.d`, and any one of them, as long as it has 
`module std.datetime;` at the top, can count equally as the 
package.d.

BTW I kinda want to put `datetime/package.d` first on the search 
path, but I fear that'd hurt the speed of the normal case (every 
import would mean 2 file not found queries until it actually 
finds the common `file.d`)... but it might be worth investigating 
if we do want to prefer it.


Anyway, if package.d is just like any other module, if we want to 
break up a module, then you can keep the existing file, with the 
existing module declaration, and just start moving stuff out. You 
wouldn't have to literally create a package.d file, you can just 
keep using your existing module.d file.


More information about the Digitalmars-d-learn mailing list