Statements
This documentation describes the statements that can be used in KASL.
Declaration Statements
Declaration statements are the statements that can be used in the global scopes.
Global Statements
These are the statements which can be used in the global scope to declare symbols such as variables, structs and functions.
| Keyword | Description | Link |
|---|---|---|
| import | Imports another kasl program. | Import |
| typealias | Names the specific type. | Typealias |
| func | Defines a function. | Function |
| input | Defines an input. | Input |
| output | Defines an output variable. | Output |
| state | Defines a state variable. | State |
| let | Defines a global constant. | Let |
| struct | Defines a struct. | Struct |
| operator infix / prefix / postfix | Defines the precedence and the associativity for the operator. | Operator Definition |
| func infix / prefix / postfix | Declares the implementation of an operator for the specific operand types. | Operator Function |
Struct Statements
Below are the statements can be used inside struct declarations.
| Keyword | Description | Link |
|---|---|---|
| var | Defines a struct field. | Struct Field |
| func | Defines a member function for the struct. | Function |
Statements
Statements can be used inside functions, and creates the actual execution logic.
| Statement | Description | Link |
|---|---|---|
| {} | Creates a scope. | Block |
| var | Declares a local variable. | Var |
| let | Declares a local constant. | Let |
| = | Assigns a value to the variable or its field. | Assign |
| if / if-else | Conditionally execute the statements. | If |
| return | Exits from the function with a return value. | Return |
| loop | Creates a loop that will be executed specific times. | Loop |