Built-in functions behave in most ways like macros. In some cases they actually are macros, but other times they implement functions that a user could not define. They all begin with a dollar sign and are in upper case.
In using these built-ins, confusion may arise regarding the order of
expansion of various arguments. When they are implemented as macros,
they are subject to the same ANSI-C preprocessor rules as other
FWEB macros, which is that all arguments are fully expanded before
generating the replacement text of the macro. When they are directly
implemented as a primitive function, however, that rule may not apply.
For example, $IF
expands only its first argument during its first
pass of processing; depending on the results of that expansion, it then
expands either its second or third argument, but not both.
The built-in function $DUMPDEF
can be used to understand and
debug the action of the built-in functions. See $DUMPDEF
: Dump macro definitions to the terminal.
In the original FWEB design, built-in functions began with an underscore. This usage conflicts with the conventions for reserved words in ANSI C, and has been eliminated. All FWEB built-ins now begin with a dollar sign.
No user-defined macro should begin with a dollar sign! It might interfere with the functioning of some internal built-in function.
$A
: Convert to ASCII$ABS
: Absolute value$ASSERT
: Assert a condition$AUTHOR
: Value of RCS global keyword Author
$COMMENT
: Generate a comment$DATE
: Today’s date$DATE_TIME
: Value of RCS global keyword Date
$DAY
: The day$DECR
: Decrement a macro$DEFINE
: Deferred macro definition$DO
: Macro do loop$DUMPDEF
: Dump macro definitions to the terminal$E
: Base of the natural logarithms$ERROR
: Send error message to output$EVAL
: Evaluate a macro expression$EXP
: Exponential function$GETENV
: Get value of environment variable$HEADER
: Value of RCS global keyword Header
$HOME
: The user’s home directory$ID
: Value of RCS global keyword Id
$IF
: Two-way conditional$IFCASE
: n-way conditional$IFDEF
: Two-way conditional$IFNDEF
: Two-way conditional$IFELSE
: Two-way conditional$INCR
: Increment a macro$INPUT_LINE
: Line number that begins current section$KEYWORD
: Value of global RCS-like keyword$L
: Change to lower case$L_KEYWORD
: Value of local RCS-like keyword$LANGUAGE
: Identifier for current language$LANGUAGE_NUM
: Number of current language$LEN
: Length of string$LOCKER
: Value of RCS global keyword Locker
$LOG
: Natural logarithm$LOG10
: Logarithm to the base 10$M
: Define a deferred macro$MAX
: Maximum of a list$MIN
: Minimum$MODULE_NAME
: Name of present web
module$MODULES
: Total number of independent modules$NAME
: Value of RCS global keyword Name
$OUTPUT_LINE
: Current line number of tangled output$P
: The C preprocessor symbol$PI
: Pi$POW
: Exponentiation$PP
: The C preprocessor symbol$RCSFILE
: Value of RCS global keyword $RCSfile
$REVISION
: Value of RCS global keyword Revision
$ROUTINE
: Current function (RATFOR only)$SECTION_NUM
: Number of current FWEB section$SECTIONS
: Maximum section number$SOURCE
: Value of RCS global keyword Source
$SQRT
: Square root$STATE
: Value of RCS global keyword State
$STRING
: Expand, then stringize$STUB
: Trap for missing module$TIME
: The time$TRANSLIT
: Transliteration$U
: Change to upper case$UNDEF
: Undefine a macro$UNQUOTE
: Remove quotes from string$UNSTRING
: Convert string into characters$VERBATIM
: (Obsolete)$VERSION
: Present FWEB version number