Larry Wall wrote:
On Tue, Mar 01, 2005 at 11:06:17PM -0600, Rod Adams wrote:
: Since the line between rules and subs is already blurring significantly, : I want to blur it a little more. I want to write rules which can take : parameters.
No problem. That's how the arguments to rules like <before foo> are
already passed.
Excellent!
Of course, one can call them like ordinary methods too, as long as one
supplies an appropriate pattern-matching context invocant. But it's
pretty handy to have that magically supplied for you inside <...>.
Now for the tricky part.
rule baltag (Str $tag, Str $body is rw) { \< $tag .*? \> $<body> := (.*?) \</ $tag \> }
$buffer ~~ / <baltag title $<body>> .* \> <$body> \< /;
In other words, I want to pass a possibly unbound hypothetical into a subrule, and let the subrule bind/rebind it.
Alternatively would be a syntax for calling the subrule, and then binding a hypothetical to one of the hypotheticals returned in the subrule. I'm moderately sure S05 made this possible, but I couldn't put all the pieces together. I'll hazard the following guess:
rule baltag (Str $tag) { \< $tag .*? \> $<body> := (.*?) \</ $tag \> }
$buffer ~~ / $<btag> := <baltag title> <($<body> := $btag<body>)> /;
Which seems very clumsy, especially if I wish to call it a lot. Be nicer if I could push the work onto the subrule.
Larry