为什么空的 Raku 形 Arrays 是真实的?

Why are empty Raku shaped Arrays truthy?

看到这个我有点吃惊:

> say my @i.so
False
> say my @i[3].so
True

谁能解释为什么在 raku 中,空数组是假的,而空 shaped 数组是真数组?

如果描述“空”指的是“没有元素”,那么就没有空的固定大小(又名“形状”)数组这样的东西:

say my @unshaped-array;                   # []
say @unshaped-array.shape;                # (*) ("whatever" shape, or "unshaped")

say @unshaped-array.elems;                # 0
say @unshaped-array.so;                   # False
say @unshaped-array[0,1,2]:exists;        # (False False False)
say @unshaped-array[0,1,2]:delete;        # ((Any) (Any) (Any))
say @unshaped-array[0,1,2]:exists;        # (False False False)
say @unshaped-array;                      # []

say @unshaped-array = [Any,Any,Any];      # [(Any) (Any) (Any)]
say @unshaped-array.elems;                # 3
say @unshaped-array.so;                   # True
say @unshaped-array[0,1,2]:exists;        # (True True True)
say @unshaped-array[0,1,2]:delete;        # ((Any) (Any) (Any))
say @unshaped-array[0,1,2]:exists;        # (False False False)
say @unshaped-array;                      # []

say my @shaped-array[3];                  # [(Any) (Any) (Any)]
say @shaped-array.shape;                  # (3)

say @shaped-array.elems;                  # 3
say @shaped-array.so;                     # True
say @shaped-array[0,1,2]:exists;          # (False False False)
say @shaped-array[0,1,2]:delete;          # (Nil Nil Nil)
say @shaped-array[0,1,2]:exists;          # (False False False)
say @shaped-array;                        # [(Any) (Any) (Any)]

say @shaped-array = [42];                 # [42 (Any) (Any)]
say @shaped-array.elems;                  # 3
say @shaped-array.so;                     # True
say @shaped-array[0,1,2]:exists;          # (True False False)
say @shaped-array[0,1,2]:delete;          # (42 Nil Nil)
say @shaped-array[0,1,2]:exists;          # (False False False)
say @shaped-array = [Nil];                # [(Any) (Any) (Any)]

# Just because I named the array "shaped", doesn't mean its shape is fixed:

say @shaped-array := [Nil];               # [(Any)]
say @shaped-array.shape;                  # (*) ("whatever" shape, or "unshaped")
say @shaped-array := [];                  # []
say @shaped-array.elems;                  # 0
say @shaped-array.so;                     # False

my @i[0];                                 # Illegal ...

我不知道目前是否有办法声明一个永久绑定到固定形状数组的变量。