Why? Isnt enough if you mix markdown with code? What are other tools for LP?
<<game-loop>> ==
while (!dead) {
<<get-input>>
<<update-world>>
<<display-world>>
}
And way down at the end of the program you can do this: <<main.c>> ==
<<includes>>
<<globals>> // if appropriate
int main() {
<<initialize-game>>
<<game-loop>>
return 0;
}
Throw that in an appendix or something because it's such blindingly obvious code (for C) that you don't need to dwell on it. It's not critical to the discussion contained in the rest of the text unless you're also providing a tutorial on C programming.And, you can (like I said, text macro-ish) reuse blocks of code in multiple places. Maybe you have some common header files, you could write this:
In order to have access to OpenGL capabilities, many of the .c files
will require this header block:
<<OpenGL-includes>> ==
#include<GL.h>
...
And now when you want to include them, you just reference this. Of course, in C you could just create a common.h file or something and tuck the includes into that, but not every language has text inclusion of that same sort. If, for instance, you were writing Java or C# or something you could use the above modified to call whatever appropriate package imports were needed. Then update it in one place and all of them get updated.