fn: :=
[contents]

Contents

Syntax

The syntax for := calls is:

f++:  
type definitions
type(definitions)
:=(type, definitions)

n++:  
@type definitions
@type(definitions)
@:=(type, definitions)

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

Description

The := function is used for defining 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 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.:

@:=(int, x=10)!

Options

The following options are available for := calls:

option description
const definition of a constant
!exprtk do not register variable with ExprTk
layer="x" define variable at layer x
mf add member functions for variables
!mf do not add member functions for variables
private definition of a private
scope+="x" add x to scopes variable can be accessed from
... parameters specify values for std::vector definition
option description

f++ example

Examples of := being used with f++:

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

n++ example

Examples of := being used with n++:

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