Releases: odin-lang/Odin
Releases · odin-lang/Odin
Odin v0.6.1a
Changes
- Minor fixes for *nix systems
Odin v0.6.1
Changes
- Fix parser threading bug on Windows
- Disable parser threading on *nix
-thread-count=N- Remove temporary files
- -
keep-temp-files
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
unionunion{int, f32, FooBar, string, map[int]string}- Duality between
anyandunionnow. Same usage with syntax.
raw_unionis now a tag onstructstruct #raw_union {...}
structfields 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
}
dofor 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
Odin v0.5.0
Changes
- C-style varargs
#c_vararg
foreigndeclaration blocks
foreign libc {
var errno: i32;
proc c_printf(fmt: ^u8, #c_vararg args: ..any) -> i32 #cc_c #link_name "printf";
}
expand_to_tuple- Default procedure arguments
proc hello(a: int = 9, b = 9) {
fmt.printf("a is %d; b is %d\n", a, b);
}
- Default return values
proc foo(x: int) -> (first: string = "Hellope", second = "world!") {
return;
}
- Named procedure arguments
hello(b = 123, a = 321);
- Named return values
return a = 123, b = "blah";
#location()and#caller_location- Explicit parametric polymorphic procedures
proc new(T: type) -> ^T { ... };
- Command line arguments
-opt=0,1,2,3
Odin v0.4.0
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
Odin v0.3.0
What's New
bit_field- Lexical Sugar:
≠,≤,≥ u128i128- Label syntax change:
name: for { break name; }
%%divisor based modulo operator"bits.odin"- Casting syntax change:
- Regular cast:
type(expr) - Bit cast:
transmute(type, expr) - Type assertion (replaces
union_cast):expr.(type)
- Regular cast:
- Address of operator
&replacing^- Pointer types and dererefencing still use
^
- Pointer types and dererefencing still use
default:replaced withcase:#orderedreimplemented#no_alias(replacing keywordno_alias)- XOR for booleans
runeas a basic type rather than alias ofi32- Provides extra type information at runtime
byteis removed- Use
u8instead
- Use
- Removed
quaternion128andquaternion256
Naming Convention
Odin has finally chose an official naming convention
In general, PascalCase for types and snake_case for values.
Import Name: snake_case (but prefer single word)
Types: PascalCase
Union Variants: PascalCase
Enum Values: PascalCase
Procedures: snake_case
Local Variables: snake_case
Field Values: snake_case
Constant Variables: SCREAMING_SNAKE_CASE
Odin v0.2.1
Added
- Allow vector math with its element type
for initeration of enum Type
Changes
bprint*returns a string now
Fixes
- Fix statement parsing of unary & and ^
- Fix IR vector arithmetic bug
- Fix unary expression for vectors
Odin v0.2.0 - Windows
Added
-
Complex numbers
complex64,complex128
-
Quaternions
quaternion128,quaternion256
-
New built in procedures
conj(x)len(x),cap(x)make([]T),make([dynamic]T),make(map[K]V)transmute(T, x)
-
#require_resultsfor procedures -
Interval syntax
a..bopen range [a, b]a..<bhalf-closed range [a, b)
-
Interval expression is match statements
case 'A'..'Z', 'a'..'z':
-
Addressing operator
&(replaces^)x: int; p: ^int = &x; i: int = p^;
-
New casting syntax
- Basic type conversion:
type(x)- Replaces
cast(type)x
- Replaces
- Type assertion:
x.(type)- Replaces
union_castand works withanynot just unions
- Replaces
- Bitcast:
transmute(T, x)- Replaces
transmute(T)x
- Replaces
- Basic type conversion:
-
os.argsCommand line arguments inos.odin -
Correct C ABI for x86/amd64 on Windows
Changes
- Remove .count and .capacity and replace with
len()andcap() - Remove
new_sliceand replace with `make - Removed
down_cast - Move
Raw_*types toraw.odin - Change memory layout of
any - Changes to
fmt.odin- Remove
sprint* - Add
aprint*,bprint*,sbprint*
- Remove
strconv.parse_intinstrconv.odin
Bug fixes
- Cast to
anyof untyped constants - Fix
appendcrash when pointer is passed - Fix slicing bug on dynamic arrays
- Fix map key not getting transferred on rehash
- Bugs with union size and alignment
- Fix procedure literal scopes and dependencies
- Fix subtype polymorphism
- Fix double declaration in
whenstatements - Fix float precision printing
Odin v0.1.3
Added
- Slices now store have capacity (again)
- Added multiple type cases for
match in - Named
forandmatchstatements (#label) ++--statements return
Changes
fmt.odinuses^[]byteand[]byterather than custom buffer type...and..<removed and replace with....is used for slice parameters and infor instatements which is equivalent to the old..<appendallows pointersnew_sliceallows for capacity
Bug Fixes
- Signed integer conversion
fmt.odinfix printing enums- Fix tuple type info bug
Odin v0.1.1
Added
- Entities and record fields prefixed with an underscore do not get exported on imports
- Records have an implicit
namesfields, a[]stringof all the names for that record (struct/raw_union/enum) - New built-in procedures
slice_to_bytes- convert any slice to a slice of bytesdelete- remove an entry from a mapclear- clear the contents of a map or dynamic array (e.g. set the count to zero)reserve- reserve memory for the dynamic map or array
union_castallows for an optional "ok" check; will panic if the cast is invalid and the ok check was not used?:ternary operator (replaces block and if expressions)- Unions with variants and common fields
Changed
- Core library additions to Windows specific stuff
Fixes
- Overloading bug due to comparison of named types
- Overloading bug due to
#import .collision - Disallow a
castfrom a pointer of a union (useunion_castinstead) - Minor bugs in generated IR code for slices