Odin v0.6.0
Additions and Changes
- Restore original declaration syntax
- Parametric Polymorphism ("Generics")
- Procedures
new :: proc(T: type) -> ^T {...}
new_clone :: proc(v: $T) -> ^T {...}
copy :: proc(dst, src: $T/[]$E) -> int {...}
- Structures
Vector :: struct(N: int, T: type) { e: [N]T; };
- Type specialization
make :: proc(T: type/[]$E) -> T {...}
add :: proc(a, b: $T/Vector) -> T {...}
sub :: proc(a, b: $T/Vector) -> T {...}
foo :: proc(b: ^Bar($T, $E)) {...}
exists :: proc(m: map[$K]$V, key: K) -> bool {...}
- Procedures
union
union{int, f32, FooBar, string, map[int]string}
- Duality between
any
andunion
now. Same usage with syntax.
raw_union
is now a tag onstruct
struct #raw_union {...}
struct
fields use semicolonsstruct {x: f32; y: int; z: string}
- Nested Struct Declarations
struct {
// constants
FOO :: 123;
MyInt :: int;
// fields
x: int;
}
- Default Struct Values
struct {
s: string = "Hellope";
i := 123;
b: bool; // zero value
}
do
for inline statements rather than blockif cond do foo();
- Removed
++
,--
- Use
+=
and-=
instead
- Use
- Removed
atomic
- Type operator precendence change
^T(x) == ^(T(x))
- Additional casting syntax
cast(T)x
(T)(x)
- Uninitialized value
---
- Removal of
*_val_of
- Replaced with
size_of
,align_of
,offset_of
,type_of
,type_info_of
- Replaced with
- Compiler options:
-opt=0,1,2,3
-show-timings
-thread-count=4
- Multi-threaded Parser