W= Andrew Wilson, AH=Austin Hastings
AH> This is really probably bad code. Maybe a better rule would be:
AH>
AH> rule same_color($color is Colorific)
AH> {
AH> <color> ::: { fail unless $color.looks_like($1); }
AH> }
AH>
AH> I KNOW that $color is an object-of-type-Colorific, while I'm not sure,
AH> frankly, what <color> is returning. Let Colorific handle that.
W>It's my understanding (such as it is) of regexen that subrules called
W>via <rule> capture their result in hypothetical variables. In
W>same_color, by the time you get into the code after the :::, $color
W>contains what was matched by <color>. So, if <color> matched at all, I
W>don't think you can call looks_like on $color because it's the
W>hypothetical result of <color> not a Colorific. Either that or it fails
W>because you said it was a Colorific and it's not. Or you tried to
W>assign to it but you can't because it's not C<is rw>.
So long as the regexp is grabbing unicode. I posit a modifier:
rule color { :ref (.) <( $1.isa(Colorific) )> }
$daylight = &peek_at_sky =~ /<color>/;
where ":ref" tells the engine that each atom is a reference, not
unicode. Then what matches is still Colorific.
On-the-side syntax question- what happens to modifiers that take arguments
when they're inside the rule? like from A5 "s:myoption($x) /foo/bar/",
can that be written "s/:myoption($x) foo/bar/" ? Wondering what happens
if the "ref" modifier can take an argument, saying what it's a ref of...
-y
~~~~~
The Moon is Waxing Crescent (1% of Full)