Result type of hyperoperators in Raku

Viewed 80

I am curious what rule determines the type of an expression including a hyperoperator. Let us consider these four kinds of Positionals:

my $ca = [1, 2];   # containerized array  $[1, 2]
my $ua := [1, 2];  # uncontanerized array [1, 2]
my $cl = (1, 2);   # containerized list   $(1, 2)
my $ul := (1, 2);  # uncontainerized list (1, 2)

I have observed that evaluating x «+» y, where x and y are taken from the above, results in an object of x's kind (cont./uncont.; array/list), e.g. $cl «+» $ua is $(2, 4).

However, the expression 0 «+» y is an object of y's kind, even though the docs claim that the left-hand side is converted to a list first. So 1 «+» $ua is [1, 2], while I would expect it to be (1, 2).

What is the actual rule for the result type of a hyperoperator application?

0 Answers
Related