Raku / old-design-docs

Raku language design documents
https://design.raku.org/
Artistic License 2.0
124 stars 36 forks source link

Interpolation of scalar array in regexes #39

Closed pmichaud closed 11 years ago

pmichaud commented 11 years ago

What's the result of something like...?

 my $x = [<a b c d>];  'a b c d' ~~ / $x /;

Is $x treated like a scalar, in which case the entire Array is stringified and matched, or is $x treated like an alternation of elements from the array?

Contrast with:

my @x = <a b c d>;   'a b c d' ~~ / @x /;

In this case, we know that it's an alternation of matches.

Pm

TimToady commented 11 years ago

$x is now always stringified (no regex dwimming, no alternation semantics). Use @$x to force alternation now, and <$x> to force regex interpolation.

pmichaud commented 11 years ago

For reference, the updated spec commit is f252dcef.