Skip to content

Odin v0.4.0

Compare
Choose a tag to compare
@gingerBill gingerBill released this 12 Jun 20:41
· 12977 commits to master since this release

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
  • foreign blocks
foreign_library lib "some_lib.lib";
foreign lib {
	proc the_variable() -> bool #link_name "sl_the_variable";
}
  • let single assignment variables
    • Replaces immutable
var a = 123; // Mutable variable
a = 456; // Okay
let x = 123; // Immutable variable
x = 456; // Cannot assign to again