develooper Front page | perl.perl6.language | Postings from August 2010

Re: Smart match isn't on Bool

Thread Previous | Thread Next
From:
Darren Duncan
Date:
August 1, 2010 14:53
Subject:
Re: Smart match isn't on Bool
Message ID:
4C55ECB0.5050505@darrenduncan.net
TSa (Thomas Sandlaß) wrote:
>> ... unless you want C<when True> to do a value-and-type check,
>> in which case it doesn't exactly follow the pattern for smartmatching
>> of the other builtin types (which only check value equivalence,
>> not type equivalence).
> 
> This is true only if you want to distinguish 1 and True which are the
> same value. But 42 should be distinct from this. Same goes for "viaduct".
> So these three should be a valid disjoint set of choices that can be
> made given $something.

Is that so?  1 and True *are* the same value now?  Not Bool wraps Int rather 
than being a subset type and it and has wholly distinct values?

Carl Mäsak wrote:
 > I don't know whence you got the impression that Bool is a subtype.
 > Bool is an enumeration type, which makes True and False distinct
 > objects both of which aren't (but instead wrap) their corresponding
 > Int values.
 >
 >> Asking "False eqv 0" should be false, though either "False eqv ?0" or
 >> "+False eqv 0" being true is okay.
 >
 > All those are as you want them.

I would like for what Carl said to be true, but TSa seems to be contradicting it.

1 and True should *not* be the same value, and they should be distinguishable in 
any generic context like eqv or given-when.  They should only compare alike when 
cast into the same type such as with a ? or +.

-- Darren Duncan


Thread Previous | 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