On Thu, Dec 04, 2008 at 07:00:55PM +0100, Moritz Lenz wrote: > GW wrote: > > I found something that could be problematic (haven't yet found out if it > > should be a special case) in Synopsis 5. More precisely it is under the > > chapter "Accessing captured subrules" in the test case > > t/regex/from_perl6_rules/capture.t lines 67–71: > > > > ok(eval(' "bookkeeper" ~~ m/<single> ($/<single>)/ '), 'Named backref', > > :todo<feature>); > > > > How can the parser know what you mean by $/<single>? Maybe you want $/ > > followed by <single> or maybe $/<single>?
I suspect $/<single> would parse as a single variable. If you want the separate subrule one can use whitespace (as noted in other posts) or brackets (if whitespace is an issue): [$/]<single> > The same rule applies for interpolation in strings: > > "my big $house.uc" is parsed as "my big { $house.uc }", ie $house.uc is > taken as one token, even though a valid interpretation would be to > interpolate $house first and then append .uc to that string. Alas, this is not exactly the case here. Interpolation in strings only occurs for things that end with a postcircumfix (parens, braces, brackets), thus my $house = 'building'; say "a big $house.uc"; # "a big building.uc" say "a big { $house.uc }"; # "a big BUILDING" say "a big $house.uc()"; # "a big BUILDING" say "a big { $house }.uc"; # "a big building.uc" > The Perl 6 solution is that you disambiguate with whitespace if you > don't want to follow the LTM-rule (ie you'd say '$/ <single>' in the regex). I think I would tend to recommend disambiguating with brackets instead of whitespace -- it's slightly more explicit (similar to how we recommend disambiguating with parens in other types of expressions). Pm