FWEB offers a built-in preprocessor facility, especially useful for FORTRAN programmers. It is closely patterned after the C/C++ preprocessor, but with some extensions such as variable numbers of arguments. In addition, there are some built-in functions that provide functionality that cannot be emulated by user-defined macros.
When working with a language such as C that has its own preprocessor, the question arises when to use that and when to use FWEB’s facilities. The answer generally comes with experience. Remember that FWEB’s macros have been expanded by the time the tangled output file is produced, whereas language-specific preprocessor commands are just passed through to that file.
If you’re a FORTRAN programmer, strongly consider the use of FWEB’s macro facilities; they will simplify your present and future life by creating more legible codes and reducing programming errors by eliminating redundant pieces of code. C/C++ programmers may also appreciate the preprocessor extensions.
In addition to conventional macro processing, FWEB also offers the convenience of certain built-in functions that behave in many ways like macros. As a trivial example, the value of pithe built-in function ‘$PI’. Built-in functions are described in Built-in functions. They can be useful to programmers in all languages.
FWEB recognizes two kinds of macros: outer macros, and WEB macros (inner macros). Control codes associated with either of these kinds normally begin the definition part. However, FWEB macros are sometimes allowed in the code part as well; see FWEB macros.
Macros are expanded by FTANGLE only; FWEAVE merely prints them as they occur in the source file.
• Outer macros | Macros copied to beginning of output file (@d). | |
• FWEB macros | Macros and built-in functions expanded by FWEB (@m). | |
• Macros and formatting | How to format macros for pretty-printing. | |
• Preprocessing | FWEB’s preprocessing language (@#if, etc.) |