Several constants are built into the MFL compiler. To discern them from user-defined ones, their names start and end with two underscores (‘__’).
The following constants are defined in mailfromd
version
9.0:
Expands to the name of the current source file.
Expands to the name of the current lexical context, i.e. the function or handler name.
This built-in constant is defined for alpha versions only. Its value is the Git tag of the recent commit corresponding to that version of the package. If the release contains some uncommitted changes, the value of the ‘__git__’ constant ends with the suffix ‘-dirty’.
Expands to the current line number in the input source file.
Expands to the major version number.
The following example uses __major__
constant to determine
if some version-dependent feature can be used:
if __major__ > 2
# Use some version-specific feature
fi
Expands to the minor version number.
Expands to the name of the current module (see Modules).
Expands to the package name (‘mailfromd’)
For alpha versions and maintenance releases expands to the version patch level. For stable versions, expands to ‘0’.
Expands to the default external preprocessor command line, if the preprocessor is used, or to an empty string if it is not, e.g.:
__defpreproc__ ⇒ "/usr/bin/m4 -s"
See Preprocessor, for information on preprocessor and its features.
Expands to the current external preprocessor command line, if the
preprocessor is used, or to an empty string if it is not. Notice,
that it equals __defpreproc__
, unless the preprocessor was
redefined using --preprocessor command line option
(see –preprocessor).
Expands to the textual representation of the program version (e.g. ‘3.0.90’)
Expands to the default state directory (see statedir).
Expands to the current value of the program state directory
(see statedir). Notice, that it is the same as
__defstatedir__
unless the state directory was redefined at run
time.
Built-in constants can be used as variables, this allows to expand them within strings or here-documents. The following example illustrates the common practice used for debugging configuration scripts:
func foo(number x) do echo "%__file__:%__line__: foo called with arg %x" … done
If the function foo
were called in line 28 of the
script file /etc/mailfromd.mfl
, like this:
foo(10)
, you will see the following string in your logs:
/etc/mailfromd.mfl:28: foo called with arg 10