Untagged (unsafe) unions and unambiguous in|postfix notation.

This commit is contained in:
Ginger Bill
2016-08-24 15:06:36 +01:00
parent 975705f1fc
commit 6bd898e552
11 changed files with 516 additions and 364 deletions
+10 -1
View File
@@ -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
View File
@@ -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)}; }