Avoid creating temporary scalars when returning multiple arrays

Håk*_*and 9 perl6 raku

Is it possible to avoid creating temporary scalars when returning multiple arrays from a function:

use v6;
sub func() {
    my @a = 1..3;
    my @b = 5..10;
    return @a, @b;
}
my ($x, $y) = func();
my @x := $x;  
my @y := $y;
say "x: ", @x;  # OUTPUT: x: [1 2 3]
say "y: ", @y;  # OUTPUT: y: [5 6 7 8 9 10]
Run Code Online (Sandbox Code Playgroud)

I would like to avoid creating the temporary variables $x and $y. Note: It is not possible to replace the function call with

my (@x, @y) = func()
Run Code Online (Sandbox Code Playgroud)

since assignment of a list to an Array is eager and therefore both the returned arrays end up in @x.

rai*_*iph 11

都不是:

my ($x, $y) = func();
my (@x, @y) = func();
Run Code Online (Sandbox Code Playgroud)

但是代替以下任何一个:

my (@x, @y) := func();
my ($x, $y) := func();
Run Code Online (Sandbox Code Playgroud)

用于@向P6发出信号,当它需要区分某个事物是单数形式(“单个数组”)还是复数形式(“单个数组中包含的项目”)时,应将其视为复数形式。

用于$表示相反的信号-应将其视为单数。

您以后总是可以通过执行以下操作$@x来明确地扭转这种情况-表示P6应该对最初声明为复数的事物使用单数透视图-或表示@$x以相反的方式进行反转。

打个比方,想像一下切成几块的蛋糕。是一件事还是一堆碎片?还要注意,它会@缓存片段的索引,而$只记得那是一块蛋糕。对于大量事物,这可能会带来很大的不同。