On Sat, 09 Jul 2016 19:48:54 -0700, c...@zoffix.com wrote: > Still present in rakudo 405519 > > <Zoffix> m: my token foo ($a) { <$a> }; > <camelia> rakudo-moar 405519: OUTPUT«===SORRY!=== Error while > compiling <tmp>Variable '$a' is not declaredat <tmp>:1------> my > token foo ($a) { <⏏$a> };»
In addition to compiling, actually calling the regex presents some additional restrictions: To use arguments with the <&a()> form, you cannot use a sub or method: $ perl6 -e 'my method a () { "a" ~~ /aa/ }; my token foo { <&a()> }; say "aa" ~~ /<foo>/' Cannot look up attributes in a Nil type object in regex foo at -e line 1 in block <unit> at -e line 1 ...but regexes work fine. To use the <&a> form, you merely need to define it in the parent scope: $ perl6 -e 'my token foo { :my regex a { a }; <&a> }; "aa" ~~ /<foo>/' ===SORRY!=== Error while compiling -e Undeclared routine: a used at line 1 $ perl6 -e 'my regex a { a }; my token foo { <&a> }; say "aa" ~~ /<foo>/' 「a」 foo => 「a」 $ perl6 -e 'my token a { a }; my token foo { <&a> }; say "aa" ~~ /<foo>/' 「a」 foo => 「a」 $ perl6 -e 'my sub a ($cursor) { "aa" ~~ /a/ }; my token foo { <&a> }; say "aa" ~~ /<foo>/' 「a」 foo => 「a」 $ perl6 -e 'my method a ($cursor:) { "aa" ~~ /a/ }; my token foo { <&a> }; say "aa" ~~ /<foo>/' 「a」 foo => 「a」 ... ...however to use the <a> form and hit a lexical method, it can be directly in the scope: $ perl6 -e 'my token foo { :my regex a { a }; <a> }; say "aa" ~~ /<foo>/' 「a」 foo => 「a」 a => 「a」 bri@atlas:~/git/roast$ perl6 -e 'my regex a { a }; my token foo { <a> }; say "aa" ~~ /<foo>/' 「a」 foo => 「a」 a => 「a」 ...but is must be a regex, not a sub or method $ perl6 -e 'my method a ($cursor:) { "aa" ~~ /a/ }; my token foo { <a> }; say "aa" ~~ /<foo>/' No such method 'a' for invocant of type 'Match'. Did you mean 'at'? in regex foo at -e line 1 in block <unit> at -e line 1 $ perl6 -e 'my sub a ($cursor) { "aa" ~~ /a/ }; my token foo { <a> }; say "aa" ~~ /<foo>/' No such method 'a' for invocant of type 'Match'. Did you mean 'at'? in regex foo at -e line 1 in block <unit> at -e line 1 ... that latter part may be to spec. However the spec, after being very careful to only talk about regexes when describing <a>'s lexical predelictions, if this is indeed intentional, slips up by dropping the word "routine" in the last paragraph of that section. A bit of spec clarification would help there. Internally, <&a> seems to route through assertion:sym<var> which installs a CALL_SUBRULE invocation, and <a> routes through assertion:sym<name> which tacks on a '&' sigil, perfoms a $*W.regex_in_scope check, verifies that there was no dot preceding it, and then creates a new lexical var of the same sigiled name, but does not use a CALL_SUBRULE instruction... just sets up RX QAST nodes. The tests in S05-metasyntax/angle-brackets.t auto-RTed as RT#124519 through RT#124523 make a lot of wrong assumptions about what the return value is and what gets done with it.