Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Keywords

This page lists all keywords in Felico and their usage.

Control Flow

if

Conditional expression.

if condition {
    // code
}

else

Alternative branch for if.

if condition {
    // code
} else {
    // alternative
}

while

Loop while condition is true.

while condition {
    // code
}

break

Exit from a loop early.

while true {
    if done {
        break
    }
}

continue

Skip to next loop iteration.

while i < 10 {
    i = i + 1
    if i % 2 == 0 {
        continue
    }
    print(i)
}

return

Return from a function.

fn max(x, y) {
    if x > y {
        return x
    }
    return y
}

Declarations

let

Variable declaration.

let x = 42
let name: string = "Felico"

fn

Function declaration.

fn greet(name) {
    print("Hello, " + name)
}

Literals

true

Boolean true value.

let flag = true

false

Boolean false value.

let flag = false

Reserved for Future Use

The following keywords are reserved for potential future features:

  • match - Pattern matching
  • for - For loops
  • in - Iterator syntax
  • struct - Custom data types
  • enum - Algebraic data types
  • trait - Type classes/interfaces
  • impl - Trait implementations
  • type - Type aliases
  • const - Compile-time constants
  • mut - Mutable bindings
  • pub - Public visibility
  • mod - Module declarations
  • use - Import statements
  • as - Type casting/aliasing
  • async - (Maybe not, due to function coloring concerns)
  • await - (Maybe not, due to function coloring concerns)

Contextual Keywords

Some identifiers have special meaning only in certain contexts. These are not strictly reserved and may be used as variable names:

  • self - Receiver in method syntax (planned)
  • super - Parent module reference (planned)