migration: changed tests to use new pointer syntax
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 6 Mar 2023 02:52:13 +0000 (20:52 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 6 Mar 2023 02:54:55 +0000 (20:54 -0600)
73 files changed:
tests/aoc-2020/day1.onyx
tests/aoc-2020/day10.onyx
tests/aoc-2020/day11.onyx
tests/aoc-2020/day12.onyx
tests/aoc-2020/day13.onyx
tests/aoc-2020/day14.onyx
tests/aoc-2020/day15.onyx
tests/aoc-2020/day16.onyx
tests/aoc-2020/day17.onyx
tests/aoc-2020/day18.onyx
tests/aoc-2020/day19.onyx
tests/aoc-2020/day2.onyx
tests/aoc-2020/day20.onyx
tests/aoc-2020/day21.onyx
tests/aoc-2020/day22.onyx
tests/aoc-2020/day23.onyx
tests/aoc-2020/day24.onyx
tests/aoc-2020/day25.onyx
tests/aoc-2020/day3.onyx
tests/aoc-2020/day4.onyx
tests/aoc-2020/day5.onyx
tests/aoc-2020/day6.onyx
tests/aoc-2020/day7.onyx
tests/aoc-2020/day8.onyx
tests/aoc-2020/day9.onyx
tests/aoc-2021/day01.onyx
tests/aoc-2021/day02.onyx
tests/aoc-2021/day03.onyx
tests/aoc-2021/day04.onyx
tests/aoc-2021/day05.onyx
tests/aoc-2021/day06.onyx
tests/aoc-2021/day07.onyx
tests/aoc-2021/day08.onyx
tests/aoc-2021/day09.onyx
tests/aoc-2021/day10.onyx
tests/aoc-2021/day11.onyx
tests/aoc-2021/day12.onyx
tests/aoc-2021/day13.onyx
tests/aoc-2021/day14.onyx
tests/aoc-2021/day15.onyx
tests/aoc-2021/day16.onyx
tests/aoc-2021/day17.onyx
tests/aoc-2021/day18.onyx
tests/aoc-2021/day21.onyx
tests/array_struct_robustness.onyx
tests/arrow_notation.onyx
tests/atomics.onyx
tests/auto_poly.onyx
tests/avl_test.onyx
tests/baked_parameters.onyx
tests/bucket_array.onyx
tests/bugs/anonymous_struct_defaults.onyx
tests/bugs/double_polymorph_yield_error.onyx
tests/bugs/macro_auto_return_not_resolved.onyx
tests/bugs/method_call_source_double.onyx
tests/caller_location.onyx
tests/compile_time_procedures.onyx
tests/complicated_polymorph.onyx
tests/i32map.onyx
tests/implicit_initialize_locals.onyx
tests/interfaces.onyx
tests/lazy_iterators.onyx
tests/multiple_returns_robustness.onyx
tests/new_struct_behaviour.onyx
tests/no_types.onyx
tests/parallel_for.onyx
tests/persist_locals.onyx
tests/poly_structs_with_values.onyx
tests/remove_test.onyx
tests/sets.onyx
tests/string_stream_test.onyx
tests/struct_use_pointer_member.onyx
tests/vararg_test.onyx

index b40a5bff4351a7b17d1c4910b3ace4d4fa36d832..7162889a655762103612f5afa20cf4c4a4d2c3e0 100644 (file)
@@ -8,12 +8,12 @@ main :: (args: [] cstr) {
     defer cfree(stream);
 
     nums := array.make(u32, 128);
-    defer array.free(^nums);
+    defer array.free(&nums);
 
     while num := 1; num > 0 {
         // This sets num to be 0 if there is no number
-        num = io.read_u32(^reader);
-        if num != 0 do array.push(^nums, num);
+        num = io.read_u32(&reader);
+        if num != 0 do array.push(&nums, num);
     }
 
     for i: nums do for j: nums do for k: nums {
index 2c04665ed2cc71235a40326907e9f38872cd0bc9..8866633a6262b1e239be5948f1440ed35d938ea8 100644 (file)
@@ -4,9 +4,9 @@ use package core
 
 count_ending_paths :: (nums: [..] u32) -> u64 {
     tally := array.make(u64, nums.count);
-    defer array.free(^tally);
+    defer array.free(&tally);
 
-    for ^t: tally do *t = 0;
+    for &t: tally do *t = 0;
     tally[nums.count - 1] = 1;
 
     while i := cast(i32) (nums.count - 2); i >= 0 {
@@ -28,20 +28,20 @@ main :: (args: [] cstr) {
     file := contents;
 
     nums := array.make(u32);
-    defer array.free(^nums);
+    defer array.free(&nums);
 
     while !string.empty(file) {
-        array.push(^nums, ~~ conv.parse_int(^file)); 
-        string.advance_line(^file);
+        array.push(&nums, ~~ conv.parse_int(&file)); 
+        string.advance_line(&file);
     }
 
     // Slight hack, but having 0 in the array makes both parts easier
-    array.push(^nums, 0);
+    array.push(&nums, 0);
 
     array.sort(nums, (a, b) => a - b);
 
     diffs: [3] u32;
-    for ^d: diffs do *d = 0;
+    for &d: diffs do *d = 0;
     for i: 1 .. nums.count do diffs[nums[i] - nums[i - 1] - 1] += 1;
     diffs[2] += 1;
 
index a8c189d0894005180a317c7c3f124a099e33fd72..e8be0fa71a68e53197d99a09b6ad260974e5ed1c 100644 (file)
@@ -11,12 +11,12 @@ GameOfSeats :: struct {
 
 SeatState :: enum (u8) { OOB; Floor; Empty; Occupied; }
 
-gos_get_seat :: (use gos: ^GameOfSeats, x: i32, y: i32) -> SeatState {
+gos_get_seat :: (use gos: &GameOfSeats, x: i32, y: i32) -> SeatState {
     if x < 0 || y < 0 || x >= width || y >= height do return SeatState.OOB;
     return seats[x + y * width];
 }
 
-gos_neighbors :: (use gos: ^GameOfSeats, x: i32, y: i32, state := SeatState.Occupied) -> u32 {
+gos_neighbors :: (use gos: &GameOfSeats, x: i32, y: i32, state := SeatState.Occupied) -> u32 {
     count := 0;
 
     for dy: -1 .. 2 {
@@ -37,7 +37,7 @@ gos_neighbors :: (use gos: ^GameOfSeats, x: i32, y: i32, state := SeatState.Occu
     return count;
 }
 
-gos_iter :: (use gos: ^GameOfSeats) -> bool {
+gos_iter :: (use gos: &GameOfSeats) -> bool {
     for i: 0 .. seats.count do temp[i] = seats[i];
 
     changed := false;
@@ -70,27 +70,27 @@ main :: (args: [] cstr) {
     file := contents;
 
     gos : GameOfSeats;
-    array.init(^gos.seats, 32);
-    defer array.free(^gos.seats);
+    array.init(&gos.seats, 32);
+    defer array.free(&gos.seats);
 
     gos.height = 0;
 
     while !string.empty(file) {
         line, file' := string.bisect(file, #char "\n");
         for ch: line do switch ch {
-            case #char "." do array.push(^gos.seats, SeatState.Floor);
-            case #char "L" do array.push(^gos.seats, SeatState.Empty);
-            case #char "#" do array.push(^gos.seats, SeatState.Occupied);
+            case #char "." do array.push(&gos.seats, SeatState.Floor);
+            case #char "L" do array.push(&gos.seats, SeatState.Empty);
+            case #char "#" do array.push(&gos.seats, SeatState.Occupied);
         }
 
         gos.width = line.count;
         gos.height += 1;
     }
 
-    array.init(^gos.temp, gos.seats.count);
-    defer array.free(^gos.temp);
+    array.init(&gos.temp, gos.seats.count);
+    defer array.free(&gos.temp);
 
-    while gos_iter(^gos) ---
+    while gos_iter(&gos) ---
 
     occupied := 0;
     for s: gos.seats do if s == SeatState.Occupied do occupied += 1;
index 40b65009f4d07a9cd8817ae6238809233c70d267..8decca70c99fa0a903a179f4a7e249c75e0c1576 100644 (file)
@@ -10,7 +10,7 @@ Ship :: struct {
     fy : i32 = 0;
 }
 
-rotate_left :: (ship: ^Ship) {
+rotate_left :: (ship: &Ship) {
     ofx := ship.fx;
     ofy := ship.fy;
 
@@ -18,7 +18,7 @@ rotate_left :: (ship: ^Ship) {
     ship.fy = -ofx;
 }
 
-rotate_right :: (ship: ^Ship) {
+rotate_right :: (ship: &Ship) {
     ofx := ship.fx;
     ofy := ship.fy;
 
@@ -26,7 +26,7 @@ rotate_right :: (ship: ^Ship) {
     ship.fy = ofx;
 }
 
-turn_around :: (ship: ^Ship) {
+turn_around :: (ship: &Ship) {
     ship.fx = -ship.fx;
     ship.fy = -ship.fy;
 }
@@ -39,10 +39,10 @@ main :: (args: [] cstr) {
     ship := Ship.{ fx = 10, fy = -1 };
     while !string.empty(file) {
         dir := file[0];
-        string.advance(^file, 1);
+        string.advance(&file, 1);
 
-        val := cast(u32, conv.parse_int(^file));
-        string.advance_line(^file); 
+        val := cast(u32, conv.parse_int(&file));
+        string.advance_line(&file); 
         
         switch dir {
             case #char "N" do ship.fy -= val;
@@ -55,15 +55,15 @@ main :: (args: [] cstr) {
             }
 
             case #char "L" do switch val {
-                case 90 do rotate_left(^ship);
-                case 180 do turn_around(^ship);
-                case 270 do rotate_right(^ship);
+                case 90 do rotate_left(&ship);
+                case 180 do turn_around(&ship);
+                case 270 do rotate_right(&ship);
             }
 
             case #char "R" do switch val {
-                case 90 do rotate_right(^ship);
-                case 180 do turn_around(^ship);
-                case 270 do rotate_left(^ship);
+                case 90 do rotate_right(&ship);
+                case 180 do turn_around(&ship);
+                case 270 do rotate_left(&ship);
             }
         }
     }
index 1134d7bad660b5bbcc5884c95be6e497add48482..65fe309a7d61f7db2027036166f7dfa947091ae8 100644 (file)
@@ -40,32 +40,32 @@ main :: (args: [] cstr) {
 
     file := contents;
 
-    est := cast(u32, conv.parse_int(^file));
-    string.advance_line(^file);
+    est := cast(u32, conv.parse_int(&file));
+    string.advance_line(&file);
 
     buses := array.make(i64);
-    defer array.free(^buses);
+    defer array.free(&buses);
 
     rems := array.make(i64);
-    defer array.free(^rems);
+    defer array.free(&rems);
 
     offset: i64 = 0;
     while !string.empty(file) {
         if *file.data == #char "x" {
-            string.advance(^file, 2);
+            string.advance(&file, 2);
         } else {
-            bus := conv.parse_int(^file);
-            array.push(^buses, ~~bus);
-            array.push(^rems, bus - offset);
+            bus := conv.parse_int(&file);
+            array.push(&buses, ~~bus);
+            array.push(&rems, bus - offset);
 
-            string.advance(^file, 1);
+            string.advance(&file, 1);
         }
 
         offset += 1;
     }
 
     // Part 1
-    // min := array.fold(^buses, 0xffffffff, math.min);
+    // min := array.fold(&buses, 0xffffffff, math.min);
 
     // take_bus := 0;
     // depart   := 0;
index 152e4ced3bf7c79d3329bc54d1c9813e550a6593..080c7c1cefec387cc714615f17730e2f9bfdf6f5 100644 (file)
@@ -31,7 +31,7 @@ BitmaskIter :: struct {
 
 bitmask_p2 :: (mask: Bitmask, val: u64) -> Iterator(u64) {
     iterator_next :: (data: rawptr) -> (u64, bool) {
-        bmi := cast(^BitmaskIter) data;
+        bmi := cast(&BitmaskIter) data;
         if bmi.done do return 0, false;
 
                for ind: bmi.floating_indicies {
@@ -47,15 +47,15 @@ bitmask_p2 :: (mask: Bitmask, val: u64) -> Iterator(u64) {
     }
 
     iterator_close :: (data: rawptr) {
-        bmi := cast(^BitmaskIter) data;
-        array.free(^bmi.floating_indicies);
+        bmi := cast(&BitmaskIter) data;
+        array.free(&bmi.floating_indicies);
         cfree(bmi);
     }
 
     bmi := new(BitmaskIter);
     bmi.done = false;
 
-    array.init(^bmi.floating_indicies, 8);
+    array.init(&bmi.floating_indicies, 8);
 
        v := val;
        for i: 0 .. MASK_SIZE {
@@ -63,7 +63,7 @@ bitmask_p2 :: (mask: Bitmask, val: u64) -> Iterator(u64) {
 
                if mask[i] == 2 {
             v &= ~(1 << cast(u64) i);
-                       array.push(^bmi.floating_indicies, cast(u8) i);
+                       array.push(&bmi.floating_indicies, cast(u8) i);
                }
        }
 
@@ -78,15 +78,15 @@ main :: (args: [] cstr) {
        file := contents;
 
        mem := map.make(u64, u64, default=0);
-       defer map.free(^mem);
+       defer map.free(&mem);
 
        mask : Bitmask;
-       for ^m: mask do *m = 2;
+       for &m: mask do *m = 2;
 
        while !string.empty(file) {
-               word := string.read_alphanum(^file);
+               word := string.read_alphanum(&file);
                if string.equal(word, "mask") {
-            string.advance(^file, 3);
+            string.advance(&file, 3);
 
                        i := 35;
             m, file' := string.bisect(file, #char "\n");
@@ -101,22 +101,22 @@ main :: (args: [] cstr) {
                        }
                }
                elseif string.equal(word, "mem") {
-                       string.advance(^file, 1);
+                       string.advance(&file, 1);
 
-                       addr := cast(u64, conv.parse_int(^file));
-                       string.advance(^file, 4);
+                       addr := cast(u64, conv.parse_int(&file));
+                       string.advance(&file, 4);
 
-                       val := cast(u64, conv.parse_int(^file));
+                       val := cast(u64, conv.parse_int(&file));
 
                        // Part 1
-                       // map.put(^mem, addr, bitmask_p1(mask, val));
+                       // map.put(&mem, addr, bitmask_p1(mask, val));
 
                        // Part 2
             for real_addr: bitmask_p2(mask, addr) {
-                map.put(^mem, real_addr, val);
+                map.put(&mem, real_addr, val);
             }
 
-                       string.advance_line(^file);
+                       string.advance_line(&file);
                }       
        }       
 
index 61317ff9d82f48823258dd1c1bc871a80dc57c1f..1d543650c6086a2259b1f8617b42162140e1dec0 100644 (file)
@@ -14,27 +14,27 @@ main :: (args: [] cstr) {
     // Any changes to the implementation of Map should be tested on this
     // file to validate if they 1) work and 2) are faster.
     nums := map.make(u32, spoken_times, .{});
-    defer map.free(^nums);
+    defer map.free(&nums);
 
     turn := 1;
     last_num := 0;
 
     for n: initial_numbers {
-        map.put(^nums, n, .{ recent = turn });
+        map.put(&nums, n, .{ recent = turn });
         turn += 1;
         last_num = n;
     }
 
     while turn != 2021 {
-        st := map.get(^nums, last_num);
+        st := map.get(&nums, last_num);
 
         if st.previous == 0 do last_num = 0;
         else                do last_num = st.recent - st.previous;
 
-        st = map.get(^nums, last_num);
+        st = map.get(&nums, last_num);
         st.previous = st.recent;
         st.recent = turn;
-        map.put(^nums, last_num, st);
+        map.put(&nums, last_num, st);
 
         turn += 1;
     }
index 452cf76ceaa3309d16d8e9f86b806f901d59fa26..35331144158d14c7561adea3dc6d10cfe9d313b6 100644 (file)
@@ -13,13 +13,13 @@ Field :: struct {
        upper1 : u32 = 0;
 }
 
-field_valid :: (use field: ^Field, n: u32) -> bool {
+field_valid :: (use field: &Field, n: u32) -> bool {
        return (lower0 <= n && n <= upper0) || (lower1 <= n && n <= upper1);
 }
 
 total_scanning_error := 0;
 
-read_ticket_and_validate :: (file: ^str, fields: [..] Field, ticket_store: ^u32) -> bool {
+read_ticket_and_validate :: (file: &str, fields: [..] Field, ticket_store: &u32) -> bool {
        retval := true;
 
        for i: 0 .. fields.count {
@@ -29,7 +29,7 @@ read_ticket_and_validate :: (file: ^str, fields: [..] Field, ticket_store: ^u32)
                if file.data[0] == #char "," do string.advance(file, 1);
 
                valid_count := 0;
-               for ^field: fields {
+               for &field: fields {
                        if field_valid(field, n) do valid_count += 1;
                }
 
@@ -49,44 +49,44 @@ main :: (args: [] cstr) {
        file := contents;
 
        fields := array.make(Field, 20);
-       defer array.free(^fields);
+       defer array.free(&fields);
 
        // Read until the first empty line
        while file.data[0] != #char "\n" {
                field := Field.{};
                field.name, file = string.bisect(file, #char ":");              
 
-               string.advance(^file, 1);
-               field.lower0 = ~~ conv.parse_int(^file);
+               string.advance(&file, 1);
+               field.lower0 = ~~ conv.parse_int(&file);
 
-               string.advance(^file, 1);
-               field.upper0 = ~~ conv.parse_int(^file);
+               string.advance(&file, 1);
+               field.upper0 = ~~ conv.parse_int(&file);
 
-               string.advance(^file, 4);
-               field.lower1 = ~~ conv.parse_int(^file);
+               string.advance(&file, 4);
+               field.lower1 = ~~ conv.parse_int(&file);
 
-               string.advance(^file, 1);
-               field.upper1 = ~~ conv.parse_int(^file);
+               string.advance(&file, 1);
+               field.upper1 = ~~ conv.parse_int(&file);
 
-               string.advance_line(^file);
+               string.advance_line(&file);
 
-               array.push(^fields, field);
+               array.push(&fields, field);
        }
 
-       for i: 0 .. 2 do string.advance_line(^file);
+       for i: 0 .. 2 do string.advance_line(&file);
 
        my_ticket := array.make(u32, fields.count);
-       defer array.free(^my_ticket);
-       read_ticket_and_validate(^file, fields, my_ticket.data);
+       defer array.free(&my_ticket);
+       read_ticket_and_validate(&file, fields, my_ticket.data);
 
-       for i: 0 .. 2 do string.advance_line(^file);
+       for i: 0 .. 2 do string.advance_line(&file);
 
        ticket_data := array.make(u32, 1024);
-       defer array.free(^ticket_data);
+       defer array.free(&ticket_data);
 
        while !string.empty(file) {
-               array.ensure_capacity(^ticket_data, ticket_data.count + fields.count);
-               if read_ticket_and_validate(^file, fields, ^ticket_data[ticket_data.count]) {
+               array.ensure_capacity(&ticket_data, ticket_data.count + fields.count);
+               if read_ticket_and_validate(&file, fields, &ticket_data[ticket_data.count]) {
                        ticket_data.count += fields.count;
                }
        }
@@ -94,16 +94,16 @@ main :: (args: [] cstr) {
        printf("Scanning error: {}\n", total_scanning_error);
 
        cols_to_assign := array.make(u32, fields.count);
-       defer array.free(^cols_to_assign);
+       defer array.free(&cols_to_assign);
 
-       for i: 0 .. fields.count do array.push(^cols_to_assign, i);
+       for i: 0 .. fields.count do array.push(&cols_to_assign, i);
 
        while cols_to_assign.count > 0 {
                for col: cols_to_assign {
                        work_count := 0;
-                       recent_work: ^Field = null;
+                       recent_work: &Field = null;
 
-                       for ^field: fields {
+                       for &field: fields {
                                if field.column != -1 do continue;
                                works := true;
 
@@ -122,14 +122,14 @@ main :: (args: [] cstr) {
 
                        if work_count == 1 {
                                recent_work.column = col;
-                               array.remove(^cols_to_assign, col);
+                               array.remove(&cols_to_assign, col);
                                break;
                        }
                }
        }
 
        prod: u64 = 1;
-       for ^field: fields {
+       for &field: fields {
                if string.starts_with(field.name, "departure") do prod *= ~~my_ticket[field.column];
        }
 
index 6be8030702e529f65aa0314589fb38cd52434c9c..59f7709183e88bb4f5a6a9f83075d464f4b2d7ae 100644 (file)
@@ -37,7 +37,7 @@ CubeState :: struct {
     next  := false;
 }
 
-get_neighbor_count :: (cubes: ^Map(CubePos, CubeState), pos: CubePos) -> u32 {
+get_neighbor_count :: (cubes: &Map(CubePos, CubeState), pos: CubePos) -> u32 {
     count := 0;
 
     for x: -1 .. 2 do for y: -1 .. 2 do for z: -1 .. 2 do for w: -1 .. 2 {
@@ -56,7 +56,7 @@ main :: (args: [] cstr) {
     file := contents;
 
     cubes := map.make(CubePos, CubeState, .{});
-    defer map.free(^cubes);
+    defer map.free(&cubes);
 
     z := 0;
     while !string.empty(file) {
@@ -64,7 +64,7 @@ main :: (args: [] cstr) {
 
         x := 0;
         for ch: line {
-            if ch == #char "#" do map.put(^cubes, .{ x, 0, z, 0 }, .{ alive = true });
+            if ch == #char "#" do map.put(&cubes, .{ x, 0, z, 0 }, .{ alive = true });
 
             x += 1;
         }
@@ -73,13 +73,13 @@ main :: (args: [] cstr) {
     }
 
     cubes_to_consider := array.make(CubePos);
-    defer array.free(^cubes_to_consider);
+    defer array.free(&cubes_to_consider);
 
     for i: 0 .. 6 {
-        for ^cube_entry: cubes.entries {
+        for &cube_entry: cubes.entries {
             if cube_entry.value.alive {
                 for x: -1 .. 2 do for y: -1 .. 2 do for z: -1 .. 2 do for w: -1 .. 2 {
-                    array.push(^cubes_to_consider, .{
+                    array.push(&cubes_to_consider, .{
                         cube_entry.key.x + x,
                         cube_entry.key.y + y,
                         cube_entry.key.z + z,
@@ -89,9 +89,9 @@ main :: (args: [] cstr) {
             }
         }
 
-        for ^cube: cubes_to_consider {
-            state  := map.get(^cubes, *cube);
-            ncount := get_neighbor_count(^cubes, *cube);
+        for &cube: cubes_to_consider {
+            state  := map.get(&cubes, *cube);
+            ncount := get_neighbor_count(&cubes, *cube);
             
             if state.alive {
                 state.next = ncount == 2 || ncount == 3;
@@ -99,20 +99,20 @@ main :: (args: [] cstr) {
                 state.next = ncount == 3;
             }
 
-            map.put(^cubes, *cube, state);
+            map.put(&cubes, *cube, state);
         }
 
-        for ^cube: cubes_to_consider {
-            state := map.get(^cubes, *cube);
+        for &cube: cubes_to_consider {
+            state := map.get(&cubes, *cube);
             state.alive = state.next;
-            map.put(^cubes, *cube, state);
+            map.put(&cubes, *cube, state);
         }
 
-        array.clear(^cubes_to_consider);
+        array.clear(&cubes_to_consider);
     }
 
     active_count := 0;
-    for ^cube_entry: cubes.entries do if cube_entry.value.alive do active_count += 1;
+    for &cube_entry: cubes.entries do if cube_entry.value.alive do active_count += 1;
 
     printf("Active count: {}\n", active_count);
 }
index 0a8e0cb45c615ffefec92412a368a774e31d2671..ac8c69ce494b6007d7b8dda48c48cc3d45834c88 100644 (file)
@@ -2,7 +2,7 @@
 
 use package core
 
-parse_factor :: (file: ^str) -> u64 {
+parse_factor :: (file: &str) -> u64 {
        string.strip_leading_whitespace(file);
 
        switch *file.data {
@@ -25,7 +25,7 @@ parse_factor :: (file: ^str) -> u64 {
        return 0;
 }
 
-parse_expression_add :: (file: ^str) -> u64 {
+parse_expression_add :: (file: &str) -> u64 {
        string.strip_leading_whitespace(file);
 
        left := parse_factor(file);
@@ -45,7 +45,7 @@ parse_expression_add :: (file: ^str) -> u64 {
        return left;
 }
 
-parse_expression_mul :: (file: ^str) -> u64 {
+parse_expression_mul :: (file: &str) -> u64 {
     string.strip_leading_whitespace(file);
 
        left := parse_expression_add(file);
@@ -71,7 +71,7 @@ main :: (args: [] cstr) {
 
        total: u64 = 0;
        while !string.empty(file) {
-               total += parse_expression_mul(^file);
+               total += parse_expression_mul(&file);
        }
 
        printf("Total: {}\n", total);
index 202e53a096d1678b4999ad82742cf37d2e2c1159..6d14bfb536de0b96d9b29285e6ab1aa90af38c5a 100644 (file)
@@ -32,32 +32,32 @@ Grammar :: struct {
     max_terminal     : u32;
 }
 
-grammar_init :: (use g: ^Grammar) {
-    array.init(^terminate_rules);
-    array.init(^unit_rules);
-    array.init(^production_rules);
+grammar_init :: (use g: &Grammar) {
+    array.init(&terminate_rules);
+    array.init(&unit_rules);
+    array.init(&production_rules);
 
     max_terminal = 0;
 }
 
-grammar_free :: (use g: ^Grammar) {
-    array.free(^terminate_rules);
-    array.free(^unit_rules);
-    array.free(^production_rules);
+grammar_free :: (use g: &Grammar) {
+    array.free(&terminate_rules);
+    array.free(&unit_rules);
+    array.free(&production_rules);
 }
 
-grammar_prepare :: (use g: ^Grammar) {
+grammar_prepare :: (use g: &Grammar) {
     // Not full-proof, but good enough for AOC.
-    for ^solo: unit_rules {
-        for ^prod: production_rules {
+    for &solo: unit_rules {
+        for &prod: production_rules {
             if prod.nt0 == solo.nt1 {
-                array.push(^production_rules, Prod.{ solo.nt0, prod.nt1, prod.nt2 });
+                array.push(&production_rules, Prod.{ solo.nt0, prod.nt1, prod.nt2 });
             }
         }
 
-        for ^unit: terminate_rules {
+        for &unit: terminate_rules {
             if unit.nt == solo.nt1 {
-                array.push(^terminate_rules, Term.{ solo.nt0, unit.t });
+                array.push(&terminate_rules, Term.{ solo.nt0, unit.t });
             } 
         }
     }
@@ -70,18 +70,18 @@ grammar_prepare :: (use g: ^Grammar) {
         terminate_rules[terminate_rules.count - 1].nt) + 1;
 }
 
-cyk_algorithm :: (use grammar: ^Grammar, input: str) -> bool {
+cyk_algorithm :: (use grammar: &Grammar, input: str) -> bool {
     dim_0 := input.count * max_terminal;
     dim_1 := max_terminal;
     dim_2 := 1;
 
     mem_size := sizeof bool * input.count * input.count * max_terminal;
-    T := cast(^bool) calloc(mem_size);
+    T := cast(&bool) calloc(mem_size);
     defer cfree(T);
     memory.set(T, ~~false, mem_size);
 
     for s: 0 .. input.count {
-        for ^term: terminate_rules {
+        for &term: terminate_rules {
             if term.t == input[s] {
                 T[0 * dim_0 + s * dim_1 + term.nt * dim_2] = true;
             }
@@ -91,7 +91,7 @@ cyk_algorithm :: (use grammar: ^Grammar, input: str) -> bool {
     for l: 1 .. input.count {
         for s: 0 .. input.count - l {
             for p: 1 .. l + 1 {
-                for ^prod: production_rules {
+                for &prod: production_rules {
                     if    T[(p - 1) * dim_0 + s       * dim_1 + prod.nt1 * dim_2]
                        && T[(l - p) * dim_0 + (s + p) * dim_1 + prod.nt2 * dim_2] {
                         T[l * dim_0 + s * dim_1 + prod.nt0 * dim_2] = true;
@@ -110,43 +110,43 @@ main :: (args: [] cstr) {
     file := contents;
 
     grammar : Grammar;
-    grammar_init(^grammar);
-    defer grammar_free(^grammar);
+    grammar_init(&grammar);
+    defer grammar_free(&grammar);
 
     while *file.data != #char "\n" {
-        nt0 := cast(u32, conv.parse_int(^file));
+        nt0 := cast(u32, conv.parse_int(&file));
 
-        string.advance(^file, 2); // ': '
+        string.advance(&file, 2); // ': '
 
         if *file.data == #char "\"" {
-            string.advance(^file, 1); // '"'
+            string.advance(&file, 1); // '"'
             t := file[0];
-            string.advance(^file, 1);
+            string.advance(&file, 1);
 
-            array.push(^grammar.terminate_rules, Term.{ nt0, t });
+            array.push(&grammar.terminate_rules, Term.{ nt0, t });
 
         } else {
             while true {
-                nt1 := cast(u32, conv.parse_int(^file));
+                nt1 := cast(u32, conv.parse_int(&file));
 
                 if *file.data == #char "\n" {
-                    array.push(^grammar.unit_rules, Unit.{ nt0, nt1 });
+                    array.push(&grammar.unit_rules, Unit.{ nt0, nt1 });
                     break;
 
                 } else {
-                    string.advance(^file, 1); // ' '
+                    string.advance(&file, 1); // ' '
 
                     if next_ch := *file.data; next_ch >= #char "0" && next_ch <= #char "9" {
-                        nt2 := cast(u32, conv.parse_int(^file));
-                        array.push(^grammar.production_rules, Prod.{ nt0, nt1, nt2 });
+                        nt2 := cast(u32, conv.parse_int(&file));
+                        array.push(&grammar.production_rules, Prod.{ nt0, nt1, nt2 });
 
-                        if *file.data == #char " " do string.advance(^file, 1);
+                        if *file.data == #char " " do string.advance(&file, 1);
                     } else {
-                        array.push(^grammar.unit_rules, Unit.{ nt0, nt1 });
+                        array.push(&grammar.unit_rules, Unit.{ nt0, nt1 });
                     }
 
                     if *file.data == #char "|" {
-                        string.advance(^file, 1); // ' |'
+                        string.advance(&file, 1); // ' |'
                     } else {
                         break;
                     }
@@ -154,16 +154,16 @@ main :: (args: [] cstr) {
             }
         }
 
-        string.advance_line(^file);
+        string.advance_line(&file);
     }
 
-    grammar_prepare(^grammar);
+    grammar_prepare(&grammar);
 
     valid_count := 0;
-    string.advance_line(^file);
+    string.advance_line(&file);
     while !string.empty(file) {
         line, file' := string.bisect(file, #char "\n");
-        if cyk_algorithm(^grammar, line) do valid_count += 1;
+        if cyk_algorithm(&grammar, line) do valid_count += 1;
     }
 
     printf("Valid count: {}\n", valid_count);
index 7f1ec0e0b9e3da8e74f762e59e22c41fc58da1ba..d523ac1a1e88e4b8e7c6a1129241724196722237 100644 (file)
@@ -11,17 +11,17 @@ main :: (args: [] cstr) {
 
     valid := 0;
 
-    while !io.reader_empty(^reader) {
-        lo := io.read_u32(^reader);
+    while !io.reader_empty(&reader) {
+        lo := io.read_u32(&reader);
 
-        io.read_byte(^reader);
-        hi := io.read_u32(^reader);
+        io.read_byte(&reader);
+        hi := io.read_u32(&reader);
 
-        io.read_byte(^reader);
-        ch := io.read_byte(^reader);
+        io.read_byte(&reader);
+        ch := io.read_byte(&reader);
 
-        io.skip_bytes(^reader, 2);
-        pw := io.read_line(^reader);
+        io.skip_bytes(&reader, 2);
+        pw := io.read_line(&reader);
 
         // Part 1
         // count := 0;
index 6c4bf7ed4f29a6f3659b9d41addc5d1d3ddeaefd..7a4eecd413d2d1c539f22a33c13d8a60b3054fd3 100644 (file)
@@ -66,7 +66,7 @@ reverse_binary :: (n_: u32, digits := TILE_DATA_WIDTH) -> u32 {
 
 build_edges :: (tile: [] bool, a := context.allocator) -> [] u32 {
        edges : [..] u32;
-    array.init(^edges, 8, allocator=a);
+    array.init(&edges, 8, allocator=a);
 
        for y: u32.[0, 9] {
                edge := 0;
@@ -75,7 +75,7 @@ build_edges :: (tile: [] bool, a := context.allocator) -> [] u32 {
                        if tile[x + y * TILE_DATA_WIDTH] do edge |= 1;
                }
 
-        array.push(^edges, edge);
+        array.push(&edges, edge);
        }       
 
        for x: u32.[0, 9] {
@@ -85,10 +85,10 @@ build_edges :: (tile: [] bool, a := context.allocator) -> [] u32 {
                        if tile[x + y * TILE_DATA_WIDTH] do edge |= 1;
                }
 
-        array.push(^edges, edge);
+        array.push(&edges, edge);
        }       
 
-       for i: 0 .. 4 do array.push(^edges, reverse_binary(edges[i]));
+       for i: 0 .. 4 do array.push(&edges, reverse_binary(edges[i]));
 
        return edges.data[0 .. 8];
 }
@@ -106,7 +106,7 @@ side_relations := ([4] TO).[
     TO.[ TO.R90,   TO.FR270, TO.F,     TO.R180,   ],
 ];
 
-has_matching_edges :: (t1: ^Tile, t2: ^Tile) -> bool {
+has_matching_edges :: (t1: &Tile, t2: &Tile) -> bool {
     match := false;
 
        for e_idx: 0 .. t1.edges.count / 2 do for e2_idx: 0 .. t2.edges.count {
@@ -126,7 +126,7 @@ has_matching_edges :: (t1: ^Tile, t2: ^Tile) -> bool {
 }
 
 // This assumes the `t` was in NORMAL orientation to begin with.
-apply_orientation :: (t: ^Tile, ori: TO) {
+apply_orientation :: (t: &Tile, ori: TO) {
     new_sides := t.edges_match;
 
     switch ori {
@@ -179,16 +179,16 @@ apply_orientation :: (t: ^Tile, ori: TO) {
     t.orientation = ori;
 }
 
-index_square_with_orientation :: (data: ^$T, ori: TO, size: i32, x: i32, y: i32) -> ^T {
+index_square_with_orientation :: (data: &$T, ori: TO, size: i32, x: i32, y: i32) -> &T {
     switch ori {
-        case TO.N     do return ^data[x + y * size];
-        case TO.R90   do return ^data[y + (size - 1 - x) * size];
-        case TO.R180  do return ^data[(size - 1 - x) + (size - 1 - y) * size];
-        case TO.R270  do return ^data[(size - 1 - y) + x * size];
-        case TO.F     do return ^data[x + (size - 1 - y) * size];
-        case TO.FR90  do return ^data[y + x * size];
-        case TO.FR180 do return ^data[(size - 1 - x) + y * size];
-        case TO.FR270 do return ^data[(size - 1 - y) + (size - 1 - x) * size];
+        case TO.N     do return &data[x + y * size];
+        case TO.R90   do return &data[y + (size - 1 - x) * size];
+        case TO.R180  do return &data[(size - 1 - x) + (size - 1 - y) * size];
+        case TO.R270  do return &data[(size - 1 - y) + x * size];
+        case TO.F     do return &data[x + (size - 1 - y) * size];
+        case TO.FR90  do return &data[y + x * size];
+        case TO.FR180 do return &data[(size - 1 - x) + y * size];
+        case TO.FR270 do return &data[(size - 1 - y) + (size - 1 - x) * size];
     }
 
     return null;
@@ -202,7 +202,7 @@ sea_monster := u8.[
     #char" ",#char"#",#char" ",#char" ",#char"#",#char" ",#char" ",#char"#",#char" ",#char" ",#char"#",#char" ",#char" ",#char"#",#char" ",#char" ",#char"#",#char" ",#char" ",#char" ",
 ];
 
-scan_for_monsters :: (forest: ^u8, ori: TO, width: u32, height: u32) -> bool {
+scan_for_monsters :: (forest: &u8, ori: TO, width: u32, height: u32) -> bool {
     found_monsters := false;
 
     for y: 0 .. height - sea_monster_height {
@@ -243,12 +243,12 @@ main :: (args: [] cstr) {
        file := contents;       
 
        tiles := array.make(Tile);
-       defer array.free(^tiles);
+       defer array.free(&tiles);
 
-    tile_map := map.make(u32, ^Tile, null);
-    defer map.free(^tile_map);
+    tile_map := map.make(u32, &Tile, null);
+    defer map.free(&tile_map);
 
-       tile_data := cast(^TileData) calloc(200 * sizeof TileData);
+       tile_data := cast(&TileData) calloc(200 * sizeof TileData);
        defer cfree(tile_data);
        
     // This ring allocator could technically overflow and start
@@ -256,15 +256,15 @@ main :: (args: [] cstr) {
     // should be more than enough space in the allocator to not
     // run into that problem... Hopefully.
        tile_data_ring := alloc.ring.make(.{ ~~ tile_data, 200 * sizeof TileData });
-       tile_allocator := alloc.ring.make_allocator(^tile_data_ring);
+       tile_allocator := alloc.ring.make_allocator(&tile_data_ring);
 
        while !string.empty(file) {
-               string.advance(^file, 5); // 'Tile '
-               id := cast(u32, conv.parse_int(^file));
+               string.advance(&file, 5); // 'Tile '
+               id := cast(u32, conv.parse_int(&file));
 
-               string.advance_line(^file);
+               string.advance_line(&file);
 
-               td := cast(^bool) raw_alloc(tile_allocator, sizeof TileData);
+               td := cast(&bool) raw_alloc(tile_allocator, sizeof TileData);
 
                for y: 0 .. 10 {
                        line, file' := string.bisect(file, #char "\n");
@@ -277,17 +277,17 @@ main :: (args: [] cstr) {
                tile_data := td[0 .. TILE_DATA_HEIGHT * TILE_DATA_WIDTH];
                edges := build_edges(tile_data, tile_allocator);
 
-               array.push(^tiles, .{
+               array.push(&tiles, .{
                        id = id,
                        orientation = TO.N,
                        data = tile_data,
                        edges = edges,
                });
 
-               string.advance_line(^file);
+               string.advance_line(&file);
        }
 
-    for ^t: tiles do map.put(^tile_map, t.id, t);
+    for &t: tiles do map.put(&tile_map, t.id, t);
 
        prod: u64 = 1;
     top_left_id := 0;
@@ -297,7 +297,7 @@ main :: (args: [] cstr) {
 
                for j: 0 .. tiles.count {
                        if i == j do continue;
-                       if has_matching_edges(^tiles[i], ^tiles[j]) {
+                       if has_matching_edges(&tiles[i], &tiles[j]) {
                                matching_count += 1;
                        }
                }
@@ -315,7 +315,7 @@ main :: (args: [] cstr) {
        printf("Corner product: {}\n", prod);
 
     grid : [12 * 12] u32;
-    memory.set(^grid, 0, sizeof [12 * 12] u32);
+    memory.set(&grid, 0, sizeof [12 * 12] u32);
 
     tile_pos_state :: struct {
         match   : SideRelation;
@@ -323,36 +323,36 @@ main :: (args: [] cstr) {
         pos_y   : i32;
     }
     to_process := array.make(tile_pos_state);
-    defer array.free(^to_process);
+    defer array.free(&to_process);
     
-    array.push(^to_process, .{ .{ top_left_id, TO.F }, 0, 0 });
+    array.push(&to_process, .{ .{ top_left_id, TO.F }, 0, 0 });
     while to_process.count > 0 {
         tid := to_process[0];
-        array.delete(^to_process, 0);
+        array.delete(&to_process, 0);
 
         if grid[tid.pos_x + 12 * tid.pos_y] != 0 do continue;
         
-        tile_ptr := map.get(^tile_map, tid.match.tile);
+        tile_ptr := map.get(&tile_map, tid.match.tile);
         tile_ptr.pos_x = tid.pos_x;
         tile_ptr.pos_y = tid.pos_y;
         grid[tid.pos_x + 12 * tid.pos_y] = tid.match.tile;
 
         apply_orientation(tile_ptr, tid.match.ori);
 
-        if tile_ptr.edges_match.top.tile    != 0 do array.push(^to_process, .{ tile_ptr.edges_match.top,    tid.pos_x, tid.pos_y - 1 });
-        if tile_ptr.edges_match.bottom.tile != 0 do array.push(^to_process, .{ tile_ptr.edges_match.bottom, tid.pos_x, tid.pos_y + 1 });
-        if tile_ptr.edges_match.left.tile   != 0 do array.push(^to_process, .{ tile_ptr.edges_match.left,   tid.pos_x - 1, tid.pos_y });
-        if tile_ptr.edges_match.right.tile  != 0 do array.push(^to_process, .{ tile_ptr.edges_match.right,  tid.pos_x + 1, tid.pos_y });
+        if tile_ptr.edges_match.top.tile    != 0 do array.push(&to_process, .{ tile_ptr.edges_match.top,    tid.pos_x, tid.pos_y - 1 });
+        if tile_ptr.edges_match.bottom.tile != 0 do array.push(&to_process, .{ tile_ptr.edges_match.bottom, tid.pos_x, tid.pos_y + 1 });
+        if tile_ptr.edges_match.left.tile   != 0 do array.push(&to_process, .{ tile_ptr.edges_match.left,   tid.pos_x - 1, tid.pos_y });
+        if tile_ptr.edges_match.right.tile  != 0 do array.push(&to_process, .{ tile_ptr.edges_match.right,  tid.pos_x + 1, tid.pos_y });
     }
 
     forest : [12 * 8 * 12 * 8] u8;
     for y: 0 .. 12 {
         for x: 0 .. 12 {
-            tile := map.get(^tile_map, grid[y * 12 + x]);
+            tile := map.get(&tile_map, grid[y * 12 + x]);
 
             for fy: 0 .. 8 {
                 for fx: 0 .. 8 {
-                    res := *index_square_with_orientation(cast(^bool) tile.data.data, tile.orientation, 10, fx + 1, fy + 1);
+                    res := *index_square_with_orientation(cast(&bool) tile.data.data, tile.orientation, 10, fx + 1, fy + 1);
                     loc := (y * 12 * 8 * 8) + (fy * 12 * 8) + (x * 8) + fx;
                     if res do forest[loc] = #char "#";
                     else   do forest[loc] = #char ".";
@@ -362,7 +362,7 @@ main :: (args: [] cstr) {
     }
 
     for ori: .[ TO.N, TO.R90, TO.R180, TO.R270, TO.F, TO.FR90, TO.FR180, TO.FR270 ] {
-        if scan_for_monsters(cast(^u8) forest, ori, 12 * 8, 12 * 8) do break;
+        if scan_for_monsters(cast(&u8) forest, ori, 12 * 8, 12 * 8) do break;
     }
     
     safe_count := 0;
index 6e1c6c037e8262a693f5275555ba46601058aede..33abd5f9a0008866dbeecd9a9bc6ab92308acdfe 100644 (file)
@@ -35,110 +35,110 @@ main :: (args: [] cstr) {
 
        file := contents;
 
-    map.init(^ingredient_map, .{});
-    map.init(^allergen_map, .{});
+    map.init(&ingredient_map, .{});
+    map.init(&allergen_map, .{});
     defer {
-        map.free(^ingredient_map);
-        map.free(^allergen_map);
+        map.free(&ingredient_map);
+        map.free(&allergen_map);
     }
 
     foods := array.make(Food);
-    defer array.free(^foods);
+    defer array.free(&foods);
 
     line_num := 0;
        while !string.empty(file) {
         food : Food;
-        array.init(^food.ingredients, 16);
-        array.init(^food.allergens);
+        array.init(&food.ingredients, 16);
+        array.init(&food.allergens);
 
         while *file.data != #char "(" {
-            ingredient_name := string.read_alphanum(^file);
-            string.advance(^file, 1); // ' '
+            ingredient_name := string.read_alphanum(&file);
+            string.advance(&file, 1); // ' '
 
-            array.push(^food.ingredients, ingredient_name);
+            array.push(&food.ingredients, ingredient_name);
 
-            ingredient := map.get(^ingredient_map, ingredient_name);
+            ingredient := map.get(&ingredient_map, ingredient_name);
             if ingredient.name.data == null {
                 ingredient.name = ingredient_name;
-                array.init(^ingredient.appears_on, 4);
+                array.init(&ingredient.appears_on, 4);
             }
 
-            array.push(^ingredient.appears_on, line_num);
+            array.push(&ingredient.appears_on, line_num);
 
-            map.put(^ingredient_map, ingredient_name, ingredient);
+            map.put(&ingredient_map, ingredient_name, ingredient);
         }
 
-        string.advance(^file, 10); // '(contains '
+        string.advance(&file, 10); // '(contains '
 
         while *file.data != #char ")" {
-            allergen_name := string.read_alphanum(^file);
-            if *file.data == #char "," do string.advance(^file, 2); // ', '
+            allergen_name := string.read_alphanum(&file);
+            if *file.data == #char "," do string.advance(&file, 2); // ', '
 
-            array.push(^food.allergens, allergen_name);
+            array.push(&food.allergens, allergen_name);
 
-            allergen := map.get(^allergen_map, allergen_name);
+            allergen := map.get(&allergen_map, allergen_name);
             if allergen.name.data == null {
                 allergen.name = allergen_name;
-                array.init(^allergen.appears_on, 4);
+                array.init(&allergen.appears_on, 4);
             }
 
-            array.push(^allergen.appears_on, line_num);
+            array.push(&allergen.appears_on, line_num);
 
-            map.put(^allergen_map, allergen_name, allergen);
+            map.put(&allergen_map, allergen_name, allergen);
         }
 
-        array.push(^foods, food);
+        array.push(&foods, food);
         
-        string.advance_line(^file);
+        string.advance_line(&file);
         line_num += 1;
        }
 
     definitely_safe := array.make(str);
-    defer array.free(^definitely_safe);
+    defer array.free(&definitely_safe);
 
-    for ^ingredient_entry: ingredient_map.entries {
+    for &ingredient_entry: ingredient_map.entries {
         potential_allergens := array.make(str);
-        defer array.free(^potential_allergens);
+        defer array.free(&potential_allergens);
 
         for food_num: ingredient_entry.value.appears_on {
-            for ^allergen_name: foods[food_num].allergens {
-                array.push(^potential_allergens, *allergen_name);
+            for &allergen_name: foods[food_num].allergens {
+                array.push(&potential_allergens, *allergen_name);
             }
         }
 
         potential_allergen_count := 0;
-        for ^allergen_name: potential_allergens {
-            c := array_count_contains(^potential_allergens, *allergen_name, string.equal);
-            allergen := map.get(^allergen_map, *allergen_name); 
+        for &allergen_name: potential_allergens {
+            c := array_count_contains(&potential_allergens, *allergen_name, string.equal);
+            allergen := map.get(&allergen_map, *allergen_name); 
             if c == allergen.appears_on.count {
                 potential_allergen_count += 1;
             }
         }
 
         if potential_allergen_count == 0 {
-            array.push(^definitely_safe, ingredient_entry.key);
+            array.push(&definitely_safe, ingredient_entry.key);
         }
     }
 
     total_safe := 0;
     for safe: definitely_safe {
-        ingredient := map.get(^ingredient_map, safe);
+        ingredient := map.get(&ingredient_map, safe);
         total_safe += ingredient.appears_on.count;
 
-        map.delete(^ingredient_map, safe);
+        map.delete(&ingredient_map, safe);
     }
 
     printf("Total safe: {}\n", total_safe);
 
     matched_ingredients := array.make(Ingredient);
-    defer array.free(^matched_ingredients);
+    defer array.free(&matched_ingredients);
 
-    while !map.empty(^ingredient_map) {
-        for ^allergen_entry: allergen_map.entries {
+    while !map.empty(&ingredient_map) {
+        for &allergen_entry: allergen_map.entries {
             match_count := 0;
             matching_ingredient_name := str.{ null, 0 };
 
-            for ^ingredient_entry: ingredient_map.entries {
+            for &ingredient_entry: ingredient_map.entries {
                 matches := true;
 
                 for ap: allergen_entry.value.appears_on {
@@ -152,24 +152,24 @@ main :: (args: [] cstr) {
             }
 
             if match_count == 1 {
-                ingredient := map.get(^ingredient_map, matching_ingredient_name);
-                map.delete(^ingredient_map, matching_ingredient_name);
+                ingredient := map.get(&ingredient_map, matching_ingredient_name);
+                map.delete(&ingredient_map, matching_ingredient_name);
 
                 ingredient.allergen = allergen_entry.key;
-                array.push(^matched_ingredients, ingredient);
+                array.push(&matched_ingredients, ingredient);
             }
         }
     }
 
-    array.sort(matched_ingredients, (i1: ^Ingredient, i2: ^Ingredient) => string.compare(i1.allergen, i2.allergen));
+    array.sort(matched_ingredients, (i1: &Ingredient, i2: &Ingredient) => string.compare(i1.allergen, i2.allergen));
 
-    for ^mi: matched_ingredients do printf("{} -> {}\n", mi.name, mi.allergen);
-    for ^mi: matched_ingredients do printf("{},", mi.name);
+    for &mi: matched_ingredients do printf("{} -> {}\n", mi.name, mi.allergen);
+    for &mi: matched_ingredients do printf("{},", mi.name);
     println("\n(Don't copy the last ','!)");
 }
 
-array_count_contains :: (arr: ^[..] $T, x: T, equal: (T, T) -> bool) -> u32 {
+array_count_contains :: (arr: &[..] $T, x: T, equal: (T, T) -> bool) -> u32 {
     count := 0;
-    for ^it: *arr do if equal(*it, x) do count += 1;
+    for &it: *arr do if equal(*it, x) do count += 1;
     return count;
 }
index 3dcc7c9569bb75097e85b34d62316dd147248313..ab98c9de4f48395c00070752bcd3c5feff4344bb 100644 (file)
@@ -5,7 +5,7 @@ use package core
 key_arena : alloc.arena.ArenaState;
 key_alloc : Allocator;
 
-score_player :: (p: ^[..] u32) -> u32 {
+score_player :: (p: &[..] u32) -> u32 {
     count := 0;
     mul := p.count;
     for c: *p {
@@ -15,7 +15,7 @@ score_player :: (p: ^[..] u32) -> u32 {
     return count;
 }
 
-combat :: (player1: ^[..] u32, player2: ^[..] u32) -> u32 {
+combat :: (player1: &[..] u32, player2: &[..] u32) -> u32 {
     while player1.count > 0 && player2.count > 0 {
         p1 := player1.data[0];
         p2 := player2.data[0];
@@ -41,31 +41,31 @@ combat :: (player1: ^[..] u32, player2: ^[..] u32) -> u32 {
 // into:
 //   4,5,2,8,|1,3,9,7,
 // Larger numbers are encoded in base 64.
-encode_hands :: (alloc: Allocator, p1: ^[..] u32, p2: ^[..] u32) -> str {
+encode_hands :: (alloc: Allocator, p1: &[..] u32, p2: &[..] u32) -> str {
     stream := io.buffer_stream_make(256, alloc);
-    writer := io.writer_make(^stream, 0);
+    writer := io.writer_make(&stream, 0);
 
     for n: *p1 {
-        io.write_i64(^writer, ~~n, 64);
-        io.write_str(^writer, ",");
+        io.write_i64(&writer, ~~n, 64);
+        io.write_str(&writer, ",");
     }
-    io.write_str(^writer, "|");
+    io.write_str(&writer, "|");
     for n: *p2 {
-        io.write_i64(^writer, ~~n, 64);
-        io.write_str(^writer, ",");
+        io.write_i64(&writer, ~~n, 64);
+        io.write_str(&writer, ",");
     }
 
-    return io.buffer_stream_to_str(^stream);
+    return io.buffer_stream_to_str(&stream);
 }
 
-recursive_combat :: (player1: ^[..] u32, player2: ^[..] u32) -> u32 {
+recursive_combat :: (player1: &[..] u32, player2: &[..] u32) -> u32 {
     hand_seen := map.make(str, bool, false);
-    defer map.free(^hand_seen);
+    defer map.free(&hand_seen);
 
     while player1.count > 0 && player2.count > 0 {
         enc_hand := encode_hands(key_alloc, player1, player2);
-        if map.has(^hand_seen, enc_hand) do return 1;
-        map.put(^hand_seen, enc_hand, true);
+        if map.has(&hand_seen, enc_hand) do return 1;
+        map.put(&hand_seen, enc_hand, true);
 
         p1 := player1.data[0];
         p2 := player2.data[0];
@@ -77,10 +77,10 @@ recursive_combat :: (player1: ^[..] u32, player2: ^[..] u32) -> u32 {
         if player1.count >= p1 && player2.count >= p2 {
             p1_copy := array.copy_range(player1, 0 .. p1);
             p2_copy := array.copy_range(player2, 0 .. p2);
-            defer array.free(^p1_copy);
-            defer array.free(^p2_copy);
+            defer array.free(&p1_copy);
+            defer array.free(&p2_copy);
 
-            round_win = recursive_combat(^p1_copy, ^p2_copy);
+            round_win = recursive_combat(&p1_copy, &p2_copy);
         } else {
             if p1 > p2 do round_win = 1;
             else       do round_win = 2;
@@ -106,50 +106,50 @@ main :: (args: [] cstr) {
 
     player1 := array.make(u32);
     player2 := array.make(u32);
-    defer array.free(^player1);
-    defer array.free(^player2);
+    defer array.free(&player1);
+    defer array.free(&player2);
 
-    string.advance_line(^file); // 'Player 1:'
+    string.advance_line(&file); // 'Player 1:'
     while *file.data != #char "\n" {
-        card := cast(u32, conv.parse_int(^file));
-        array.push(^player1, card);
+        card := cast(u32, conv.parse_int(&file));
+        array.push(&player1, card);
 
-        string.advance_line(^file);
+        string.advance_line(&file);
     }
 
-    string.advance_line(^file); // '\n'
-    string.advance_line(^file); // 'Player 2:'
+    string.advance_line(&file); // '\n'
+    string.advance_line(&file); // 'Player 2:'
     while !string.empty(file) {
-        card := cast(u32, conv.parse_int(^file));
-        array.push(^player2, card);
+        card := cast(u32, conv.parse_int(&file));
+        array.push(&player2, card);
 
-        string.advance_line(^file);
+        string.advance_line(&file);
     }
 
     {
-        player1_copy := array.copy(^player1);
-        player2_copy := array.copy(^player2);
-        defer array.free(^player1_copy);
-        defer array.free(^player2_copy);
+        player1_copy := array.copy(&player1);
+        player2_copy := array.copy(&player2);
+        defer array.free(&player1_copy);
+        defer array.free(&player2_copy);
 
-        combat_score := combat(^player1_copy, ^player2_copy);
+        combat_score := combat(&player1_copy, &player2_copy);
         printf("Answer: {}\n", combat_score);
     }
 
     #if false {
         key_arena = alloc.arena.make(context.allocator, 1 << 14);
-        key_alloc = alloc.arena.make_allocator(^key_arena);
+        key_alloc = alloc.arena.make_allocator(&key_arena);
 
-        player1_copy := array.copy(^player1);
-        player2_copy := array.copy(^player2);
-        defer array.free(^player1_copy);
-        defer array.free(^player2_copy);
+        player1_copy := array.copy(&player1);
+        player2_copy := array.copy(&player2);
+        defer array.free(&player1_copy);
+        defer array.free(&player2_copy);
 
-        winner := recursive_combat(^player1_copy, ^player2_copy);
+        winner := recursive_combat(&player1_copy, &player2_copy);
 
         score : u32;
-        if winner == 1 do score = score_player(^player1_copy);
-        if winner == 2 do score = score_player(^player2_copy);
+        if winner == 1 do score = score_player(&player1_copy);
+        if winner == 2 do score = score_player(&player2_copy);
 
         printf("Recursive answer: {}\n", score);
     }
index b51cf013b71c5cc2de14c0aeaaab79fcb40a6aaa..6440e6ddc0ade53e580fae6920fb9dcd32fb1ccd 100644 (file)
@@ -56,25 +56,25 @@ main :: (args: [] cstr) {
     cups_data := i32.[ 9, 6, 2, 7, 1, 3, 8, 5, 4 ];
 
     // Easier think about in zero-indexed
-    for ^cup: cups_data do *cup -= 1;
+    for &cup: cups_data do *cup -= 1;
 
-    array.init(^cups, 1000000);
-    defer array.free(^cups);
+    array.init(&cups, 1000000);
+    defer array.free(&cups);
 
-    for cup: cups_data do array.push(^cups, cup);
+    for cup: cups_data do array.push(&cups, cup);
 
     // Part 1
-    // simulate(array.to_slice(^cups));
+    // simulate(array.to_slice(&cups));
     
     // Part 2
-    for i: 9 .. 1000000 do array.push(^cups, i);
+    for i: 9 .. 1000000 do array.push(&cups, i);
     simulate(cups, 10000000);
 
     // Undo the zero-indexing
-    for ^cup: cups do *cup += 1;
+    for &cup: cups do *cup += 1;
 
     // Part 1
-    // one_idx := get_idx(array.to_slice(^cups), 1);
+    // one_idx := get_idx(array.to_slice(&cups), 1);
     // for i: 1 .. 9 {
     //     printf("{}", cast(i32) cups[w(one_idx + i)]);
     // }
index 47a534cb6f2df2001ae871b0f55ca3883fb07369..06367a2de280c131081021367d90adaede5c7347 100644 (file)
@@ -29,13 +29,13 @@ main :: (args: [] cstr) {
        contents := #file_contents "./tests/aoc-2020/input/day24.txt";
 
     file_stream := io.buffer_stream_make(contents);
-       file := io.reader_make(^file_stream);
+       file := io.reader_make(&file_stream);
 
        grid := map.make(Vec2, Cell, .{}); // `true` is black
-       defer map.free(^grid);
+       defer map.free(&grid);
 
-       while !io.reader_empty(^file) {
-               line := io.read_line(^file);
+       while !io.reader_empty(&file) {
+               line := io.read_line(&file);
 
                loc := Vec2.{ 0, 0 };
                s := 0;
@@ -65,28 +65,28 @@ main :: (args: [] cstr) {
                }
 
 
-               curr := map.get(^grid, loc);
-               map.put(^grid, loc, .{ alive = !curr.alive });
+               curr := map.get(&grid, loc);
+               map.put(&grid, loc, .{ alive = !curr.alive });
        }
 
        // Part 1
        black_count := 0;
-       for ^cell: grid.entries {
+       for &cell: grid.entries {
                if cell.value.alive do black_count += 1;
        }       
        printf("Black count: {}\n", black_count);
 
        // Part 2
        cells_to_consider := array.make(Vec2);
-       defer array.free(^cells_to_consider);
+       defer array.free(&cells_to_consider);
 
        for i: 0 .. 100 {
-               for ^cell: grid.entries {
+               for &cell: grid.entries {
                        if cell.value.alive {
-                               array.push(^cells_to_consider, cell.key);
+                               array.push(&cells_to_consider, cell.key);
 
-                               for ^dir: Hex_Directions {
-                                       array.push(^cells_to_consider, .{
+                               for &dir: Hex_Directions {
+                                       array.push(&cells_to_consider, .{
                                                x = cell.key.x + dir.x,
                                                y = cell.key.y + dir.y,
                                        });
@@ -94,9 +94,9 @@ main :: (args: [] cstr) {
                        }
                }
 
-               for ^cell: cells_to_consider {
-                       state  := map.get(^grid, *cell);
-                       ncount := get_neighbor_count(^grid, *cell);
+               for &cell: cells_to_consider {
+                       state  := map.get(&grid, *cell);
+                       ncount := get_neighbor_count(&grid, *cell);
 
                        if state.alive {
                                state.next = ncount == 1 || ncount == 2;
@@ -104,27 +104,27 @@ main :: (args: [] cstr) {
                                state.next = ncount == 2;
                        }
 
-                       map.put(^grid, *cell, state);
+                       map.put(&grid, *cell, state);
                }
 
-               for ^cell: cells_to_consider {
-                       map.update(^grid, *cell, #quote { it.alive = it.next; });
+               for &cell: cells_to_consider {
+                       map.update(&grid, *cell, #quote { it.alive = it.next; });
                }
 
-               array.clear(^cells_to_consider);
+               array.clear(&cells_to_consider);
        }
 
        black_count = 0;
-       for ^cell: grid.entries {
+       for &cell: grid.entries {
                if cell.value.alive do black_count += 1;
        }       
        printf("GOL black count: {}\n", black_count);
 }
 
-get_neighbor_count :: (grid: ^map.Map(Vec2, Cell), pos: Vec2) -> u32 {
+get_neighbor_count :: (grid: &map.Map(Vec2, Cell), pos: Vec2) -> u32 {
        count := 0;
 
-       for ^dir: Hex_Directions {
+       for &dir: Hex_Directions {
                cell := map.get(grid, Vec2.{ x = pos.x + dir.x, y = pos.y + dir.y });
                if cell.alive do count += 1;
        }
index 75a5904979fce49c2a367151f2faeb87ce5d93cc..60f7fee3a175cd53c97eb772793a6e07026e3b29 100644 (file)
@@ -22,11 +22,11 @@ dlp_bsgs :: (n: u32, a: u32, b: u32) -> u32 {
     m := cast(u32) math.ceil(math.sqrt(cast(f64) n));
 
     t := map.make(u32, u32, default=0);
-    defer map.free(^t);
+    defer map.free(&t);
 
     tmp: u64 = 1;
     for i: 0 .. m {
-        map.put(^t, ~~tmp, i);
+        map.put(&t, ~~tmp, i);
         tmp = (tmp * ~~a) % ~~n;
     }
 
@@ -34,8 +34,8 @@ dlp_bsgs :: (n: u32, a: u32, b: u32) -> u32 {
 
     tmp = ~~b;
     for i: 0 .. m {
-        if map.has(^t, ~~tmp) {
-            v := map.get(^t, ~~tmp);
+        if map.has(&t, ~~tmp) {
+            v := map.get(&t, ~~tmp);
             return i * m + v; 
         }
 
@@ -56,8 +56,8 @@ main :: (args: [] cstr) {
 
     file := contents;
 
-    card_pub_key := cast(u32, conv.parse_int(^file));
-    door_pub_key := cast(u32, conv.parse_int(^file));
+    card_pub_key := cast(u32, conv.parse_int(&file));
+    door_pub_key := cast(u32, conv.parse_int(&file));
 
     card_loop_secret := dlp_bsgs(20201227, 7, card_pub_key);
     door_loop_secret := dlp_bsgs(20201227, 7, door_pub_key);
index ad082a60f69e0ab16ceafee949ae77022199cf56..7eb37a47f10f8bf0a278d2a326d964175b530e4b 100644 (file)
@@ -19,19 +19,19 @@ main :: (args: [] cstr) {
     contents := #file_contents "./tests/aoc-2020/input/day3.txt";
 
     forest := array.make(u8, 1024);
-    defer array.free(^forest);
+    defer array.free(&forest);
 
     width := 0;
     height := 0;
     while true {
-        line := string.read_until(^contents, #char "\n");
-        string.advance(^contents, 1);
+        line := string.read_until(&contents, #char "\n");
+        string.advance(&contents, 1);
         if line.count == 0 do break;
 
         width = line.count;
         height = height + 1;
 
-        for ch: line do array.push(^forest, ch);
+        for ch: line do array.push(&forest, ch);
     }
 
     lis := LineInterp.[
index 6b70058a0d3870f05396d641b8b2969ba6b64276..bb2a01db25b1934b67a2599256c2ff19ba8c6b49 100644 (file)
@@ -3,7 +3,7 @@
 use package core
 
 // Returns the number of fields
-process_passport :: (contents: ^str) -> u32 {
+process_passport :: (contents: &str) -> u32 {
     field_count := 0;
 
     while true {
@@ -36,7 +36,7 @@ main :: (args: [] cstr) {
     while true {
         if contents.count == 0 do break;
 
-        field_count := process_passport(^contents);
+        field_count := process_passport(&contents);
         if field_count == 7 do valid_passports += 1;
     }
 
index 98bc6f369333066ce83d59b8344f25fa62bd7747..b2adef1964f685bbd6b637716ad1a37115e2ee20 100644 (file)
@@ -6,13 +6,13 @@ main :: (args: [] cstr) {
     contents := #file_contents "./tests/aoc-2020/input/day5.txt";
 
     vals := array.make(u32);
-    defer array.free(^vals);
+    defer array.free(&vals);
 
     max_val := 0;
 
     while true {
-        line := string.read_until(^contents, #char "\n");
-        string.advance(^contents);
+        line := string.read_until(&contents, #char "\n");
+        string.advance(&contents);
         if line.count == 0 do break;
 
         val := 0;
@@ -22,7 +22,7 @@ main :: (args: [] cstr) {
         }
 
         max_val = math.max(max_val, val);
-        array.push(^vals, val);
+        array.push(&vals, val);
     }
 
     missing := 0;
index a034bbca54d818a0cb717ecd841caf8ce0148ee0..c79d69a4143cbfa7e35b7a66cccc9e018b19c79c 100644 (file)
@@ -2,9 +2,9 @@
 
 use package core
 
-part_1 :: (contents: ^str) -> u32 {
+part_1 :: (contents: &str) -> u32 {
     chars : [26] bool;
-    for ^ch: chars do *ch = false;
+    for &ch: chars do *ch = false;
 
     while true {
         line := string.read_until(contents, #char "\n");
@@ -20,9 +20,9 @@ part_1 :: (contents: ^str) -> u32 {
     return sum;
 }
 
-part_2 :: (contents: ^str) -> u32 {
+part_2 :: (contents: &str) -> u32 {
     chars : [26] u32;
-    for ^ch: chars do *ch = 0;
+    for &ch: chars do *ch = 0;
 
     person_count := 0;
     while true {
@@ -48,7 +48,7 @@ main :: (args: [] cstr) {
     while true {
         if contents.count == 0 do break;
 
-        unique := part_1(^contents);
+        unique := part_1(&contents);
         unique_sum += unique;
     }
 
index 5cea2f585a300bd144dd15c125dd73db8a2ea6af..fb9055e37de0aec11b9fd4fdcf23ef6b9ac00746 100644 (file)
@@ -3,8 +3,8 @@
 use package core
 
 BagGraph :: struct {
-    nodes    : [..] ^BagNode;
-    node_map : map.Map(str, ^BagNode);
+    nodes    : [..] &BagNode;
+    node_map : map.Map(str, &BagNode);
 }
 
 BagNode :: struct {
@@ -17,33 +17,33 @@ BagNode :: struct {
 }
 
 BagContainment :: struct {
-    bag : ^BagNode;
+    bag : &BagNode;
     count : u32;
 }
 
-bg_init :: (use graph: ^BagGraph) {
-    array.init(^nodes, 16);
-    map.init(^node_map, null);
+bg_init :: (use graph: &BagGraph) {
+    array.init(&nodes, 16);
+    map.init(&node_map, null);
 }
 
-bg_free :: (use graph: ^BagGraph) {
-    array.free(^nodes);
-    map.free(^node_map);
+bg_free :: (use graph: &BagGraph) {
+    array.free(&nodes);
+    map.free(&node_map);
 }
 
-bg_get_node :: (use graph: ^BagGraph, name: str) -> ^BagNode {
-    node := map.get(^node_map, name);
+bg_get_node :: (use graph: &BagGraph, name: str) -> &BagNode {
+    node := map.get(&node_map, name);
 
     if node == null {
         node = calloc(sizeof BagNode);
         // Part 1
-        // array.init(^node.contained_in, 2);
+        // array.init(&node.contained_in, 2);
         // Part 2
-        array.init(^node.contain, 2);
+        array.init(&node.contain, 2);
         node.color = name;
 
-        array.push(^nodes, node);
-        map.put(^node_map, node.color, node);
+        array.push(&nodes, node);
+        map.put(&node_map, node.color, node);
     }
 
     return node;
@@ -55,58 +55,58 @@ main :: (args: [] cstr) {
     file := contents;
 
     graph : BagGraph;
-    bg_init(^graph);
-    defer bg_free(^graph);
+    bg_init(&graph);
+    defer bg_free(&graph);
 
     while true {
-        name := string.read_until(^file, #char " ", 1);
+        name := string.read_until(&file, #char " ", 1);
         if name.count == 0 do break;
 
-        container := bg_get_node(^graph, name);
+        container := bg_get_node(&graph, name);
 
-        string.read_until(^file, #char " ", 2);
+        string.read_until(&file, #char " ", 2);
 
         while true {
             if string.starts_with(file, " no") do break;
 
-            count := cast(u32, conv.parse_int(^file));
-            string.advance(^file, 1);
+            count := cast(u32, conv.parse_int(&file));
+            string.advance(&file, 1);
 
-            contained_name := string.read_until(^file, #char " ", 1);
-            contained := bg_get_node(^graph, contained_name);
+            contained_name := string.read_until(&file, #char " ", 1);
+            contained := bg_get_node(&graph, contained_name);
 
             // Part 1
-            // array.push(^contained.contained_in, BagContainment.{
+            // array.push(&contained.contained_in, BagContainment.{
             //     bag = container,
             //     count = count
             // });
 
             // Part 2
-            array.push(^container.contain, .{ bag = contained, count = count });
+            array.push(&container.contain, .{ bag = contained, count = count });
 
-            bag_word := string.read_until_any(^file, 1, #char " ", #char "\n");
+            bag_word := string.read_until_any(&file, 1, #char " ", #char "\n");
             if bag_word[bag_word.count - 1] == #char "." do break;
         }
 
-        string.advance_line(^file);
+        string.advance_line(&file);
     }
 
     // Part 1
-    // to_process_bags : [..] ^BagNode;
-    // processed_bags: [..] ^BagNode;
+    // to_process_bags : [..] &BagNode;
+    // processed_bags: [..] &BagNode;
 
-    // array.init(^to_process_bags);
-    // array.init(^processed_bags, 32);
-    // array.push(^to_process_bags, bg_get_node(^graph, "shiny gold"));
+    // array.init(&to_process_bags);
+    // array.init(&processed_bags, 32);
+    // array.push(&to_process_bags, bg_get_node(&graph, "shiny gold"));
 
     // while to_process_bags.count > 0 {
-    //     bag := array.pop(^to_process_bags);
-    //     array.push(^processed_bags, bag);
+    //     bag := array.pop(&to_process_bags);
+    //     array.push(&processed_bags, bag);
     //     
     //     for container: bag.contained_in {
-    //         if !array.contains(^processed_bags, container.bag) && !array.contains(^to_process_bags, container.bag) {
+    //         if !array.contains(&processed_bags, container.bag) && !array.contains(&to_process_bags, container.bag) {
     //             // printf("Adding {} to process.\n", container.bag.color);
-    //             array.push(^to_process_bags, container.bag);
+    //             array.push(&to_process_bags, container.bag);
     //         }
     //     }
     // }
@@ -114,20 +114,20 @@ main :: (args: [] cstr) {
     // printf("Count: {}\n", processed_bags.count - 1);
     
     // Part 2
-    to_process := array.make(^BagNode);
+    to_process := array.make(&BagNode);
     multiplier := array.make(u32);
-    array.push(^to_process, bg_get_node(^graph, "shiny gold"));
-    array.push(^multiplier, 1);
+    array.push(&to_process, bg_get_node(&graph, "shiny gold"));
+    array.push(&multiplier, 1);
 
     count := 0;
     while to_process.count > 0 {
-        bag := array.pop(^to_process);
-        mul := array.pop(^multiplier);
+        bag := array.pop(&to_process);
+        mul := array.pop(&multiplier);
         count += mul;
 
         for bc: bag.contain {
-            array.push(^to_process, bc.bag);
-            array.push(^multiplier, bc.count * mul);
+            array.push(&to_process, bc.bag);
+            array.push(&multiplier, bc.count * mul);
         }
     }
 
index 842c4cd2e56b3a0d1befcb9e3ca667f0278611c3..e9e1bd6e764935dcf99b1771202c3f55d27bc4d0 100644 (file)
@@ -12,9 +12,9 @@ Instruction :: struct {
 }
 
 // Returns if the program successfully exited.
-get_acc_value :: (instrs: [..] Instruction, ret_acc: ^i32) -> bool {
+get_acc_value :: (instrs: [..] Instruction, ret_acc: &i32) -> bool {
     already_been := map.make(i32, bool, false);
-    defer map.free(^already_been);
+    defer map.free(&already_been);
 
     ip   := 0;
     acc  := 0;
@@ -25,8 +25,8 @@ get_acc_value :: (instrs: [..] Instruction, ret_acc: ^i32) -> bool {
             break;
         }
         
-        if map.has(^already_been, ip) do break;
-        map.put(^already_been, ip, true);
+        if map.has(&already_been, ip) do break;
+        map.put(&already_been, ip, true);
 
         switch instrs[ip].opcode {
             case OpCode.Nop do ip += 1;
@@ -48,17 +48,17 @@ main :: (args: [] cstr) {
     file := contents;
 
     instrs := array.make(Instruction, 32);
-    defer array.free(^instrs);
+    defer array.free(&instrs);
 
     while !string.empty(file) {
         word := file.data[0 .. 3];
-        string.advance(^file, 4);
+        string.advance(&file, 4);
 
         sign := file.data[0];
-        string.advance(^file, 1);
-        val := cast(i32) conv.parse_int(^file);
+        string.advance(&file, 1);
+        val := cast(i32) conv.parse_int(&file);
 
-        string.advance_line(^file);
+        string.advance_line(&file);
 
         if sign == #char "-" do val *= -1;
 
@@ -67,15 +67,15 @@ main :: (args: [] cstr) {
         elseif string.equal(word, "acc") do opcode = OpCode.Acc;
         elseif string.equal(word, "jmp") do opcode = OpCode.Jmp;
 
-        array.push(^instrs, .{ opcode, ~~val });
+        array.push(&instrs, .{ opcode, ~~val });
     }
 
     acc: i32;
-    for ^instr: instrs {
+    for &instr: instrs {
         if     instr.opcode == OpCode.Nop do instr.opcode = OpCode.Jmp;
         elseif instr.opcode == OpCode.Jmp do instr.opcode = OpCode.Nop;
 
-        if get_acc_value(instrs, ^acc) do break;
+        if get_acc_value(instrs, &acc) do break;
 
         if     instr.opcode == OpCode.Nop do instr.opcode = OpCode.Jmp;
         elseif instr.opcode == OpCode.Jmp do instr.opcode = OpCode.Nop;
index 9acb88f23549364d709d38ec4bd3b68d076719ed..7c877233fd60fbb3d4987e2e53d6832658562c9f 100644 (file)
@@ -30,11 +30,11 @@ main :: (args: [] cstr) {
     file := contents;
 
     nums := array.make(u64, 32);
-    defer array.free(^nums);
+    defer array.free(&nums);
 
     while !string.empty(file) {
-        num := conv.parse_int(^file);
-        array.push(^nums, num);
+        num := conv.parse_int(&file);
+        array.push(&nums, num);
     }
 
     preamble_length :: 25;
index bc106c9ee1b19a12ecb09653fa8f0076812e0569..838b3e5f60481e346261d29524beeca9b113d578 100644 (file)
@@ -15,13 +15,13 @@ count_increasing :: (arr: [] $T) -> u32 {
 
 main :: (args) => {
     file := os.open("./tests/aoc-2021/input/day01.txt")->expect("Error opening file");
-    reader := io.reader_make(^file);
-    defer os.close(^file);
+    reader := io.reader_make(&file);
+    defer os.close(&file);
 
     nums: [..] i32;
-    while !io.reader_empty(^reader) {
-        nums << io.read_u32(^reader);
-        io.skip_whitespace(^reader);
+    while !io.reader_empty(&reader) {
+        nums << io.read_u32(&reader);
+        io.skip_whitespace(&reader);
     }
 
     { // Part 1
index ca1704c132afdaa38b6c20cd62fc93febe82a14c..9c0c55ac4ab2853022d7a2ce12ca56af252de203 100644 (file)
@@ -10,9 +10,9 @@ main :: (args) => {
 
         #if PART == 1 {
             horizontal, vertical := 0, 0;
-            while !io.reader_empty(^reader) {
-                parts := string.split(io.read_line(^reader, inplace=true), #char " ");
-                defer memory.free_slice(^parts);
+            while !io.reader_empty(&reader) {
+                parts := string.split(io.read_line(&reader, inplace=true), #char " ");
+                defer memory.free_slice(&parts);
 
                 value := cast(i32) conv.str_to_i64(parts[1]);
                 switch parts[0] {
@@ -28,9 +28,9 @@ main :: (args) => {
         #if PART == 2 {
             horizontal, vertical, aim : i64;
             horizontal, vertical, aim = 0, 0, 0;
-            while !io.reader_empty(^reader) {
-                parts := string.split(io.read_line(^reader, inplace=true), #char " ");
-                defer memory.free_slice(^parts);
+            while !io.reader_empty(&reader) {
+                parts := string.split(io.read_line(&reader, inplace=true), #char " ");
+                defer memory.free_slice(&parts);
 
                 value := conv.str_to_i64(parts[1]);
                 switch parts[0] {
index 243ea2390f78af4b38e38e76c56ed364fa5df6e6..7510252e818b5175e3a3aad480626975b1b0a0c5 100644 (file)
@@ -4,7 +4,7 @@ PART :: 2
 
 use package core
 
-read_binary :: (r: ^io.Reader) -> i32 {
+read_binary :: (r: &io.Reader) -> i32 {
     n := 0;
 
     io.skip_whitespace(r);
@@ -30,8 +30,8 @@ main :: (args) => {
         reader := io.reader_make(it);
 
         nums: [..] i32;
-        while !io.reader_empty(^reader) {
-            nums << read_binary(^reader);
+        while !io.reader_empty(&reader) {
+            nums << read_binary(&reader);
         }
 
         num1 := 0;
@@ -48,8 +48,8 @@ main :: (args) => {
 
         printf("Part 1: {}\n", num1 * num2);
 
-        oxygen_array := array.copy(^nums);
-        co2_array    := array.copy(^nums);
+        oxygen_array := array.copy(&nums);
+        co2_array    := array.copy(&nums);
 
         filter_array :: macro (arr: [..] i32, index: i32, comparison: Code) {
             A := 0;
@@ -66,7 +66,7 @@ main :: (args) => {
                 defer i += 1;
 
                 if (arr[i] & (1 << index)) != expected {
-                    array.fast_delete(^arr, i);
+                    array.fast_delete(&arr, i);
                     i -= 1;
                 }
             }
index 1fd397a56aa67fa61183a5cbae7e6a0c41a1dda2..4d639b2be773b92e8161e9266580754c22085717 100644 (file)
@@ -12,7 +12,7 @@ Board :: struct {
     won_on  : Cell;
 }
 
-board_score :: (use b: ^Board) => {
+board_score :: (use b: &Board) => {
     sum_of_unmarked := 0;
     for 25 do if !marked[it] do sum_of_unmarked += ~~cells[it];
     return sum_of_unmarked * ~~won_on;
@@ -22,30 +22,30 @@ main :: (args) => {
     for os.with_file("./tests/aoc-2021/input/day04.txt") {
         reader := io.reader_make(it);
 
-        numbers_line := io.read_line(^reader, inplace=true, consume_newline=true);
+        numbers_line := io.read_line(&reader, inplace=true, consume_newline=true);
         numbers_str  := string.split(numbers_line, #char ",");
         numbers := memory.make_slice(Cell, numbers_str.count);
         for numbers_str.count do numbers[it] = ~~ conv.parse_int(numbers_str[it]);
 
         boards: [..] Board;
-        while !io.reader_empty(^reader) {
-            array.insert_empty(^boards, boards.count);
-            board := ^boards[boards.count - 1];
+        while !io.reader_empty(&reader) {
+            array.insert_empty(&boards, boards.count);
+            board := &boards[boards.count - 1];
             board.has_won = false;
-            memory.set(^board.marked, 0, sizeof typeof board.marked);
+            memory.set(&board.marked, 0, sizeof typeof board.marked);
 
             for 25 {
-                board.cells[it] = ~~ io.read_u32(^reader);
+                board.cells[it] = ~~ io.read_u32(&reader);
             }
 
-            io.skip_whitespace(^reader);
+            io.skip_whitespace(&reader);
         }
 
-        winning_board: ^Board = null;
-        worst_board  : ^Board = null;
+        winning_board: &Board = null;
+        worst_board  : &Board = null;
 
         for called: numbers {
-            for ^ board: boards {
+            for & board: boards {
                 if board.has_won do continue;
 
                 // Whatever the last board we touch is must be the worst one.
index f5fca8d56ad47304c739f6920438e0c156163fa1..47d68fb9da48779e37c95add53327dd9d8845fc3 100644 (file)
@@ -28,7 +28,7 @@ line_points :: (l: Line) -> Iterator(Point) {
     c.dx = 1 if l.x2 > l.x1 else -1 if l.x2 < l.x1 else 0;
     c.dy = 1 if l.y2 > l.y1 else -1 if l.y2 < l.y1 else 0;
 
-    next :: (use c: ^Context) -> (Point, bool) {
+    next :: (use c: &Context) -> (Point, bool) {
         if curr_t > max_t do return .{0,0}, false;
 
         defer curr_t += 1;
@@ -48,23 +48,23 @@ main :: (args) => {
 
         lines: [..] Line;
 
-        while !io.reader_empty(^reader) {
-            x1 := io.read_u32(^reader);
-            io.skip_bytes(^reader, 1);
-            y1 := io.read_u32(^reader);
-            io.skip_bytes(^reader, 4);
+        while !io.reader_empty(&reader) {
+            x1 := io.read_u32(&reader);
+            io.skip_bytes(&reader, 1);
+            y1 := io.read_u32(&reader);
+            io.skip_bytes(&reader, 4);
 
-            x2 := io.read_u32(^reader);
-            io.skip_bytes(^reader, 1);
-            y2 := io.read_u32(^reader);
-            io.skip_whitespace(^reader);
+            x2 := io.read_u32(&reader);
+            io.skip_bytes(&reader, 1);
+            y2 := io.read_u32(&reader);
+            io.skip_whitespace(&reader);
 
             lines << .{x1, y1, x2, y2};
         }
 
         point_count: Map(Point, u32);
 
-        for ^line: lines {
+        for &line: lines {
             for p: line_points(*line) {
                 if point_count->has(p) {
                     point_count[p] = point_count[p] + 1;
@@ -75,7 +75,7 @@ main :: (args) => {
         }
 
         count := 0;
-        for ^ point_count.entries {
+        for & point_count.entries {
             if it.value >= 2 do count += 1;
         }
 
index 8bdbb3c530f46b59497d2998626fc3a13d0e2c71..37c607e6bf91fef9efe996102980dd16b7325b71 100644 (file)
@@ -5,7 +5,7 @@ use package core
 main :: (args) => {
     for file: os.with_file("./tests/aoc-2021/input/day06.txt") {
         reader := io.reader_make(file);
-        start_str := io.read_all(^reader);
+        start_str := io.read_all(&reader);
 
         start_list := string.split(start_str, #char ",");
 
index e96d3c57a4cac9c7e47bc5ce56d755841b1c253e..452cd1e5257e7fd35dba731bb710c292437b047d 100644 (file)
@@ -5,7 +5,7 @@ use package core
 main :: (args) => {
     for file: os.with_file("./tests/aoc-2021/input/day07.txt") {
         reader := io.reader_make(file);
-        nums := io.read_all(^reader)
+        nums := io.read_all(&reader)
             |> string.split(#char ",")
             |> iter.as_iter()
             |> iter.map((x) => cast(i32) conv.parse_int(x))
index b52bda04bce5326f2fc4df68d6598e950df0547d..e6dbc76236da352051a5ddaf797806ff79e0566c 100644 (file)
@@ -29,7 +29,7 @@ decode_line :: (left, right: str) -> u32 {
     solved_segments: Map(u8, u32);
 
     left_segments := string.split(left, #char " ");
-    defer memory.free_slice(^left_segments);
+    defer memory.free_slice(&left_segments);
 
     // Look for 1.
     one_data := *array.first(left_segments, (x) => x.count == 2);
@@ -121,8 +121,8 @@ decode_line :: (left, right: str) -> u32 {
 
     sum := 0;
     words := string.split(right, #char " ");
-    defer memory.free_slice(^words);
-    for^ words {
+    defer memory.free_slice(&words);
+    for& words {
         string.strip_whitespace(it);
         
         num_segments : [7] bool;
@@ -141,7 +141,7 @@ decode_line :: (left, right: str) -> u32 {
 }
 
 // Nicer way of printing a Map.
-#match io.write (w: ^io.Writer, x: ^Map($K, $V)) {
+#match io.write (w: &io.Writer, x: &Map($K, $V)) {
     io.write(w, "{\n");
     for e: x.entries {
         io.write(w, "    {} => {}\n", e.key, e.value);
@@ -162,19 +162,19 @@ main :: (args) => {
         reader := io.reader_make(file);
 
         answer := 0; 
-        while !io.reader_empty(^reader) {
-            line := io.read_line(^reader, consume_newline=true, inplace=true);
+        while !io.reader_empty(&reader) {
+            line := io.read_line(&reader, consume_newline=true, inplace=true);
             left, right := do {
                 parts := string.split(line, #char "|");
-                defer memory.free_slice(^parts);
+                defer memory.free_slice(&parts);
                 return parts[0], parts[1];
             };
-            string.strip_whitespace(^left);
-            string.strip_whitespace(^right);
+            string.strip_whitespace(&left);
+            string.strip_whitespace(&right);
 
             #if PART == 1 {
                 words := string.split(right, #char " ");
-                for^ words {
+                for& words {
                     string.strip_whitespace(it);
                     switch it.count {
                         case 2, 3, 4, 7 do answer += 1;
index 9adce7667e3641a2065ff05e3570827555441941..f954a54a6aab375fe8559e4bb2456faed3b463e2 100644 (file)
@@ -3,7 +3,7 @@
 use package core
 
 Pos :: struct {x,y: i32;}
-#match hash.to_u32 (use p: Pos) => x * 13 ^ 17 * y;
+#match hash.to_u32 (use p: Pos) => x * 13 & 17 * y;
 #operator == (p1, p2: Pos) => p1.x == p2.x && p1.y == p2.y;
 
 Cell :: struct {
@@ -21,14 +21,14 @@ find_span :: macro (low: Pos) -> u32 {
 
     while queued.count != 0 {
         t := queued[0];
-        array.delete(^queued, 0);
+        array.delete(&queued, 0);
 
-        top := ^heightmap[t];
+        top := &heightmap[t];
         if top.height == 9 do continue;
 
         included << t;
 
-        array.clear(^potential);
+        array.clear(&potential);
         if t.x < width - 1 && top.dx < 0 {
             potential << Pos.{t.x+1,t.y};
         }
@@ -56,7 +56,7 @@ find_span :: macro (low: Pos) -> u32 {
     return included.count;
 }
 
-#match io.write (w: ^io.Writer, x: ^Map($K, $V)) {
+#match io.write (w: &io.Writer, x: &Map($K, $V)) {
     io.write(w, "{\n");
     for e: x.entries {
         io.write(w, "    {} => {}\n", e.key, e.value);
@@ -71,9 +71,9 @@ main :: (args) => {
         heightmap: Map(Pos, Cell);
 
         height, width := 0, 0;
-        while !io.reader_empty(^reader) {
-            line := io.read_line(^reader, consume_newline=false, inplace=true);
-            io.skip_whitespace(^reader);
+        while !io.reader_empty(&reader) {
+            line := io.read_line(&reader, consume_newline=false, inplace=true);
+            io.skip_whitespace(&reader);
 
             for line.count {
                 heightmap[Pos.{it, height}] = Cell.{cast(u32) (line[it] - #char "0")};
@@ -84,12 +84,12 @@ main :: (args) => {
         }
 
         for y: height - 1 do for x: width {
-            map.update(^heightmap, .{x,y}) {
+            map.update(&heightmap, .{x,y}) {
                 it.dy = it.height - heightmap[Pos.{x,y+1}].height;
             }
         }
         for x: width - 1 do for y: height {
-            map.update(^heightmap, .{x,y}) {
+            map.update(&heightmap, .{x,y}) {
                 it.dx = it.height - heightmap[Pos.{x+1,y}].height;
             }
         }
@@ -97,7 +97,7 @@ main :: (args) => {
         lowest: [..] Pos;
         risk_sum := 0;
         for y: height do for x: width {
-            h := ^heightmap[Pos.{x,y}];
+            h := &heightmap[Pos.{x,y}];
             if x < width  - 1 && h.dx >= 0 do continue;
             if y < height - 1 && h.dy >= 0 do continue;
 
index 7e0e54504bcab065197f043b1ad4ce8ff519abd3..ab81073090dfe90c288195ba19668c7fb0f22246 100644 (file)
@@ -20,12 +20,12 @@ main :: (args) => {
 
         corrupted_score := 0;
         completion_scores: [..] u64;
-        while !io.reader_empty(^reader) {
-            line := io.read_line(^reader, consume_newline=false, inplace=true);
-            io.skip_whitespace(^reader);
+        while !io.reader_empty(&reader) {
+            line := io.read_line(&reader, consume_newline=false, inplace=true);
+            io.skip_whitespace(&reader);
 
             char_stack: [..] u8;
-            defer array.free(^char_stack);
+            defer array.free(&char_stack);
             for ch: line {
                 switch ch {
                     case #char "(", #char "[", #char "<", #char "{" {
@@ -33,7 +33,7 @@ main :: (args) => {
                     }
 
                     case #char ")", #char "]", #char ">", #char "}" {
-                        x := array.pop(^char_stack);
+                        x := array.pop(&char_stack);
                         if x != ch {
                             // printf("Expected '{}', found '{}' instead.\n", x, ch);
                             corrupted_score += score_map[ch];
@@ -48,7 +48,7 @@ main :: (args) => {
             complete_score: u64 = 0;
             while char_stack.count != 0 {
                 complete_score *= 5;
-                switch array.pop(^char_stack) {
+                switch array.pop(&char_stack) {
                     case #char ")" do complete_score += 1;
                     case #char "]" do complete_score += 2;
                     case #char "}" do complete_score += 3;
index c4346348a2e9ed677af553da14da97a3d9e8a448..59451f9dd6041368272e0e8feb98fb54c12afa69 100644 (file)
@@ -11,9 +11,9 @@ main :: (args) => {
         reader := io.reader_make(file);
 
         octopuses: [..] u32;
-        while !io.reader_empty(^reader) {
-            line := io.read_line(^reader, consume_newline=false, inplace=true);
-            io.skip_whitespace(^reader);
+        while !io.reader_empty(&reader) {
+            line := io.read_line(&reader, consume_newline=false, inplace=true);
+            io.skip_whitespace(&reader);
 
             for ch: line do octopuses << ~~(ch - #char "0");
         }
@@ -41,7 +41,7 @@ main :: (args) => {
         sync_step := 0;
         while true {
             step += 1;
-            for ^o: octopuses do *o += 1;
+            for &o: octopuses do *o += 1;
 
             #persist to_flash: Set(Pos);
             for y: 10 do for x: 10 {
@@ -50,7 +50,7 @@ main :: (args) => {
                 }
             }
 
-            for flash: iter.as_iter(^to_flash) {
+            for flash: iter.as_iter(&to_flash) {
                 for y: -1 .. 2 do for x: -1 .. 2 {
                     if y == 0 && x == 0 do continue;
 
@@ -60,7 +60,7 @@ main :: (args) => {
                 }
             }
 
-            for flash: iter.as_iter(^to_flash) {
+            for flash: iter.as_iter(&to_flash) {
                 set_octopus(flash.x, flash.y, 0);
                 if step <= 100 do flash_count += 1;
             }
index 3d701d046f1120a3bbc21b6a3878e5e3b5852ecc..32faed1d7a8c07c29bde9562e5dfc089d5b8586c 100644 (file)
@@ -22,12 +22,12 @@ main :: (args) => {
 
         verticies: Set(str);
         edges: Set(Communative_Pair(str));
-        while !io.reader_empty(^reader) {
-            line := io.read_line(^reader, consume_newline=true);
+        while !io.reader_empty(&reader) {
+            line := io.read_line(&reader, consume_newline=true);
 
             left, right := do {
                 parts := string.split(line, #char "-");
-                defer memory.free_slice(^parts);
+                defer memory.free_slice(&parts);
                 return string.strip_whitespace(parts[0]), string.strip_whitespace(parts[1]);
             };
 
@@ -40,7 +40,7 @@ main :: (args) => {
         node_stack: [..] Node;
         node_stack << .{ "start", 0, false };
 
-        children_of :: (edges: ^$T, name: str) -> Iterator(str) {
+        children_of :: (edges: &$T, name: str) -> Iterator(str) {
             name_copy := make_temp(str);
             *name_copy = name;
 
@@ -61,8 +61,8 @@ main :: (args) => {
         }
 
         edge_map: Map(str, [] str);
-        for v: iter.as_iter(^verticies) {
-            edge_map[*v] = children_of(^edges, *v) |> iter.to_array();
+        for v: iter.as_iter(&verticies) {
+            edge_map[*v] = children_of(&edges, *v) |> iter.to_array();
         }
 
         paths_count := 0;
@@ -79,7 +79,7 @@ main :: (args) => {
 
                 if cannot_visit_multiple(child) {
                     visit_count := 0;
-                    for^ node_stack {
+                    for& node_stack {
                         if it.name == child do visit_count += 1;
                     }
 
@@ -94,7 +94,7 @@ main :: (args) => {
                 else              do node_stack << .{ child, 0, second_visit };
 
             } else {
-                array.pop(^node_stack);
+                array.pop(&node_stack);
             }
         }
 
index ed19deb5ae1d193c1cc9c08df418d65b90f70f11..7876fb0256313bff684dc5a7a1ea07fe32e0d723 100644 (file)
@@ -12,8 +12,8 @@ cmp_point :: (p1, p2: Point) => {
     return p1.y - p2.y;
 }
 
-apply_fold :: (dots: ^[] Point, axis_name: str, axis_value: i32) {
-    for^ *dots do switch axis_name {
+apply_fold :: (dots: &[] Point, axis_name: str, axis_value: i32) {
+    for& *dots do switch axis_name {
         case "x" do if it.x > axis_value do it.x = 2 * axis_value - it.x;
         case "y" do if it.y > axis_value do it.y = 2 * axis_value - it.y;
     }
@@ -28,8 +28,8 @@ main :: (args) => {
 
         dots: [..] Point;
         while true {
-            line := io.read_line(^reader, consume_newline=true, inplace=true);
-            string.strip_whitespace(^line);
+            line := io.read_line(&reader, consume_newline=true, inplace=true);
+            string.strip_whitespace(&line);
             if line.count == 0 do break;
 
             parts := string.split_iter(line, #char ",")
@@ -42,17 +42,17 @@ main :: (args) => {
         }
 
         part_1_answer := -1;
-        while !io.reader_empty(^reader) {
-            line := io.read_line(^reader, consume_newline=true, inplace=true);
+        while !io.reader_empty(&reader) {
+            line := io.read_line(&reader, consume_newline=true, inplace=true);
 
-            string.read_until(^line, #char " ", 1);
-            string.advance(^line, 1);
+            string.read_until(&line, #char " ", 1);
+            string.advance(&line, 1);
 
-            axis_name := string.read_until(^line, #char "=");
-            string.advance(^line, 1);
+            axis_name := string.read_until(&line, #char "=");
+            string.advance(&line, 1);
             axis_value := cast(i32) conv.str_to_i64(line);
 
-            apply_fold(~~ ^dots, axis_name, axis_value);
+            apply_fold(~~ &dots, axis_name, axis_value);
             if part_1_answer < 0 {
                 part_1_answer = dots.count;
             }
index 8716771e54b663d6f4591e4e41892b20f440f25e..d43166f4dd9bf535d6b83ba20060e7618777d1c9 100644 (file)
@@ -12,7 +12,7 @@ State :: struct {
 }
 
 // Nicer way of printing a Map.
-#match io.write (w: ^io.Writer, x: ^Map($K, $V)) {
+#match io.write (w: &io.Writer, x: &Map($K, $V)) {
     io.write(w, "{\n");
     for e: x.entries {
         io.write(w, "    {} => {}\n", e.key, e.value);
@@ -24,31 +24,31 @@ main :: (args) => {
     for file: os.with_file("./tests/aoc-2021/input/day14.txt") {
         reader := io.reader_make(file);
 
-        start_polymer := io.read_line(^reader, consume_newline=false);
-        io.skip_whitespace(^reader);
+        start_polymer := io.read_line(&reader, consume_newline=false);
+        io.skip_whitespace(&reader);
 
         rules: [..] Rule;
-        while !io.reader_empty(^reader) {
+        while !io.reader_empty(&reader) {
             r: Rule;
-            io.read_bytes(^reader, .{cast(^u8) ^r.pair, 2});
-            io.skip_bytes(^reader, 4);
-            r.insert = io.read_byte(^reader);
+            io.read_bytes(&reader, .{cast(&u8) &r.pair, 2});
+            io.skip_bytes(&reader, 4);
+            r.insert = io.read_byte(&reader);
 
             rules << r;
-            io.skip_whitespace(^reader);
+            io.skip_whitespace(&reader);
         }
 
         polymer_state: Map(Pair(u8, u8), State);
         add_to_state :: macro (pair: Pair(u8, u8), count: u64) {
             if polymer_state->has(pair) {
-                (^polymer_state[pair]).next += ~~count;
+                (&polymer_state[pair]).next += ~~count;
             } else {
                 polymer_state[pair] = .{ 0, ~~count };
             }
         }
 
         step_state :: macro () {
-            for^ polymer_state.entries {
+            for& polymer_state.entries {
                 it.value.now = it.value.next;
                 it.value.next = 0;
             }
@@ -62,8 +62,8 @@ main :: (args) => {
         step_state();
 
         for 40 {
-            for^ rule: rules {
-                pair_count := ^polymer_state[rule.pair];
+            for& rule: rules {
+                pair_count := &polymer_state[rule.pair];
                 if pair_count != null {
                     if pair_count.now > 0 {
                         pair1 := Pair(u8, u8).{ rule.pair.first, rule.insert };
@@ -77,14 +77,14 @@ main :: (args) => {
         }
 
         mode: Map(u8, u64);
-        for^ polymer_state.entries {
+        for& polymer_state.entries {
             mode[it.key.second] = mode[it.key.second] + it.value.now;
         }
 
         maximum := array.fold(mode.entries, cast(u64) 0, (x, y) => math.max(x.value, y));
         minimum := array.fold(mode.entries, maximum, (x, y) => math.min(x.value, y));
 
-        println(^mode);
+        println(&mode);
         printf("Part 2: {}\n", maximum - minimum - 1);
     }
 }
index 8686600297b9842f9576ed6e9b016e97e6d04809..c05ca03182246a3ec1fd7e57c2a4240b6c024037 100644 (file)
@@ -15,9 +15,9 @@ main :: (args) => {
 
         cells: [..] u8;
         height := 0;
-        while !io.reader_empty(^reader) {
-            line := io.read_line(^reader, consume_newline=false, inplace=true);
-            io.skip_whitespace(^reader);
+        while !io.reader_empty(&reader) {
+            line := io.read_line(&reader, consume_newline=false, inplace=true);
+            io.skip_whitespace(&reader);
 
             for line do cells << it;
             height += 1;
@@ -32,7 +32,7 @@ main :: (args) => {
 
         minimum := 0;
         while to_try.data.count != 0 {
-            try := heap.remove_top(^to_try);
+            try := heap.remove_top(&to_try);
             tried << .{try.x, try.y};
 
             cell_value := cast(u32) (cells[(try.y % height) * width + (try.x % width)] - #char "0");
index 30bef44ae1366c28840da837b87671a146e901c5..941d4abdd6e69ae1a66b859b2289cc3c5287d518 100644 (file)
@@ -25,20 +25,20 @@ BitIterator :: struct {
     value_idx: u32;
     bit_idx: i32;
 
-    next :: (b: ^BitIterator) -> u32 {
+    next :: (b: &BitIterator) -> u32 {
         v, _ := iter.take_one(b.iter, no_close=true);
         return v;
     }
 }
 
-bit_iterator :: (values: [] u8) -> ^BitIterator {
+bit_iterator :: (values: [] u8) -> &BitIterator {
     c := new(BitIterator);
     c.iter = .{ c, next, cfree };
     c.values = values;
     c.value_idx = 0;
     c.bit_idx = 7;
 
-    next :: (use c: ^BitIterator) -> (u32, bool) {
+    next :: (use c: &BitIterator) -> (u32, bool) {
         if value_idx >= values.count do return 0, false;
 
         defer {
@@ -58,7 +58,7 @@ bit_iterator :: (values: [] u8) -> ^BitIterator {
     return c;
 }
 
-read_bits :: (bit_provider: ^BitIterator, count: u32) -> u32 {
+read_bits :: (bit_provider: &BitIterator, count: u32) -> u32 {
     res := 0;
     for count {
         res *= 2;
@@ -83,10 +83,10 @@ Packet_Literal :: struct {
 
 Packet_Operator :: struct {
     use base: Packet;
-    subpackets: [] ^Packet;
+    subpackets: [] &Packet;
 }
 
-parse_packet :: (bit_provider: ^BitIterator) -> ^Packet {
+parse_packet :: (bit_provider: &BitIterator) -> &Packet {
     version := read_bits(bit_provider, 3);
     type    := read_bits(bit_provider, 3);
 
@@ -109,7 +109,7 @@ parse_packet :: (bit_provider: ^BitIterator) -> ^Packet {
         }
 
         case #default {
-            packets: [..] ^Packet;
+            packets: [..] &Packet;
 
             l_type := read_bits(bit_provider, 1);
             if l_type == 0 {
@@ -137,13 +137,13 @@ parse_packet :: (bit_provider: ^BitIterator) -> ^Packet {
     }
 }
 
-packet_sum_version :: (p: ^Packet) -> u64 {
+packet_sum_version :: (p: &Packet) -> u64 {
     switch p.type {
         case 4 do return ~~p.version;
 
         case #default {
             sum: u64;
-            for (cast (^Packet_Operator) p).subpackets {
+            for (cast (&Packet_Operator) p).subpackets {
                 sum += packet_sum_version(it);
             }
 
@@ -152,8 +152,8 @@ packet_sum_version :: (p: ^Packet) -> u64 {
     }
 }
 
-packet_reduce :: (p: ^Packet) -> u64 {
-    op := cast(^Packet_Operator) p;
+packet_reduce :: (p: &Packet) -> u64 {
+    op := cast(&Packet_Operator) p;
     switch p.type {
         case 0 {
             return array.fold(op.subpackets, cast(u64) 0, (x, y) => y + packet_reduce(x));
@@ -172,7 +172,7 @@ packet_reduce :: (p: ^Packet) -> u64 {
         }
         
         case 4 {
-            return (cast(^Packet_Literal) p).value;
+            return (cast(&Packet_Literal) p).value;
         }
 
         case 5 {
@@ -193,7 +193,7 @@ packet_reduce :: (p: ^Packet) -> u64 {
 main :: (args) => {
     for file: os.with_file("./tests/aoc-2021/input/day16.txt") {
         reader := io.reader_make(file);
-        line   := io.read_line(^reader, consume_newline=false, inplace=true);
+        line   := io.read_line(&reader, consume_newline=false, inplace=true);
 
         transmission: [..] u8;
         for i: range.{ 0, line.count, 2 } {
index 03d9f6718216a900d17232bc8753811dc1b7d533..529bfbba3fd02cac13dcf3545799375db594c4b3 100644 (file)
@@ -33,14 +33,14 @@ main :: (args) => {
     for file: os.with_file("./tests/aoc-2021/input/day17.txt") {
         reader := io.reader_make(file);
 
-        io.skip_bytes(^reader, 15);
-        tx0 = io.read_i32(^reader);
-        io.skip_bytes(^reader, 2);
-        tx1 = io.read_i32(^reader);
-        io.skip_bytes(^reader, 4);
-        ty0 = io.read_i32(^reader);
-        io.skip_bytes(^reader, 2);
-        ty1 = io.read_i32(^reader);
+        io.skip_bytes(&reader, 15);
+        tx0 = io.read_i32(&reader);
+        io.skip_bytes(&reader, 2);
+        tx1 = io.read_i32(&reader);
+        io.skip_bytes(&reader, 4);
+        ty0 = io.read_i32(&reader);
+        io.skip_bytes(&reader, 2);
+        ty1 = io.read_i32(&reader);
     }
 
     max := 0;
index 77a8a1f1c1f0d9e9bdbfd88f10d28251b54e88be..cc308572091bed7338450b2f4b85c2a11661dfb5 100644 (file)
@@ -8,8 +8,8 @@ use core.alloc {arena}
 num_allocator: Allocator;
 
 SnailNum :: struct {
-    parent: ^SnailNum;
-    left, right: ^SnailNum;
+    parent: &SnailNum;
+    left, right: &SnailNum;
 
     left_val, right_val: u32;
 }
@@ -29,7 +29,7 @@ SnailNum :: struct {
         return n;
     }
 
-    clone :: (n: ^SnailNum) -> ^SnailNum {
+    clone :: (n: &SnailNum) -> &SnailNum {
         if !n do return null;
 
         new_num := SnailNum.make();
@@ -41,7 +41,7 @@ SnailNum :: struct {
         return new_num;
     }
 
-    add :: (a, b: ^SnailNum) => {
+    add :: (a, b: &SnailNum) => {
         if !a do return b;
         if !b do return a;
 
@@ -54,13 +54,13 @@ SnailNum :: struct {
         return new_root;
     }
 
-    reduce :: (use n: ^SnailNum) -> (reduced_something: bool) {
+    reduce :: (use n: &SnailNum) -> (reduced_something: bool) {
         if r, _ := n->reduce_explodes(); r do return true;
         if r    := n->reduce_splits();   r do return true;
         return false;
     }
 
-    reduce_explodes :: (use n: ^SnailNum, depth := 0) -> (reduced_something: bool, zero_node: bool) {
+    reduce_explodes :: (use n: &SnailNum, depth := 0) -> (reduced_something: bool, zero_node: bool) {
         if depth <= 3 {
             if left != null {
                 if did_reduce, zero_node := left->reduce_explodes(depth + 1); zero_node {
@@ -96,7 +96,7 @@ SnailNum :: struct {
         return true, true;
     }
 
-    reduce_splits :: (use n: ^SnailNum) -> (reduced_something: bool) {
+    reduce_splits :: (use n: &SnailNum) -> (reduced_something: bool) {
         if left {
             if left->reduce_splits() {
                 return true;
@@ -129,26 +129,26 @@ SnailNum :: struct {
         }
     }
 
-    set_left :: (parent, new_left: ^SnailNum) {
+    set_left :: (parent, new_left: &SnailNum) {
         parent.left_val = 0;
         parent.left = new_left;
         if new_left do new_left.parent = parent;
     }
 
-    set_right :: (parent, new_right: ^SnailNum) {
+    set_right :: (parent, new_right: &SnailNum) {
         parent.right_val = 0;
         parent.right = new_right;
         if new_right do new_right.parent = parent;
     }
 
-    number_to_left :: (n: ^SnailNum) -> ^u32 {
+    number_to_left :: (n: &SnailNum) -> &u32 {
         while n.parent && n.parent.left == n {
             n = n.parent;
         }
 
         if !n.parent do return null;
 
-        if !n.parent.left do return ^n.parent.left_val;
+        if !n.parent.left do return &n.parent.left_val;
 
         n = n.parent.left;
 
@@ -156,17 +156,17 @@ SnailNum :: struct {
             n = n.right;
         }
 
-        return ^n.right_val;
+        return &n.right_val;
     }
 
-    number_to_right :: (n: ^SnailNum) -> ^u32 {
+    number_to_right :: (n: &SnailNum) -> &u32 {
         while n.parent && n.parent.right == n {
             n = n.parent;
         }
 
         if !n.parent do return null;
 
-        if !n.parent.right do return ^n.parent.right_val;
+        if !n.parent.right do return &n.parent.right_val;
 
         n = n.parent.right;
 
@@ -174,10 +174,10 @@ SnailNum :: struct {
             n = n.left;
         }
 
-        return ^n.left_val;
+        return &n.left_val;
     }
 
-    magnitude :: (use n: ^SnailNum) => {
+    magnitude :: (use n: &SnailNum) => {
         if !n {
             return 0;
         }
@@ -186,7 +186,7 @@ SnailNum :: struct {
             +  2 * (right_val + right->magnitude());
     }
 
-    parse :: (line: ^str) -> ^SnailNum {
+    parse :: (line: &str) -> &SnailNum {
         string.advance(line);  // [
 
         root := SnailNum.make();
@@ -209,7 +209,7 @@ SnailNum :: struct {
         return root;
     }
 
-    format :: (output: ^conv.Format_Output, s: ^conv.Format, use n: ^SnailNum) {
+    format :: (output: &conv.Format_Output, s: &conv.Format, use n: &SnailNum) {
         if !left && !right {
             conv.format(output, "[{},{}]", left_val, right_val);
         }
@@ -229,7 +229,7 @@ SnailNum :: struct {
 
 main :: () {
     num_arena := arena.make(context.allocator, 256 * 1024);
-    SnailNum.allocator = alloc.as_allocator(^num_arena);
+    SnailNum.allocator = alloc.as_allocator(&num_arena);
     
     conv.register_custom_formatter(SnailNum.format);
 
@@ -237,10 +237,10 @@ main :: () {
         r := io.reader_make(file);
 
         #if PART == 1 {
-            s: ^SnailNum = null;
+            s: &SnailNum = null;
             
             for line: r->lines() {
-                n := SnailNum.parse(^line);
+                n := SnailNum.parse(&line);
                 s = s->add(n);
             }
 
@@ -248,9 +248,9 @@ main :: () {
         }
 
         #if PART == 2 {
-            nums := make([..] ^SnailNum);
+            nums := make([..] &SnailNum);
             for line: r->lines() {
-                nums << SnailNum.parse(^line);
+                nums << SnailNum.parse(&line);
             }
 
             maximum := 0;
index 639fb6c562104dfd8d920dde5fed699fc86b38cb..dd552be3e2ae2cf0a86aff633f6e43aefd868679 100644 (file)
@@ -14,7 +14,7 @@ Die :: struct {
         return .{ 1, 0 };
     }    
 
-    roll :: (d: ^Die) -> u32 {
+    roll :: (d: &Die) -> u32 {
         defer d.value += 1;
         defer d.rolls += 1;
         return d.value;
@@ -27,7 +27,7 @@ Player :: struct {
 }
 
 #inject Player {
-    move :: (p: ^Player, squares: u32) {
+    move :: (p: &Player, squares: u32) {
         p.square += squares;
         p.square %= 10;
         
@@ -47,8 +47,8 @@ main :: () {
         _, s1 := string.bisect(l1, #char ":");
         _, s2 := string.bisect(l2, #char ":");
 
-        string.strip_whitespace(^s1);
-        string.strip_whitespace(^s2);
+        string.strip_whitespace(&s1);
+        string.strip_whitespace(&s2);
 
         p1.square = ~~ (conv.str_to_i64(s1) - 1);
         p2.square = ~~ (conv.str_to_i64(s2) - 1);
@@ -58,7 +58,7 @@ main :: () {
     losing_score: u32;
 
     while true {
-        play :: macro (player, opponent: ^Player) {
+        play :: macro (player, opponent: &Player) {
             r1 := die->roll();
             r2 := die->roll();
             r3 := die->roll();
@@ -71,8 +71,8 @@ main :: () {
             }
         }
 
-        play(^p1, ^p2);
-        play(^p2, ^p1);
+        play(&p1, &p2);
+        play(&p2, &p1);
     }
 
     println(losing_score * die.rolls);
@@ -159,7 +159,7 @@ calc_wins :: (p1, p2: Player, player_1_turn := true) -> (u64, u64) {
         w1, w2: u64;
         
         if player_1_turn {
-            for^ cases {
+            for& cases {
                 n1, n2 := calc_wins_memo(
                     p1->move(it.spaces),
                     p2,
@@ -171,7 +171,7 @@ calc_wins :: (p1, p2: Player, player_1_turn := true) -> (u64, u64) {
             }
 
         } else {
-            for^ cases {
+            for& cases {
                 n1, n2 := calc_wins_memo(
                     p1,
                     p2->move(it.spaces),
@@ -199,8 +199,8 @@ main :: () {
         _, s1 := string.bisect(l1, #char ":");
         _, s2 := string.bisect(l2, #char ":");
 
-        string.strip_whitespace(^s1);
-        string.strip_whitespace(^s2);
+        string.strip_whitespace(&s1);
+        string.strip_whitespace(&s2);
 
         p1.square = cast(i32) (conv.str_to_i64(s1) - 1);
         p2.square = cast(i32) (conv.str_to_i64(s2) - 1);
index f487e8cd0c5ecedd2064fa0792dd93fbd86015ae..de454d5482c4a173bda4f7e7121aad78fac64d7c 100644 (file)
@@ -5,7 +5,7 @@ use package core
 Vec2 :: struct { x: i32; y: i32; }
 
 // Overload print() to print Vec2's.
-#match io.write (use writer: ^io.Writer, use v: Vec2) {
+#match io.write (use writer: &io.Writer, use v: Vec2) {
     io.write_format(writer, "Vec2({}, {})", x, y);
 }
 
@@ -18,7 +18,7 @@ calc_vecs :: (n := 0) -> [4] Vec2 {
     vecs : [4] Vec2;
 
     i := n;
-    for ^v: vecs {
+    for &v: vecs {
         v.x = i * i;
         v.y = i * i * i;
         i += 1;
@@ -32,7 +32,7 @@ main :: (args: [] cstr) {
     {
         println("Array of structs on the stack.");
         vecs : [8] Vec2;
-        for ^v: vecs {
+        for &v: vecs {
             v.x = 4039;
             v.y = 7782;
         }
@@ -44,7 +44,7 @@ main :: (args: [] cstr) {
     {
         println("Array of structs from function call.");
         vecs := calc_vecs();
-        for ^v: vecs do println(*v);
+        for &v: vecs do println(*v);
     }
 
     // Array of structs on a struct
@@ -88,7 +88,7 @@ main :: (args: [] cstr) {
 
         nums : [100] u32;
         i := 1;
-        for ^n: nums {
+        for &n: nums {
             *n = i * i;
             i += 5;
         }
@@ -100,12 +100,12 @@ main :: (args: [] cstr) {
         println("2D-array from an allocation to a function.");
 
         vecs_data: [2][4] Vec2;
-        vecs := ^vecs_data; // equivalent of heap allocating it
+        vecs := &vecs_data; // equivalent of heap allocating it
 
-        set_vecs :: (vecs: ^[2][4] Vec2) {
+        set_vecs :: (vecs: &[2][4] Vec2) {
             i := 0;
-            for ^row: *vecs {
-                for ^v: *row {
+            for &row: *vecs {
+                for &v: *row {
                     *v = .{ 1000 + i, 2000 + i * i };
                     i += 1;
                 }
@@ -114,11 +114,11 @@ main :: (args: [] cstr) {
 
         set_vecs(vecs);
 
-        print_vecs :: (vecs: ^[4] Vec2) {
-            for ^v: *vecs do println(*v);
+        print_vecs :: (vecs: &[4] Vec2) {
+            for &v: *vecs do println(*v);
         }
 
-        print_vecs(^(*vecs)[0]);
-        print_vecs(^(*vecs)[1]);
+        print_vecs(&(*vecs)[0]);
+        print_vecs(&(*vecs)[1]);
     }
 }
index 5bffa291067eb43bcf7e9a3ab67536748b75bb9d..dcbbd11b5a3df063a4f049f25f597b1f87d76715 100644 (file)
@@ -8,12 +8,12 @@ V2 :: struct {
 
     add :: (v1, v2: V2) => V2.{v1.x+v2.x, v1.y+v2.y};
 
-    add_inplace :: (v1: ^V2, v2: V2) {
+    add_inplace :: (v1: &V2, v2: V2) {
         v1.x += v2.x;
         v1.y += v2.y;
     }
 
-    format :: (output: ^conv.Format_Output, _: ^conv.Format, v: ^V2) {
+    format :: (output: &conv.Format_Output, _: &conv.Format, v: &V2) {
         conv.format(output, "({}, {})", v.x, v.y); 
     }
 }
index f935cfac41581e1600848406c1648f39e1de3d4a..2bc907619e2767f1db3e922c414ba61b450ee4f0 100644 (file)
@@ -21,8 +21,8 @@ test_var := 5678;
 print_from_other_thread :: (sd) => {
     // Creating high contention for the shared resource
     for i: 10000 {
-        sync.scoped_mutex(^shared_mutex);
-        for ^v: sd.arr {
+        sync.scoped_mutex(&shared_mutex);
+        for &v: sd.arr {
             *v += 1;
         }
     }
@@ -36,7 +36,7 @@ print_from_other_thread :: (sd) => {
 }
 
 main :: (args) => {
-    sync.mutex_init(^shared_mutex);
+    sync.mutex_init(&shared_mutex);
 
     test_var = 1234;
     println(test_var);
@@ -46,16 +46,16 @@ main :: (args) => {
     array.fill(sd.arr, 0);
 
     threads : [4] thread.Thread;
-    for ^t: threads {
-        thread.spawn(t, ^sd, print_from_other_thread);
+    for &t: threads {
+        thread.spawn(t, &sd, print_from_other_thread);
         printf("Spawned thread {}\n", t.id);
     }
 
-    memory.alloc_slice(^partial_arr, 10);
+    memory.alloc_slice(&partial_arr, 10);
     for i: 10 do partial_arr[i] = i;
 
     printf("Waiting...\n");
-    for ^t: threads {
+    for &t: threads {
         thread.join(t);
         printf("Thread {} joined!\n", t.id);
     }
index 6c1a15cb665bfc1693d60df895d10f7573b0ba2d..186c01b42fb5efb879259102f5ae4c286dc66901 100644 (file)
@@ -2,7 +2,7 @@
 
 use package core
 
-dumb :: (it: Iterator, m: ^Map) {
+dumb :: (it: Iterator, m: &Map) {
     println(it.Iter_Type);
     println(__autopoly_var_0);
     println(typeof *m);
@@ -14,7 +14,7 @@ Vector2 :: struct (T: type_expr) {
 
 vec_add :: (v1: Vector2, v2: typeof v1) => (typeof v1).{ v1.x + v2.x, v1.y + v2.y };
 
-mappable :: (k: m.Key_Type, m: ^Map, x: $T) {
+mappable :: (k: m.Key_Type, m: &Map, x: $T) {
     printf("{} to {}\n", m.Key_Type, m.Value_Type);
     println(k);
     println(x);
@@ -24,24 +24,24 @@ Thing :: struct (type: type_expr) {
     value: type;
 }
 
-f :: (thing: ^Thing, other: typeof thing) {
+f :: (thing: &Thing, other: typeof thing) {
     printf("type of thing is {}\n", typeof thing);
     printf("thing is {}\n", *thing);
 }
 
 main :: (args) => {
     m: Map(i32, str);
-    dumb(iter.as_iter(1 .. 10), ^m);
+    dumb(iter.as_iter(1 .. 10), &m);
 
     V :: Vector2(i32)
     v1 := V.{ 1, 0 };
     v2 := V.{ 0, 1 };
     println(vec_add(v1, v2));
 
-    mappable(1234, ^m, "WOOT WOOT!!!");
+    mappable(1234, &m, "WOOT WOOT!!!");
 
     t: Thing(f32);
-    f(^t, ^t);
+    f(&t, &t);
 
     for iter.as_iter(0 .. 100) |> iter.map(x => x * 2) |> iter.filter(x => x <= 10) {
         println(it);
index a727e494e3acfbdceae71d4c700cfbeca4d0d22c..ab818a3a0ac0363239aa0e8bfe3071182f3438e6 100644 (file)
@@ -3,15 +3,15 @@
 use package core
 
 main :: () {
-    tree: ^avl_tree.AVL_Tree(i32);
+    tree: &avl_tree.AVL_Tree(i32);
 
-    avl_tree.insert(^tree, 20);
-    avl_tree.insert(^tree, 5);
-    avl_tree.insert(^tree, 8);
-    avl_tree.insert(^tree, 25);
-    avl_tree.insert(^tree, 0);
-    avl_tree.insert(^tree, 15);
-    avl_tree.insert(^tree, 10);
+    avl_tree.insert(&tree, 20);
+    avl_tree.insert(&tree, 5);
+    avl_tree.insert(&tree, 8);
+    avl_tree.insert(&tree, 25);
+    avl_tree.insert(&tree, 0);
+    avl_tree.insert(&tree, 15);
+    avl_tree.insert(&tree, 10);
 
     avl_tree.print(tree);
     print("\n");
index f0325ac3f75b0381e43bc1307ef25dd8fe67be9c..cb0e4cdd98b2565283fc3bb93e749d8498c3adca 100644 (file)
@@ -8,7 +8,7 @@ count_to :: ($N: i32) {
 }
 
 alloc_slice :: ($T: type_expr, N: i32) -> [] T {
-    data := cast(^T) calloc(sizeof T * N);
+    data := cast(&T) calloc(sizeof T * N);
     return .{ data, N };
 }
 
@@ -25,27 +25,27 @@ main :: (args: [] cstr) {
     count_to(UP_TO);
 
     sl := alloc_slice(i32, 10);
-    for ^ sl do *it = 1234;
+    for & sl do *it = 1234;
 
     for sl do println(it);
 
 
     // This is so much cleaner than the alternative.
     ages := map.make(str, u32, default=0);
-    defer delete(^ages);
+    defer delete(&ages);
 
-    map.put(^ages, "Dwight", 32);
-    map.put(^ages, "Jim", 25);
-    map.put(^ages, "Pam", 24);
+    map.put(&ages, "Dwight", 32);
+    map.put(&ages, "Jim", 25);
+    map.put(&ages, "Pam", 24);
 
-    print_age :: (ages: ^map.Map(str, u32), name: str) {
+    print_age :: (ages: &map.Map(str, u32), name: str) {
         age := map.get(ages, name);
         printf("{}'s age is {}.\n", name, age);
     }
 
-    print_age(^ages, "Dwight");
-    print_age(^ages, "Jim");
-    print_age(^ages, "Pam");
-    print_age(^ages, "Michael");
+    print_age(&ages, "Dwight");
+    print_age(&ages, "Jim");
+    print_age(&ages, "Pam");
+    print_age(&ages, "Michael");
 }
 
index 550dbfa3af3f6f2d450efc950e2425eb3f191a9c..3e06092ac8c147c58cdcd3bf0dbe861db5a62da9 100644 (file)
@@ -14,7 +14,7 @@ main :: (args: [] cstr) {
         sum += *it;
     });
 
-    for it: bucket_array.as_iter(^ba) {
+    for it: bucket_array.as_iter(&ba) {
         printf("{}\n", it);
     }
 
index 9bd635d8b544992d05e78b6b3ff6e3566b95b441..81a8d338815b2349f9fbc0ebbf2d0a97db086eb6 100644 (file)
@@ -11,13 +11,13 @@ S :: struct {
 
 main :: (args) => {
     v: S;
-    array.init(^v.some_array);
+    array.init(&v.some_array);
 
-    do_something_with_S(^v);
+    do_something_with_S(&v);
 
-    printf("{*p}\n", ^v);
+    printf("{*p}\n", &v);
 }
 
-do_something_with_S :: (s: ^S) {
+do_something_with_S :: (s: &S) {
     s.some_array << .{ "Joe", 14 };
 }
index 96e4b032b5613b871ed81d4d05cc7d4003c99ac1..790f5779b9748259cc3e4fc180c0afea5eefbe95 100644 (file)
@@ -2,7 +2,7 @@
 
 use core
 
-q :: (v: ^$C, g: (^C) -> $T) {
+q :: (v: &$C, g: (&C) -> $T) {
     println(*v);
     println(g(v));
     println(T);
@@ -11,5 +11,5 @@ q :: (v: ^$C, g: (^C) -> $T) {
 main :: () {
     v := 5;
 
-    q(^v, _ => false);
+    q(&v, _ => false);
 }
index 3a289d59d7726df5ca40c1b13adbcb89529ec622..691ed8fb10d2a4c5c8edc2e93d14abba4d2b6fb6 100644 (file)
@@ -17,5 +17,5 @@ main :: (args) => {
     S << Point.{ 2, 3 };
     S << Point.{ 1, 2 };
 
-    set.has(^S, Point.{ 1, 2 }) |> println();
+    set.has(&S, Point.{ 1, 2 }) |> println();
 }
index bf2a2d3839dfb170c35c96d3a51707852e507469..63866adba62c61e7bcb02aa85d7603f592d02da5 100644 (file)
@@ -3,11 +3,11 @@
 use core
 
 Foo :: struct {
-    use vtable: ^VTable;
+    use vtable: &VTable;
     x: u32;
 
     VTable :: struct {
-        f: (^Foo) -> void;
+        f: (&Foo) -> void;
     }
 }
 
@@ -18,9 +18,9 @@ good_foo := Foo.VTable.{
     }
 }
 
-make_foo :: () -> ^Foo {
+make_foo :: () -> &Foo {
     foo := new(Foo);
-    foo.vtable = ^good_foo;
+    foo.vtable = &good_foo;
     foo.x = 1234;
 
     printf("Made foo!\n");
@@ -30,6 +30,6 @@ make_foo :: () -> ^Foo {
 main :: () {
     make_foo()->f();
 
-    Foo.{^good_foo, 5678}->f();
+    Foo.{&good_foo, 5678}->f();
 }
 
index be91947a580dcc73e306461a3ca64b3e9662d149..fe27a40c431957b6cd46e740da0bb3bd21b6dbce 100644 (file)
@@ -20,7 +20,7 @@ main :: (args: [] cstr) {
 Something :: struct {
     member := cast(u32) 1234;
 
-    method :: (use s: ^Something) {
+    method :: (use s: &Something) {
         using_callsite(member);
     }
 }
index abc2cdae98fb2b57fb7460245c7eb758b5a1bcbc..bd51f2cdd6ab12979d82250ce1cdb459ab7ae118 100644 (file)
@@ -21,7 +21,7 @@ test_vtable2 := Test_VTable.{
 
 
 Test_Thing :: struct {
-    vt : ^Test_VTable;
+    vt : &Test_VTable;
 
     data : i32;
 }
@@ -33,19 +33,19 @@ dummy := () { println("hello world!"); }
 main :: (args: [] cstr) {
     dummy();
 
-    t := Test_Thing.{ ^test_vtable1, 10 };
-    println(do_a_thing(^t));
+    t := Test_Thing.{ &test_vtable1, 10 };
+    println(do_a_thing(&t));
 
-    t.vt = ^test_vtable2;
-    println(do_a_thing(^t));
+    t.vt = &test_vtable2;
+    println(do_a_thing(&t));
 
     tmp_vt := Test_VTable.{ first = test_vtable1.second, second = test_vtable2.first, third = math.max_poly };
-    t.vt = ^tmp_vt;
-    println(do_a_thing(^t));
+    t.vt = &tmp_vt;
+    println(do_a_thing(&t));
 
     println(t.vt.first == test_vtable1.second);
 
-    do_a_thing :: (use t: ^Test_Thing) -> i32 {
+    do_a_thing :: (use t: &Test_Thing) -> i32 {
         if vt.second == null_proc || vt.first == null_proc do return data;
 
         res := data |> vt.second() |> vt.first();
index 754edbc4de17ef3905dcfadeeb8db417aa0e29d9..9c985dfb8e9013fb5f8132c3fa10d67c40ba6f8c 100644 (file)
@@ -45,13 +45,13 @@ main :: (args: [] cstr) {
         }
 
         Guy :: struct {
-            best_friend: ^Guy;
+            best_friend: &Guy;
             favorite_color: Color;
         }
 
         nightmare :: (x: (typeof(z.best_friend), $K) -> void,
                       y: (typeof(x)) -> $R,
-                      z: ^$SomeType,
+                      z: &$SomeType,
                       w: R) {
             k := y(x);
         }
@@ -60,7 +60,7 @@ main :: (args: [] cstr) {
             printf("dummy1 got T={}, typeof(a.favorite_color)={}\n", a, typeof(b));
         }
 
-        dummy2 :: (f: (a: ^Guy, b: $C) -> void) -> C {
+        dummy2 :: (f: (a: &Guy, b: $C) -> void) -> C {
             printf("dummy2 got C={}\n", C);
 
             other_guy := new(Guy);
index 38cb257497bb661e44ac363e7cdcd7a7ea9d10d9..db403f7672ec6630d5301f0de573e9e06e3fe736 100644 (file)
@@ -6,24 +6,24 @@ use package core
 
 main :: (args: [] cstr) {
     imap : Map(i32, str);
-    map.init(^imap, "");
+    map.init(&imap, "");
     defer {
         print("Freeing map\n");
-        map.free(^imap);
+        map.free(&imap);
     }
-    map.put(^imap, 50, "Hello ");
+    map.put(&imap, 50, "Hello ");
     imap->put(1234, "World!");
 
-    println(map.has(^imap, 50));
-    println(map.has(^imap, 51));
+    println(map.has(&imap, 50));
+    println(map.has(&imap, 51));
 
-    printf("{}{}\n", map.get(^imap, 50), map.get(^imap, 1234));
+    printf("{}{}\n", map.get(&imap, 50), map.get(&imap, 1234));
 
-    printf("{*p}\n", ^imap);
+    printf("{*p}\n", &imap);
 
-    map.delete(^imap, 50);
-    println(map.has(^imap, 50));
+    map.delete(&imap, 50);
+    println(map.has(&imap, 50));
 
-    map.clear(^imap);
-    println(map.has(^imap, 1234));
+    map.clear(&imap);
+    println(map.has(&imap, 1234));
 }
index 60e9943baf2b2fd995bea873b65950d0805356d7..677bd23f677052322dc16d43c4b362ac18a2b06a 100644 (file)
@@ -13,11 +13,11 @@ main :: (args) => {
 
     {
         arr: [..] i32;
-        printf("{*p}\n", cast(^array.Untyped_Array) ^arr);
+        printf("{*p}\n", cast(&array.Untyped_Array) &arr);
 
         people: Map(str, i32);
         people["Joe"] = 12;
         people["Jane"] = 34;
-        printf("{*p}\n", ^people.entries);
+        printf("{*p}\n", &people.entries);
     }
 }
\ No newline at end of file
index 8ba891ef2489bb479b43206c38e2b7f9f44262c7..83a2a92f6bc6bfde99dd97ea43c380a5a8fe4a92 100644 (file)
@@ -57,7 +57,7 @@ BitField :: interface (t: $T) {
 Complex :: struct {
     x, y: f32;
 
-    format :: (output: ^conv.Format_Output, format: ^conv.Format, c: ^Complex) {
+    format :: (output: &conv.Format_Output, format: &conv.Format, c: &Complex) {
         conv.format(output, "{.2} + {.2}i", c.x, c.y);
     }
 }
@@ -76,7 +76,7 @@ consume :: macro (x: $T/iter.Iterable) => {
     // everything WAY more complicated.
     consume_inner :: #match {
         // Iterator over pointers get dereferenced
-        macro (iter: Iterator(^$T)) -> [..] T {
+        macro (iter: Iterator(&$T)) -> [..] T {
             arr := array.make(T);
             for iter do arr << *it;
             return arr;
@@ -105,7 +105,7 @@ main :: (args: [] cstr) {
     // println(bit_math(3.0, 4.0));
 
     a := consume(f32.[4,2,4,7,4]);
-    defer array.free(^a);
+    defer array.free(&a);
     println(a);
 
     consume(1 .. 10) |> println();
index 42b630f9813e9a7c5675fb341ec9202ffef9f8e7..8f6fff7dab521a8dd558680f5401c93b91d07405 100644 (file)
@@ -4,7 +4,7 @@ use package core
 
 count_iterator :: (lo: $T, hi: T, step: T = 1) -> Iterator(T) {
     return iter.generator(
-        ^.{ low = lo, high = hi, step = step, current = lo },
+        &.{ low = lo, high = hi, step = step, current = lo },
     
         (ctx) => {
             if ctx.current <= ctx.high {
index 79c3a10d97803bd4eceb93574562d3f15ae98079..9ee7330ec9dbd630504874e35d2bedf8e860f63e 100644 (file)
@@ -48,7 +48,7 @@ main :: (args: [] cstr) {
     array_print(farr);
 
     array_print :: (arr: [$N] $T) {
-        for ^e: arr {
+        for &e: arr {
             print(*e);
             print(" ");
         }
index 600169ee2967fe2343a372adb0435dc4b2e924e9..5bd6382d25657cb13b8a379114a87caf7b90da6d 100644 (file)
@@ -18,7 +18,7 @@ Foo :: struct {
     member1 := get_a_value(f32);
     member2 := get_a_value(i32);
     
-    get_member2_plus_three :: (foo: ^Foo) -> i32 {
+    get_member2_plus_three :: (foo: &Foo) -> i32 {
         return foo.member2 + 3;
     }
     
@@ -35,7 +35,7 @@ Foo2 :: struct {
         age  : i32;
     }
     
-    get_member2_plus_three :: (foo: ^$T) -> f32 {
+    get_member2_plus_three :: (foo: &$T) -> f32 {
         return foo.member2 + 3;
     }
     
index 4bc7058fe52675aeb41ed1f9dd0c7f8d6d13a145..6a1340371a8babfb66d0162e15aa505282098ad8 100644 (file)
@@ -14,7 +14,7 @@ main :: () {
     };
 
     for 40 {
-        step_physics(^object, 0.01);
+        step_physics(&object, 0.01);
         printf("{}\n", object);
     }
 }
index 3280816571e4199f4b45b1b43ed1cc1136f4c5dd..662e3fcd635c8557644403c4439520b800380e1b 100644 (file)
@@ -4,13 +4,13 @@ main :: () {
     sum := 0;
 
     thread_data := .{
-        sum = ^sum,
+        sum = &sum,
         mutex = sync.Mutex.{},
     };
-    sync.mutex_init(^thread_data.mutex);
+    sync.mutex_init(&thread_data.mutex);
 
-    iter.parallel_for(0 .. 10000, 4, ^thread_data) {
-        sync.scoped_mutex(^thread_data.mutex);
+    iter.parallel_for(0 .. 10000, 4, &thread_data) {
+        sync.scoped_mutex(&thread_data.mutex);
         *thread_data.sum += it;
     }
 
index 8e9108fa49443df4a10e97f58b446152fc0c061e..835dab2faf8f30141729cfd3ff8217f75b1b87d2 100644 (file)
@@ -28,14 +28,14 @@ foo :: (x: i32) -> i32 {
 
 cached_fib :: (n: u64) -> u64 {
     #persist cache : map.Map(u64, u64);
-    _ :: #init () { map.init(^cache); };
+    _ :: #init () { map.init(&cache); };
 
     if n <= 1 do return n;
 
-    if map.has(^cache, n) do return map.get(^cache, n);
+    if map.has(&cache, n) do return map.get(&cache, n);
 
     res := cached_fib(n - 1) + cached_fib(n - 2);
-    map.put(^cache, n, res);
+    map.put(&cache, n, res);
 
     print_cache_size();
 
index 9fd5eeb4c500a0ab8b7454d0fdca00a50d36e4af..21d6b93263ae304420df30429b746ccf4e0cd913 100644 (file)
@@ -10,8 +10,8 @@ main :: (args: [] cstr) {
 
     nps : NewPolyStruct(i32, 4);
 
-    for ^x: nps.x do *x = 12345;
-    for ^y: nps.y do *y = 67890;
+    for &x: nps.x do *x = 12345;
+    for &y: nps.y do *y = 67890;
 
     for x: nps.x do println(x);
 
index ddddedb96dff37556991070d43774706a051b450..be9290782234448e565fd511f85317f52612720a 100644 (file)
@@ -8,7 +8,7 @@ main :: (args) => {
 
     println(x);
 
-    for iter.as_iter(^x) {
+    for iter.as_iter(&x) {
         if it % 2 == 0 {
             #remove;
         }
index aaf1875a34dd749217537844ce8cbf639d939bec..bea6234f344b4301b3f639c39fcb9df8e073b080 100644 (file)
@@ -6,15 +6,15 @@ main :: (args: [] cstr) {
 
     S := set.make(i32);
 
-    set.insert(^S, 5);
-    set.insert(^S, 5);
-    set.insert(^S, 6);
+    set.insert(&S, 5);
+    set.insert(&S, 5);
+    set.insert(&S, 6);
     for entry: S.entries do println(entry.value);
 
-    println(set.has(^S, 5));
+    println(set.has(&S, 5));
 
     println("--------------");
-    set.remove(^S, 5);
+    set.remove(&S, 5);
     for entry: S.entries do println(entry.value);
-    println(set.has(^S, 5));
+    println(set.has(&S, 5));
 }
\ No newline at end of file
index 9f722810921340d9f7093ffe3f9b3f443608c465..0e97c8702508caea5199e86b03ea21d1bd2b6a98 100644 (file)
@@ -6,17 +6,17 @@ main :: (args: [] cstr) {
     some_string := "This is a test string that can be read.\n\n\n\n\n\n1234 4567";
 
     sstream := io.buffer_stream_make(some_string);
-    sreader := io.reader_make(^sstream);
+    sreader := io.reader_make(&sstream);
 
     for i: 0 .. 2 {
-        word := io.read_word(^sreader, allocator=context.temp_allocator);
+        word := io.read_word(&sreader, allocator=context.temp_allocator);
         println(word);
     }
 
-    println(io.read_line(^sreader, consume_newline=false, allocator=context.temp_allocator));
+    println(io.read_line(&sreader, consume_newline=false, allocator=context.temp_allocator));
 
-    a := io.read_u32(^sreader);
-    b := io.read_u32(^sreader);
+    a := io.read_u32(&sreader);
+    b := io.read_u32(&sreader);
 
     println(a);
     println(b);
index 14686b20251af1970eae1b96a77834cfdfe7a261..a280651303bb9405bbbe8a2189ca19754e16a20c 100644 (file)
@@ -2,30 +2,30 @@
 use package core
 
 Person_Vtable :: struct {
-    greet: (^Person) -> void;
+    greet: (&Person) -> void;
 }
 
 Person :: struct {
-    use vtable: ^Person_Vtable;
+    use vtable: &Person_Vtable;
 
     name: str;
 }
 
 nice_person := Person_Vtable.{
-    greet = (use p: ^Person) {
+    greet = (use p: &Person) {
         printf("Hello, I am {}!\n", name);
     }
 }
 
 mean_person := Person_Vtable.{
-    greet = (use p: ^Person) {
+    greet = (use p: &Person) {
         printf("Go away!! {}\n", typeof greet);
     }
 }
 
 main :: (args) => {
-    billy := Person.{ ^nice_person, "Billy" };
-    charles := Person.{ ^mean_person, "Charles" };
+    billy := Person.{ &nice_person, "Billy" };
+    charles := Person.{ &mean_person, "Charles" };
 
     billy->greet();
     charles->greet();
index d978577a60c2e3263f88fab917fc96862f4fcb8e..34ca9c551366603132a13430ebf67b54d56896ed 100644 (file)
@@ -16,7 +16,7 @@ new_va_test :: (prefix: str, va: ..any) {
         // The right way to do it is this:
         // x := * misc.any_as(va[i], i32);
 
-        x := *cast(^i32, va[i].data);
+        x := *cast(&i32, va[i].data);
         println(x);
     }
 }