develooper Front page | perl.perl6.language | Postings from September 2005

Re: Stringification, numification, and booleanification of pairs

Thread Previous | Thread Next
From:
Damian Conway
Date:
September 22, 2005 03:49
Subject:
Re: Stringification, numification, and booleanification of pairs
Ingo Blechschmidt asked:

>     my $pair = (a => 42);
>     say ~$pair;  # "a\t42"? "a\t42\n"? "a 42"?

Not yet specified but I believe it should be "42" (i.e. stringifies to value).

Note that S02 does specify that pairs *interpolate* to key-tab-val-newline,
so you can still get "a\t42\n" by writing "$pair" instead.


>     say +$pair;  # 0 (pairs aren't numbers)?
>                  # 42?
>                  # 0 ("a" is not a number)?
 >                  # 0 (~$pair can't be used as a number)?

Not yet specified, but I believe it should be 42 (i.e. numerifies to the value)


>     say ?$pair;  # true (because 42 is true)?
>                  # true (because pairs are always true)?

Not yet specified but I believe it should be true because 42 is true

In summary: when applied to a pair, the value-coercing operators should coerce 
the pair's value.

Damian

Thread Previous | Thread Next


Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About