Why doesn't this "include-guard-ish" code evaluate in the correct order?

C++ compiler vendors are still struggling to implement C++20 modules in 2023, and here you are in Julia, trying to use includes instead.

I strongly suggest putting this code into modules.
You can then using the module as many times as you’d like; the header-guards are built in.
The module will also be precompilable.

To put these in a load path, I’d put them in a package and ] dev it. Creating packages is easy with:

You could create one package for each of common, constants, etc. Or one package with multiple modules, if that’s what you’d prefer.

Either way, I’d definitely use modules instead of trying to use header guards. That’s why we have them, and why languages like C++ are trying to transition to them.

EDIT:
I also avoid the PktTemplates wizard, because it is nice to be able to just hit up in the search history and get a generic template. E.g., typing t = PkgT and hitting up, I get:

t = PkgTemplates.Template(user="chriselrod",plugins=[Git(ignore=["*#*", "*~", "*#*#"],branch="main",ssh=true),CompatHelper(),GitHubActions(),Codecov(),Documenter{GitHubActions}()]);
PkgTemplates.generate(t, "MyNewPkgName") # PkgT [up]

Most people will probably want to use a different user=.

So creating a new package only takes me a few seconds. The skeleton is all there, so all that’s left is deving it and filling out the code.

6 Likes