fn: private
[contents]

Contents

Syntax

The syntax for private calls is:

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

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

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

Description

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

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

Options

The following options are available for private calls:

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

f++ example

Examples of private being used with f++:

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

n++ example

Examples of private being used with n++:

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