Scott Bronson skribis 2004-06-24 10:44 (-0700):
> However, it seems that because Perl is finally getting a typing system,
> this hack can be fixed in Perl itself! No programmer intervention
> needed. Undef and '' can be false for strings, undef and 0 can be false
> for integers, undef, 0, and 0.0 can be false for floats, etc.
I think this makes sense:
string: undef, ""
number: undef, 0 (implies 0.0)
other: convert to number and then decide. Anything that can't
naturally be converted to a number (i.e. would be invalid syntax if
unquoted) is true.
/me wanted to write this in Perl 6, but couldn't think of a good way to
represent true and false when returning from &is_true :)
Perhaps having real true and false values (where true cannot be false
and false cannot be true) would make a lot of things much easier. I, for
one, would like "return true;" (where "true" is undef-ish: a keyword
that always returns the same value).
Juerd