On Friday, December 7, 2018 2:42:33 PM MST Samir via Digitalmars-d-learn wrote: > Ok. Upon further investigation, I think I see what is going on. > Most of the repos I am skimming are for this year's Advent of > Code. They structure their repo with an `app.d` file which does > contain a `main` function but this program is structured such > that it imports the files I was looking at earlier (which do not > have a `main` function). > > Looks like I have to get smarter on how modules, mixins and > imports work.
There's one main per program, not per module. Where main lives depends on how the program was written, but dub encourages putting it in app.d, because that's what it generates when you create a new dub project. imports then provide access to other modules so that the code doing the importing can use it. You can think of it like the module with main being the start of the import tree, though it's a bit more complicated than that in practice, since modules can be compiled separately, and main only has to be there when the program is finally linked. But in concept, you have main and the module its in importing other modules, which then import other modules, etc. until you get all of the code in the program. - Jonathan M Davis