Interesting question. Actually pair of questions. On the first one, there's no known limit on the use of
++include'once. But since you're compiling with the
/igoo (Include Global Only Once) switch, you're effectively already using
++include'once everywhere. So I don't think removing your
++IFNDEF statements bracketing each include will make any difference.
As an aside, I've settled on the pattern of always using
++include'once (in fact, it's an APN shortcut triggered by "inc"), but I still add the
++IFNDEF directives inside most include files anyway -- partly out of habit, but also on the theory that it provides additional flexibility. For example, in cases where I may want to test multiple versions of a function, I can use the
/C:symbol=value compiler switch to explicitly DEFINE the symbol associated with a the relevant include file to prevent it from being processed even once.
But setting all of that to the side to address the second question about how much overhead there is in scanning a file during the first compiler pass (necessary to process the conditional directives), it's definitely "something", but probably not "a lot". I'm guessing that on average, the first pass is about 3-4 times faster than the second pass, since it only needs to pay attention to ++ directives, DEFINES, function/procedure declarations and calls, and now perhaps DEFSTRUCTs. And it doesn't actually have to 'compile' any of it. It's mainly just building the matrix of called functions so that we shake out those that aren't called, and can know in advance the named parameters for those that are. But perhaps I should add some timing statistics to the compiler output to actually measure that.
While on the subject of minor refinements/optimizations, I noticed that you tend to use LOOKUP as a way to conditionally include a file depending on whether it exists, e.g.
++IF (LOOKUP("in:invprchist.sdf") # 0)
++INCLUDE in:invprchist.sdf
++ENDIF
There's nothing wrong with that, and doesn't add more than a few extra picoseconds of overhead to parse the statement, but just from a syntax simplification perspective, my preference would be for:
++INCLUDE'IF'EXISTS in:invprchist.sdf
or
++INCLUDE'ONCE'IF'EXISTS in:invprchist.sdf
It just seems a little cleaner.