fn: function
[contents]

Contents

Syntax

The syntax for function definitions is:

f++:  
function{options}(name)
{
	//function code
}

n++:  
@function{options}(name)
{
	//function code
}

Description

The function function is for user-defined functions, it takes a single parameter specifying a function name and is followed by a block of code to be run whenever the function is called.

Options

The following options are available for function calls:

option description
f++ function is in f++
n++ function is in n++
!const function is not constant
lambda function is a lambda
layer="l" define function at scope layer l
!o do not return output (option available at call time)
o return output (option available at call time)
pb parse function block at definition time
private function is private
scope+="s" function can be called from scope s
!s do not add scope when function is called (option available at call time)
s add scope when function is called [default] (option available at call time)
option description

f++ example

Examples of function being used with f++:

function(myFunc)
{
	console("hello, world!")
}

myFunc

function(myFunc)
{
	console("options: {", join(options, "; "), "}")
	console("params: {", join(params, "; "), "}")
}

myFunc{a, b, c}("hello", "world!")

n++ example

Example of function being used with n++:

@function(myFunc)
	@console("hello, world!")

@myFunc