In the code below, the Regex $r clearly "knows" that it contains the text bar – that's how it is able to match against the Str bar. But .gist and .raku report that $r contains the variable $foo without saying what value $foo contains. Is there any way to get $r to tell me its computed value?
sub f {
my $foo = 'bar';
g(rx/$foo/);
}
sub g($r) {
say $r.gist;
say 'bar' ~~ rx/$r/;
}
f # OUTPUT: rx/$foo/
# 「bar」
(I know that I can access the same information by manually parsing $r, finding all variables, and then walking &g's callframes to find the values of the variables. But that seems like a fairly brittle hack to get at info that the Regex clearly already knows, at least on some level.)