On Mon, Dec 27, 2010 at 18:49, Daniel Carrera <dcarr...@gmail.com> wrote:
snip
> That's cool. Thanks. I notice it works on numbers and string literals:
> "hello".WHAT   # Str()
> 3.WHAT         # Int()
> 3.3.WHAT       # Rat()
> pi.WHAT        # Num()
> (1+3i).WHAT    # Complex()
>
> But it seems to give very inconsistent results when applied to functions:
> print.WHAT  # Bool()
> say.WHAT    # [blank]
> sin.WHAT    # [error]
snip

That is because you are calling the WHAT on the function's return
value, not on the function itself.  For instance,

{ 5 }().WHAT;
{ "foo" }().WHAT;

will retrun Int() and Str() because that is what those lambdas return, but

{ 5 }.WHAT;

returns Block(), because that is what it is.  Similarly,

sub f { 5 }
&f.WHAT;

returns Sub(), and

&say.WHAT

returns Multi() because that is what they are.

snip
>> 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.
>
>
> What is TTIAR?
snip

It is an error to have Two Terms In A Row.


-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

Reply via email to