One method-like thing that's come in handy for me as I've tinkered with the
language is .WHAT.
{ ... }.WHAT
Block()
AFAIK, you can use .WHAT on *any* term, because every term in Perl6 is an
object that is implemented by a class, and every class has a corresponding type
object (which is what .WHAT returns for you).
This might not have helped you had you not realized that {%matches{$p1}++} is a
term. However, if you keep in mind that TTIAR is always a syntax error in
Perl6, then if your code is compiling, whatever is between ?? and !! must be a
single term.
It's really the TTIAR thing that makes reading Perl6 so incredibly predictable,
I think.
/Perl6 weenie signing off
On Dec 27, 2010, at 06:17 PM, Daniel Carrera wrote:
> On Mon, Dec 27, 2010 at 10:03 PM, Chas. Owens > { } by itself creates a
> lambda (i.e. an anonymous function), so it may
>
>>> be that you are returning an anonymous function that never gets
>>> executed. Try using parentheses instead of braces.
>>
>> Or better yet, don't use anything. Since ++ has higher precedence
>> than ??!!, it doesn't need to any parentheses:
>>
>> $r1 > $r2 ?? %matches{$p1}++ !! %matches{$p2}++ ;
>>
>
>
> Ah. That makes sense. I hadn't realized that squiggly brackets were lambdas.
> Very cool. To prove that they are lambdas, I confirmed that the following
> works:
>
> $r1 > $r2 ?? {%matches{$p1}++}() !! {%matches{$p2}++}();
>
> So, in this needlessly complex code, I basically create an anonymous
> function and immediately execute it.
>
> Cheers,
> Daniel.
> --
> No trees were destroyed in the generation of this email, but a large number
> of electrons were severely inconvenienced.