On Wed, Apr 02, 2003 at 10:16:37AM -0800, Austin Hastings wrote:
> And the Colorific class supposedly has a way to determine if two colors
> look about like each other. Again, I don't know how that works, but I
> don't need to.
>
>> AH> rule same_color($color is Colorific)
>> AH> {
>> AH> <color> ::: { fail unless $1.looks_like($color); }
>> AH> }
>
> This is really probably bad code. Maybe a better rule would be:
>
> rule same_color($color is Colorific)
> {
> <color> ::: { fail unless $color.looks_like($1); }
> }
>
> I KNOW that $color is an object-of-type-Colorific, while I'm not sure,
> frankly, what <color> is returning. Let Colorific handle that.
It's my understanding (such as it is) of regexen that subrules called
via <rule> capture their result in hypothetical variables. In
same_color, by the time you get into the code after the :::, $color
contains what was matched by <color>. So, if <color> matched at all, I
don't think you can call looks_like on $color because it's the
hypothetical result of <color> not a Colorific. Either that or it fails
because you said it was a Colorific and it's not. Or you tried to
assign to it but you can't because it's not C<is rw>.
I think we need a P6 regexen engine to play with to get used to all this
new stuff properly :-) Oh, and I really, really don't like all this
extraneous type information that everybody seems to be sprinkling around
their Perl6 code.
andrew
--
Virgo: (Aug. 23 - Sept. 22)
It seems the danger is over for now, but something tells you that you
haven't seen the last of that dastardly villain.