Patrick R. Michaud wrote: > On Thu, Aug 28, 2008 at 08:32:41AM -0700, Carl Mäsak wrote: >> r30590: >> $ ./perl6 -e 'regex a { b }; "b" ~~ a' >> too few arguments passed (0) - 2 params expected >> [...] >> >> I've also added tests for this in t/spec/S05-metasyntax/regex.t. >> >> (S05 is not entirely clear as to whether this should actually work. >> IMHO, there's noreason for it not to. Storing anonymous regexes in >> scalar variables already works.) >> >> $ ./perl6 -e 'my $a = regex { b }; say "b" ~~ $a' >> b > > For now I'm going to claim that Rakudo has this one correct. The > difference between the first and second examples above is that in > the scalar variable example, the $a variable passed to infix:<~~> > contains the regex sub itself, whereas in the first example the > a regex is being invoked as a 0-argument listop prior to calling > the smart match.
I'm not quite sure. To quote S03: "The first section contains privileged syntax; if a match can be done via one of those entries, it will be. These special syntaxes are dispatched by their form rather than their type." [...] $_ X Type of Match Implied Match if (given $_) ====== ===== ===================== =================== Any Code:($) item sub truth X($_) So what does the "Code" mean? A code object? or the name of a sub? Since it says that the first dispatch is based on the form, I could imagine that ~~ has some kind of macro semantics, actually. CC'ing p6l in the hope of some clarification. Cheers, Moritz -- Moritz Lenz http://moritz.faui2k3.org/ | http://perl-6.de/