public final class WhileyFile.Function extends WhileyFile.FunctionOrMethodOrProperty
function f(int x) -> (int y)
// Parameter must be positive
requires x > 0
// Return must be negative
ensures y < 0:
// body
return -x
Here, a function f is defined which accepts only positive
integers and returns only negative integers. The special variable
$ is used to refer to the return value. Functions in Whiley
may not have side-effects (i.e. they are pure functions).
Function declarations may also have modifiers, such as
public and private.
NOTE see WhileyFile.FunctionOrMethodOrProperty for more information.
WhileyFile.FunctionOrMethodOrProperty| Modifier and Type | Field and Description |
|---|---|
Type.Function |
resolvedType |
ensures, lifetimeParameters, parameters, requires, returns, statements| Constructor and Description |
|---|
Function(List<Modifier> modifiers,
String name,
List<WhileyFile.Parameter> returns,
List<WhileyFile.Parameter> parameters,
List<Expr> requires,
List<Expr> ensures,
List<Stmt> statements,
wybs.lang.Attribute... attributes) |
| Modifier and Type | Method and Description |
|---|---|
Type.Function |
resolvedType() |
wyal.lang.WyalFile.Type.Function |
unresolvedType() |
hasModifier, modifiers, namepublic Type.Function resolvedType
public wyal.lang.WyalFile.Type.Function unresolvedType()
unresolvedType in class WhileyFile.FunctionOrMethodOrPropertypublic Type.Function resolvedType()
resolvedType in class WhileyFile.FunctionOrMethodOrPropertyCopyright © 2017. All rights reserved.