fn: const
[contents]

#### Syntax

The syntax for const calls is:

f++:
const type definitions
type{const}(definitions)
:={const}(type, definitions)


n++:
@const type definitions
@type{const}(definitions)
@:={const}(type, definitions)


Note: If you are using the first syntax for constant variable definitions and want to have more code and/or text following on the same line then simply end the definition with ';'.

#### Description

The const function is used for defining constant variables, the first parameter specifies the type of variables being defined, the remainder of the parameters should be variable definitions.

Note: If you need to define thousands of variables then := is faster, plus it has useful error messages for unrecognised types.

Note: Nift will skip to the first non-whitespace (ie. to the first character that is not a space, tab or newline) after a constant definition and inject it to the output file where the definition started. If you want to prevent Nift from doing this put a '!' after the definition, eg.:

@:={const}(int, x=10)!



#### Options

The following options are available for const calls:

option description
!exprtk do not register variable with ExprTk
layer="x" define variable at layer x
private definition of a private
scope+="x" add x to scopes variable can be accessed from
option description

#### f++ example

Examples of const being used with f++:

const int a=10, b=12; const double d=3.14
string{const}(str="hello, world!")
:=(ofstream, ofs("output.txt"))
write(ofs, a, " ", b, " ", d, endl)
write(ofs, str, endl)
ofs.close()

#### n++ example

Examples of const being used with n++:

@const int a=10, b=12; @const double d=3.14
@string{const}(str="hello, world!")
@:=(ofstream, ofs("output.txt"))
@write(ofs, a, " ", b, " ", d, endl)
@write(ofs, str, endl)
@ofs.close()