Releases: odin-lang/Odin
Releases · odin-lang/Odin
Odin v0.5.0
Changes
- C-style varargs
#c_vararg
foreign
declaration 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
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
- 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:
≠
,≤
,≥
u128
i128
- 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:
#ordered
reimplemented#no_alias
(replacing keywordno_alias
)- XOR for booleans
rune
as a basic type rather than alias ofi32
- Provides extra type information at runtime
byte
is removed- Use
u8
instead
- Use
- Removed
quaternion128
andquaternion256
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 in
iteration 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_results
for procedures -
Interval syntax
a..b
open range [a, b]a..<b
half-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_cast
and works withany
not just unions
- Replaces
- Bitcast:
transmute(T, x)
- Replaces
transmute(T)x
- Replaces
- Basic type conversion:
-
os.args
Command line arguments inos.odin
-
Correct C ABI for x86/amd64 on Windows
Changes
- Remove .count and .capacity and replace with
len()
andcap()
- Remove
new_slice
and 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_int
instrconv.odin
Bug fixes
- Cast to
any
of untyped constants - Fix
append
crash 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
when
statements - Fix float precision printing
Odin v0.1.3
Added
- Slices now store have capacity (again)
- Added multiple type cases for
match in
- Named
for
andmatch
statements (#label
) ++
--
statements return
Changes
fmt.odin
uses^[]byte
and[]byte
rather than custom buffer type...
and..<
removed and replace with..
..
is used for slice parameters and infor in
statements which is equivalent to the old..<
append
allows pointersnew_slice
allows for capacity
Bug Fixes
- Signed integer conversion
fmt.odin
fix 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
names
fields, a[]string
of 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_cast
allows 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
cast
from a pointer of a union (useunion_cast
instead) - Minor bugs in generated IR code for slices
Odin v0.1.0
Added:
- Dynamic Arrays
[...]Type
- Dynamic Maps
map[Key]Value
- Dynamic array and map literals
- Custom struct alignemnt
struct #align 8 { bar: i8 }
- Allow
_
in numbers - Variadic
append
- fmt.sprint*
- Entities prefixes with an underscore do not get exported on imports
- Overloaded
free
for pointers, slices, strings, dynamic arrays, and dynamic maps - enum types have an implict
names
field, a []string of all the names in that enum
Removed:
- Maybe/option types
- immutable variables
- Remove
type
keyword and other "reserved" keywords
Changed:
compile_assert
andassert
return the value of the condition for semantic reasonsthread_local
->#thread_local
#include
->#load
- Files only get checked if they are actually used
match x in y {}
// For type match statements- Version numbering now starts from 0.1.0 and uses the convention:
- major.minor.patch
Fixes:
- Many
fmt.*
fixes
To come very Soon™:
- Linux and OS X builds (unofficial ones do exist already)
Odin v0.0.6b
Bug Fixes
- Fix assignment of "untyped" constants to
any
(issue #13) - Fix crash when passing arguments with no value/type to a call
Odin v0.0.6a
What's New
- Overloaded
free
- Accepts pointers, slices, and strings
- 3 dotted ellipsis
...