Skip to content

Keywords ​

Fenneth has 16 reserved words. They cannot be used as variable, function, field or struct names.

KeywordPurposeExample
letDeclare a variable (type and initial value required).let n: i32 = 0;
constDeclare a constant.const MAX: i32 = 10;
fnDeclare a function.fn add(a: i32, b: i32) -> i32 { ... }
returnLeave a function, optionally with a value.return a + b;
ifConditional.if n > 0 { ... }
elseAlternative branch; combine as else if.else if n == 0 { ... } else { ... }
whileLoop while a condition holds.while i < 10 { ... }
forLoop over a range or an array.for i in 0..3 { ... }
inSeparates the loop variable from what is iterated.for x in xs { ... }
breakLeave the innermost loop.break;
continueSkip to the next loop iteration.continue;
trueBoolean literal.let ok: bool = true;
falseBoolean literal.let ok: bool = false;
structDeclare a struct type.struct P { x: i32, }
externDeclare a function implemented outside Fenneth (used with fn).extern fn f(a: i32) -> i32;
importLoad another source file.import "geometry";

Reserved type names ​

i32, f64, bool and String are built-in type names. A struct cannot use them as its name.

Built-in function names ​

The following names belong to the language and cannot be redefined as your own functions: print, write, eprint, to_f64, to_i32, to_str, len, push, pop, str_at, substr, char_str, str_to_i32, read_file, write_file, file_exists, read_line, args, exit, panic. See Built-in functions.

Symbols ​

SymbolMeaning
->Return type in a function signature
..Exclusive range in for i in a..b
:Type annotation, struct field, struct literal field
;Statement terminator
{ }Block, struct body, struct literal
[ ]Array type, array literal, indexing
.Struct field access
// /* */Comments

Released under the MIT License.