24 Sep 2022
deoac   in block <unit> at bin/RakuTrek line 67 16:43
```
`    #| When the Enterprise moves into a new quadrant, this method should be 16:45
    #| called to update the galaxy.
    method refresh-quadrant (Location $old-loc, Location $new-loc) {
Nemokosch well, what is the code that gives the error?
deoac         my ($new-quad, $new-sect) = $new-loc.split;
        my ($old-quad, $old-sect) = $old-loc.split;
        my Quadrant $old-quadrant := $.quadrants[$old-quad.x;$old-quad.y];
        my Quadrant $new-quadrant := $.quadrants[$new-quad.x;$new-quad.y];
        # update the Enterprise
        $.Enterprise.location = $new-loc.clone;
        # update the new location
        $new-quadrant.has-enterprise = True;
        try { $new-quadrant.sectors[$new-sect.x;$new-sect.y] = $.Enterprise;
            CATCH { .say; .resume; };
        }
        # update the old location
        $old-quadrant.has-enterprise = False;
        try { $old-quadrant.sectors[$old-sect.x;$old-sect.y] = EmptySpace.new;
            CATCH { .say; .resume; };
$.quadrants is a 2-dim grid of sectors.  Sectors are a 2-dim grid of objects. 16:46
Errors are from the CATCH blocks
Nemokosch huh, kinda frightening 16:48
deoac Which? My code or the errors?
BTW, the first time I call this function, only the first CATCH is executed. 16:50
After that both CATCHes are triggered.
Nemokosch > Partially dimensioned views of shaped arrays not yet implemented. Sorry.
This error is okay, or I mean, a reasonable type of error
The other one seems kind of like nuclear reactors melting 16:51
deoac Yet, many times 'partially dimensioned views of shaped arrays' works just fine.
Nemokosch Well, that "shouldn't" work 16:52
deoac :-)
Nemokosch if your array is not 2-dimensional and you are providing 2 dimensions, that won't work, at least not at the moment
Kaiepi i wonder if `Failure`'s involved somewhere, somehow 16:54
deoac The arrays are definitely 2-dim.  If I remove one of the dimensions, I get the error `Cannot assign to a 2 dimension array with only 1 dimensions` 17:00
Nemokosch it could be a bug, hard to tell from this code 17:04
deoac New question. 20:09
Nemokosch go ahead 😅 20:10
deoac I have a sub that returns an array made up of three values - a Str, Array[Rat], Object - in that order.  How can a specify this with `returns` or `-->` ?
Nemokosch That is an excellent question but I'm afraid I'm not going to be of any use. I barely ever use type annotations. 20:12
lately I have heard of the Data::Record module made by Kaiepi: raku.land/zef:Kaiepi/Data::Record seems like it could come handy 20:13
gfldex m:``` 20:15
subset Stuffz of List where { .elems == 3 && .[0] ~~ Str && .[1] ~~ Array[Rat] && .[2] ~~ Any:D }
sub foo( --> Stuffz) {}
```
gfldex deoac: please note that you don't specify a return type with `returns`, you tell the compiler to do a runtime value check on returning a value.
Kaiepi `subset Stuffz of List:D where (Str, Array[Rat], Any:D)` should work too 20:21
deoac gfldex: Thanks, I'll use --> instead 20:25
gfldex --> and `returns` are equivalent
deoac Thanks for the `subset` tip.  They really are a nifty and useful part of the language!
gfldex Actually, they are a cludge to keep the gammar less complicated that it is already. :) 20:26
And they often provide LTA error messages. We really could do with tuples, like in Nim. 20:27