mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-01 12:18:15 +00:00
Untagged (unsafe) unions and unambiguous in|postfix notation.
This commit is contained in:
+10
-1
@@ -12,6 +12,15 @@ main :: proc() {
|
||||
// data_control();
|
||||
|
||||
// run_game();
|
||||
|
||||
Thing :: type union {
|
||||
i: i32,
|
||||
f: f32,
|
||||
}
|
||||
t: Thing;
|
||||
t.f = 123;
|
||||
print_int_base(t.i as int, 16);
|
||||
print_nl();
|
||||
}
|
||||
|
||||
hellope :: proc() -> int {
|
||||
@@ -153,7 +162,7 @@ procedures :: proc() {
|
||||
print_int(a + b);
|
||||
}
|
||||
|
||||
print_int(3 'add' 4); // Infix style
|
||||
print_int(3 ''add 4); // Infix style
|
||||
print_nl();
|
||||
print_int(12 'fibonacci); // Postfix style
|
||||
print_nl();
|
||||
|
||||
+3
-3
@@ -102,9 +102,9 @@ cross :: proc(x, y: Vec3) -> Vec3 {
|
||||
}
|
||||
|
||||
|
||||
vec2_mag :: proc(v: Vec2) -> f32 { return fsqrt(v 'dot2' v); }
|
||||
vec3_mag :: proc(v: Vec3) -> f32 { return fsqrt(v 'dot3' v); }
|
||||
vec4_mag :: proc(v: Vec4) -> f32 { return fsqrt(v 'dot4' v); }
|
||||
vec2_mag :: proc(v: Vec2) -> f32 { return fsqrt(v ''dot2 v); }
|
||||
vec3_mag :: proc(v: Vec3) -> f32 { return fsqrt(v ''dot3 v); }
|
||||
vec4_mag :: proc(v: Vec4) -> f32 { return fsqrt(v ''dot4 v); }
|
||||
|
||||
vec2_norm :: proc(v: Vec2) -> Vec2 { return v / Vec2{vec2_mag(v)}; }
|
||||
vec3_norm :: proc(v: Vec3) -> Vec3 { return v / Vec3{vec3_mag(v)}; }
|
||||
|
||||
Reference in New Issue
Block a user