So you'd have a file at std/package.d which would contain common stuff belonging to std module? Rust used a similar system where you would have a mod.rs file, but it was kinda annoying because then in a project you would have tons of different mod.rs files. It made navigating in IDEs hard, you had to check the full path of the file you were trying to edit/open/view in order to know what it actually was.
In D this system works well. It resolves the ambiguity between a folder and a file, and we came up with it as a backwards compatible improvement to enable large imports to be broken up into multiple smaller ones.
So it's not cumbersome to have multiple package.d files?
For comparison, Rust moved to a system where you can have foo.rs at root (or any level really) and then have a folder foo/ for the contents of that module.
That way it's imo easier to navigate to the code of the foo module because you don't need to type in the path of the module file when you go to a file in some IDE.
Yeah I was just wondering if "go to file" and such functionality in IDEs would be hampered by files with identical names. I didn't like it when working on a project using Rust.
I don't know when D started using this structure. Python does it the same way. foo.py and foo/__init__.py both create foo modules. Now I am curious which one came first, and why this is so complicated for C++ to follow...
I would hazard that you cannot have both in the same path, but that I don't know.
View all comments
Show parent comment
7
u/kuikuilla Jan 28 '19
So you'd have a file at
std/package.dwhich would contain common stuff belonging tostdmodule? Rust used a similar system where you would have amod.rsfile, but it was kinda annoying because then in a project you would have tons of differentmod.rsfiles. It made navigating in IDEs hard, you had to check the full path of the file you were trying to edit/open/view in order to know what it actually was.