Odin 是一种快速、简洁、可读且实用的编程语言,其希望用以下这些目标取代 C:
特性:
显式过程重载
package main
import “core:fmt”
main :: proc() { program := “+ + * - /”; accumulator := 0;
for token in program { switch token { case '+': accumulator += 1; case '-': accumulator -= 1; case '*': accumulator *= 2; case '/': accumulator /= 2; case '![](/static/assets/osapp/images/bb352c33c50e6f13fa87f2808ce44ecf.png)': accumulator *= accumulator; case: // Ignore everything else } } fmt.printf("The program \"%s\" calculates the value %d\n", program, accumulator);
}