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

Stringification, numification, and booleanification of pairs

Thread Next
From:
Ingo Blechschmidt
Date:
September 21, 2005 07:58
Subject:
Stringification, numification, and booleanification of pairs
Message ID:
loom.20050921T164009-963@post.gmane.org
Hi,

quick questions:

    my $pair = (a => 42);
    say ~$pair;  # "a\t42"? "a\t42\n"? "a 42"?
    say +$pair;  # 0 (pairs aren't numbers)?
                 # 42?
                 # 0 ("a" is not a number)?
                 # 0 (~$pair can't be used as a number)?
    say ?$pair;  # true (because 42 is true)?
                 # true (because pairs are always true)?

FWIW, I'd opt for ~$pair to be "a\t42", +$pair to be +(~$pair) [1],
and ?$pair to be always true.


--Ingo

[1] The numification of match objects used to *not* be the numification
    of their stringification, causing confusion, see
    http://tinyurl.com/asocc.


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About