Functions

The Gorilla Programming Language


Functions

There are two kinds of functions in Gorilla

Function Statement

Syntax:

functionStatement ::= "func" identifier parameters block

Syntax in code:

func FunctionName(arg1, arg2, arg3) {
    doo.something1(arg1 + arg2 + arg3)
    doo.something2(arg1 * arg2 * arg3)
}
func NoArgument()
    doo.something()

Function Literal

Syntax:

functionLiteral ::= "fn" parameters? block

Syntax in code:

fn(arg1, arg2, arg3) {
    doo.something1(arg1 + arg2 + arg3)
    doo.something2(arg1 * arg2 * arg3)
}
fn doo.something

Function Statement is a statement while Function Literal is an expression

func name(){} is the same as name = fn(){}

back