Download FWEB manual - (La)TeX Navigator
Transcript
— OVERLOADING OPERATORS —
61
♣ 8.2 OVERLOADING IDENTIFIERS
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
One can change the printed
quite complicated; one must endow FWEAVE with a macroprocessing facility analogous to that of FTANGLE. This has
appearance of an identifier
not been done yet (probably it will be someday). In the
with the ‘@W’ command.
meantime, one has the command ‘@W, which provides a restricted form of such a facility. This command, new with version 1.30, 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.
It should now be clear how the previous “call integrate ” example was formatted. One simply said
@n
@
@W alpha .
@W beta .
@W fM "f_\\rm M"
@a
call integrate(x,alpha,beta,fM)
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,” where an example is
given.
9. RATFOR
Closely related to macro preprocessing is the notion of statement translation. In statement translation,
FWEB recognizes a special keyword or construction that is not part of the source language, and automatically
translates that construction into valid compilable code. It is a more general operation than macro expansion,
although it reduces to that in the simplest cases.