Simplify support for alternate bases using int(..., base=0) which
auto-detects it using the standard Python syntax for numbers.
Octal numbers are useful to specify permission bits and umasks.
Binary numbers are not super useful... But considering we get them for
free, let's allow them here too.
v2: Tweak the regex so it doesn't accept a decimal number with a leading
zero, which is invalid for int(..., base=0) and would raise a ValueError
if passed around.
Having support for the '%' operator makes it easier to implement
even/odd version checks, like:
enable_debug = get_option('enable-debug')
if enable_debug == 'auto'
if minor_version % 2 == 0
enable_debug = 'minimum'
else
enable_debug = 'yes'
endif
endif
which would be impossible without resorting to less obvious long-hand
forms like:
a - (b * (a / b))
bool to_int() will return 0 or 1, useful if one wants to set
a define to 0 or 1 based on a boolean result instead of having
it just defined or undefined.
bool to_string() will return 'true' or 'false' by default same
as when using it to format a string, but with the additional
possibility to specify two extra string arguments to be returned
as true/false values, e.g. to_string('yes', 'no'). This can be
useful when outputting messages to be shown to the user.
Addition (+), subtraction (-), multiplication (*) and division (/) for numbers
follows the BIDMAS rules.
Strings and arrays can be concatenated with the addition operator
Strings can be concatenated with numbers with the addition operator