Closed jonicho closed 3 years ago
This is good! I was thinking more of solving this issue with a #once
directive, which is declared by the included file itself (not by the files which include them). When you declare #once
in a file, the assembler will ignore duplicate inclusions of that file as a whole. Would this be more ergonomic?
In the future, it'd be nice if certain directives would automatically not be re-run, if a file is included more than once. For example, I think #ruledef
blocks are currently idempotent, so the assembler could just ignore duplicate inclusions, and we wouldn't need any kind of include guard.
Yes, i think a #once directive in the included file would be even better! If you implement that, maybe it should only be allowed in the first line of a file so you can see whether a file can be included only once at a glance.
I would like to propose an #include_once directive, which would work like the #include directive, but only including a file if it has not already been included.
This would for example be useful for library files which themselves may include other library files resulting in the same file included more than once and causing multiple-definition-errors.
This is related to #27, with which you could achive this by using include-guards, but I think an #include_once directive would be more elegant and maybe also easier to implement.