HaloO,

David Green wrote:
Using int8 vs Int is presumably a performance issue, but "int8 29" and "Int 29" *mean* the same thing, so they should be ===. An Enum doesn't mean the same thing as a plain Int, so it shouldn't.

IIRC, === is defined to compare only values from the same type domain.
For values from different domains it is false. The question I want to have answered here is in which respects int8 differs from Int and which
they have in common and how that is expressed in Perl 6. E.g. Int could
be a role and int8 is a class that does this role. The standard
implementation for integers is some BigInt class that also does the Int
role. This class has to be known to other types like int8 for failover
when their range of values is left. Well, int8 could failover to int16
first.

I wonder if int8 being a class that does the Int role can thus be used
as implementation type of a variable:

   my $x is int8;

Would that also imply a constraint of int8?

I guess all my concerns boil down to the fact that I don't understand
what a protoobject which is returned by WHAT exactly is. E.g. how
can int8 and BigInt share the Int protoobject such that === compares
them.


(As you point out, you can always use something like "Weekday::Sun eq Star::Sun" or "Weekday::Sun == 0" if you want string or numeric equality.)

Yes, these comparisons are well defined in the Str and Num domains.


Regards, TSa.
--

"The unavoidable price of reliability is simplicity" -- C.A.R. Hoare
"Simplicity does not precede complexity, but follows it." -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12  -- Srinivasa Ramanujan

Reply via email to