Next: , Previous: , Up: gtroff Reference   [Contents][Index]


5.4 Identifiers

Like any other language, gtroff has rules for properly formed identifiers. In gtroff, an identifier can be made up of almost any printable character, with the exception of the following characters:

For example, any of the following is valid.

br
PP
(l
end-list
@_

Note that identifiers longer than two characters with a closing bracket (‘]’) in its name can’t be accessed with escape sequences that expect an identifier as a parameter. For example, ‘\[foo]]’ accesses the glyph ‘foo’, followed by ‘]’, whereas ‘\C'foo]'’ really asks for glyph ‘foo]’.

To avoid problems with the refer preprocessor, macro names should not start with ‘[’ or ‘]’. Due to backwards compatibility, everything after ‘.[’ and ‘.]’ is handled as a special argument to refer. For example, ‘.[foo’ makes refer to start a reference, using ‘foo’ as a parameter.

Escape: \A'ident'

Test whether an identifier ident is valid in gtroff. It expands to the character 1 or 0 according to whether its argument (usually delimited by quotes) is or is not acceptable as the name of a string, macro, diversion, number register, environment, or font. It returns 0 if no argument is given. This is useful for looking up user input in some sort of associative table.

\A'end-list'
    ⇒ 1

See Escapes, for details on parameter delimiting characters.

Identifiers in gtroff can be any length, but, in some contexts, gtroff needs to be told where identifiers end and text begins (and in different ways depending on their length):

Unlike many other programming languages, undefined identifiers are silently ignored or expanded to nothing. When gtroff finds an undefined identifier, it emits a warning, doing the following:

See Warnings., Interpolating Registers, and Strings.

Note that macros, strings, and diversions share the same name space.

.de xxx
.  nop foo
..
.
.di xxx
bar
.br
.di
.
.xxx
    ⇒ bar

As can be seen in the previous example, gtroff reuses the identifier ‘xxx’, changing it from a macro to a diversion. No warning is emitted! The contents of the first macro definition is lost.

See Interpolating Registers, and Strings.


Next: , Previous: , Up: gtroff Reference   [Contents][Index]