A function declaration or definition.

If the definition is missing or a specifier, then the statement must be terminated by a semicolon; if it’s a Block, the semicolon is not necessary.


shared formal Boolean equals(Object that);
function compareByLength({Anything*} first, {Anything*} second) => first.length.compare(second.length);
shared void run() {
    print("Hello, `` process.arguments.first else "World" ``!");
childrenSource Codeshared formal [Annotations, Type|FunctionModifier|DynamicModifier|VoidModifier, LIdentifier, <TypeParameters|TypeConstraint|Block|LazySpecifier>*] children

The child nodes of this node.

definitionSource Codeshared formal Block|LazySpecifier? definition

The function definition.

nameSource Codeshared formal MemberName name

The function name.

parameterListsSource Codeshared formal [Parameters+] parameterLists

The parameter lists. A function must have at least one, but may also have several parameter lists.

typeSource Codeshared formal Type|FunctionModifier|DynamicModifier|VoidModifier type

The type of the function.

This can be:

  • a Type,
  • a void’ modifier (VoidModifier) for a function that does not return a value,
  • a function’ modifier (FunctionModifier) for a function with inferred type,
  • a dynamic’ modifier (DynamicModifier) for a dynamically typed function.

(A function declaration without definition may not use a ‘function’ modifier, as wtihout a definition no type can be inferred.)

typeConstraintsSource Codeshared formal TypeConstraint[] typeConstraints

The type constraints placed upon the function’s type parameters, if any.

typeParametersSource Codeshared formal TypeParameters? typeParameters

The type parameters of the function, if any.

Inherited Attributes
Attributes inherited from: Declaration
Attributes inherited from: Node
Attributes inherited from: Object
Inherited Methods
Methods inherited from: Node
Methods inherited from: Object