What's New
- Compiler compiles as C++ rather than C
- Massive declaration syntax change
- Declarations now use the Pascal-like prefix syntax
proc foo() {}var x = 123;var y: int = 123;(Type annotation)const y = 123;let z = false;type Bar struct{};import "fmt.odin";import_load "bits.odin";foreign_library "whatever.lib";foreign_system_library "kernel32.lib";
- Pascal-like declaration grouping (except for procedures)
const (
X: int = 123;
Y = 456; // copies above type e.g. `int`
Z = 789; // ditto
)
- Default procedure arguments
proc foo(i: int = 123, s: string, b = false) { ... }
foo(s = "Hellope");
foo(b = true, s = "Potato");
foo(1337, "Googolplex");
foo(99, "Whatever", false);
// Cannot mix named and non-named - consistent with compound literals
foreignblocks
foreign_library lib "some_lib.lib";
foreign lib {
proc the_variable() -> bool #link_name "sl_the_variable";
}
letsingle assignment variables- Replaces
immutable
- Replaces
var a = 123; // Mutable variable
a = 456; // Okay
let x = 123; // Immutable variable
x = 456; // Cannot assign to again