removed type-value interchange
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 30 Nov 2021 00:15:18 +0000 (18:15 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 30 Nov 2021 00:15:18 +0000 (18:15 -0600)
core/io/binary.onyx
docs/watchout
src/parser.c
tests/new_struct_behaviour.onyx
tests/operator_overload.onyx
tests/poly_structs_with_values.onyx
tests/struct_robustness.onyx

index f65c726e50201ebd7e687edda0bce2be92a27830..c709a3144133eb7652fbd6579c011d42166bd545 100644 (file)
@@ -17,14 +17,14 @@ binary_write_byte :: (use bw: ^BinaryWriter, byte: u8) {
 }
 
 binary_write :: (use bw: ^BinaryWriter, $T: type_expr, v: ^T) {
-    stream_write(stream, <[] u8>.{ ~~ v, sizeof T });
+    stream_write(stream, .{ ~~ v, sizeof T });
 }
 
 binary_write_slice :: (use bw: ^BinaryWriter, sl: [] $T, output_size := false) {
     assert(false, "binary_write_slice is not working at the moment");
     if output_size do binary_write(bw, i32, sl.count);
 
-    bytes := <[] u8>.{
+    bytes := ([] u8).{
         data = cast(^u8) ^sl.data[0],
         count = sizeof T * sl.count,
     };
@@ -72,5 +72,5 @@ binary_read_slice :: (use br: ^BinaryReader,
     sl := memory.make_slice(u8, size * sizeof T, allocator = allocator);
     _, bytes_read := stream_read(stream, sl);
 
-    return <[] T>.{ data = cast(^T) sl.data, count = size };
+    return .{ data = cast(^T) sl.data, count = size };
 }
index 19c79e76df59479d38ccb944cf9cae0c2a75fec2..cec05161de2b1a4a5c8978bd15951092b2d5b834 100644 (file)
@@ -15,10 +15,4 @@ Some tags to watch out for in the code with features that may be removed in the
 
         The implementation of `null_proc` is rather simple, but feels a
         little verbose an targential compared to everything else being done
-        in the compiler.
-
-    :TypeValueInterchange
-        Angle brackets are being used to specify types in value expressions
-        and vice versa. This is just a temporary hack. The long term goal
-        is that type expressions are automatically detected in value
-        expressions.
\ No newline at end of file
+        in the compiler.
\ No newline at end of file
index 4304880fe0363ba9da251d4c4549b332fdc296d9..b3e770dd4aee6ab040902fb6dd1ecefcadb89d6d 100644 (file)
@@ -516,17 +516,6 @@ static AstTyped* parse_factor(OnyxParser* parser) {
             break;
         }
 
-        // :TypeValueInterchange
-        case '<': {
-            AstTypeAlias* alias = make_node(AstTypeAlias, Ast_Kind_Type_Alias);
-            alias->token = expect_token(parser, '<');
-            alias->to = parse_type(parser);
-            expect_token(parser, '>');
-
-            retval = (AstTyped *) alias;
-            break;
-        }
-
         case '[': {
             AstType *type = parse_type(parser);
             retval = (AstTyped *) type;
index c3094a2b7f2771686d68fdbbd82b585f4108346d..600169ee2967fe2343a372adb0435dc4b2e924e9 100644 (file)
@@ -57,7 +57,7 @@ main :: (args: [] cstr) {
     foo := Foo.{};
     println(foo->get_member2_plus_three());
     
-    ps := <PolyStruct(i32)>.{ 1234 };
+    ps := PolyStruct(i32).{ 1234 };
     println(ps.works(ps.member));
 
     plus_one : (i32) -> i32 = PolyStruct.member_function;
index 0fa1aaf0360f5f6a9dcdaabb1d1f4dd577754311..c929cabed7c9c73d8261c38c3cb88b83005049d8 100644 (file)
@@ -59,7 +59,7 @@ join :: (a: Vec($T, $N), b: Vec(T, $M)) -> Vec(T, #value N + M) {
 }
 
 make_vec :: (data: [$N] $T) -> Vec(T, N) {
-    return <Vec(T, N)>.{ data };
+    return .{ data };
 }
 
 main :: (args: [] cstr) {
index 3fd0053488545913ea8374504b2ace0cd308415d..2cdcac9242e594293ea99a40a3c646fb08cd2ead 100644 (file)
@@ -24,7 +24,7 @@ main :: (args: [] cstr) {
         str_member : str = default; 
     }
 
-    swd := <SimpleWithDefault(i32, "Hello World!")>.{ x = 1234 };
+    swd := SimpleWithDefault(i32, "Hello World!").{ x = 1234 };
     println(swd.x);
     println(swd.str_member);
     poly_match(swd);
index 09648d30cd6b16f8a6ac594c1886ec72894fb52e..43165758f25b059a233c31ff3bbb2333d3b81f79 100644 (file)
@@ -118,8 +118,7 @@ main :: (args: [] cstr) {
 
         printf("PolyStruct<i32, f32>({}, {})\n", ps1.t_data, ps1.r_data);
 
-        // Currently, this is how you have to do this.
-        ps2 := <PolyStruct(f32, i32)>.{ 1234, 5678 };
+        ps2 := PolyStruct(f32, i32).{ 1234, 5678 };
         printf("PolyStruct<f32, i32>({}, {})\n", ps2.t_data, ps2.r_data);
     }
 
@@ -131,7 +130,7 @@ main :: (args: [] cstr) {
             r_data : R = 5678;
         }
 
-        PolyStructTyped :: <PolyStruct(i32, f32)>;
+        PolyStructTyped :: PolyStruct(i32, f32);
 
         ps := PolyStructTyped.{};
         printf("PolyStruct<i32, f32>({}, {})\n", ps.t_data, ps.r_data);