Next: Protection, Previous: Built-in functions, Up: Built-in functions [Contents][Index]
Several of the built-in functions expect or return a string argument.
Examples include $STRING (see $STRING), $UNQUOTE
(see $UNQUOTE), and $UNSTRING (see $UNSTRING). 
In understanding the operation of those functions, it is important to
understand just what a string means in the FWEB context.  As usual,
it is a vector of characters.  However, those need not be
delimited by quotes, although they may be.  Internally, a string is
represented by the construction sqc...cqs, where s is a special
string delimiter never seen by the user, q is an optional quote
character (either single or double quote depending on the language), and
c is an ordinary character.  Whether or not the quotes are present,
the string delimiters inhibit macro expansion.
The difference between $UNQUOTE and $UNSTRING can now be
stated as follows.  Given a quoted string such as "abc" (in C),
abc (and therefore is not very useful).
$UNSTRING is primarily used internally.  
The built-ins $P (see $P) and $PP (see $PP), which
both generate the preprocessor character ‘#’, provide a good
illustration of the differences between $UNQUOTE and
$UNSTRING.  Consider FORTRAN as an example.  Essentially,
$P is defined as ‘$UNQUOTE('#')’, which is internally
s#s.  When this single-character string is sent to the output, it is
treated like any other expression and therefore would appear in column 7
or greater even if the construction appeared at the very beginning of
the line.  On the other hand, $PP is (essentially) defined as
‘$UNSTRING('#')’, which is internally the single character #.
Because this character is not a string, the FORTRAN output driver
treats it as a special control character, defined in this case to force
the character into the first column.
Next: Protection, Previous: Built-in functions, Up: Built-in functions [Contents][Index]