Previous: Pseudo-operators, Up: Pretty-printing [Contents][Index]
For special effects in the woven output, there are commands to help one change the appearance of operators and identifiers.
A feature common to both C++ and FORTRAN–90 is operator overloading, the ability to extend or redefine the definition of an operator such as ‘.FALSE.’ or ‘=’. FORTRAN–90 even allows one to define new dot operators—for example, one might define the operator ‘.IN.’ to test for inclusion in a set. In a nontrivial extension of the original design, FWEAVE allows one to define how overloaded operators should appear on output. Indeed, this feature can be used even when the compiler language itself does not permit overloading in order to customize the appearance of the woven output.
The ‘@v’ control code is used to change the appearance of an operator. The format is
@v new_operator_symbol_or_name "TeX material" old_operator
This means “Display the new operator according to the TeX material, but treat it like the old operator—e.g., unary or binary—for formatting purposes. The quoted TeX material is treated just like a C string, so if one wants to include a backslash one must escape it with another backslash. For example, one can make an equals sign display on output as a large left arrow by saying
@v = "\\Leftarrow" =
Two FORTRAN examples are
@v .FALSE. "\\.{.FALSE.}" .FALSE. @v .IN. "\\in" +
This feature can go a long way toward enhancing readability of the woven output, particularly when operators are actually being overloaded. It can also lead to arbitrarily bizarre output that no-one else will understand. As usual, restraint is advised.
Although operator overloading is quite useful, it does not allow one to change the appearance of identifiers. In its most general form, such a facility becomes quite complicated; one must endow FWEAVE with a macro-processing facility analogous to that of FTANGLE. This has not been done yet (maybe it will be someday). In the meantime, one has the command ‘@W’, which provides a restricted form of such a facility. This command is experimental, and not firmly established. Changes in usage and/or syntax may be made in future versions.
The most general form of the ‘@W’ command is
@W identifier "replacement text"
This means: Replace any references to identifier in the woven output with the replacement text.
A more restrictive form is
@W identifier \newmacro
which replaces references to identifier with a call to
\newmacro
. (Note that there are no quotes in this form.)
The shortest form is
@W identifier .
which replaces references to identifier with a call to
\identifier
. For example, the identifier x normally appears in
woven output as ‘\.{\Wshort\{x\}}’. If one says
@W x .
one will instead get the macro reference ‘\x’, which could be defined to give a variety of special effects. (However, one may need some rather intimate understanding of FWEAVE’s output in order to ensure that things always work correctly.)
One of the important uses of this facility is to expedite special formatting of array references. This subject is discussed separately below in the section on “Special array formatting” (sorry, that isn’t here yet), where an example is given.
Previous: Pseudo-operators, Up: Pretty-printing [Contents][Index]