develooper Front page | perl.perl6.users | Postings from August 2021

intermixed types and resulting types

Thread Next
From:
Joseph Brenner
Date:
August 21, 2021 01:15
Subject:
intermixed types and resulting types
Message ID:
CAFfgvXUnM29-kGTrT1fGxeY2afjAgA-11FixCoyKT32ZAnVfpw@mail.gmail.com
There are some object types that are "compatible" in certain ways, for example:

 o   You can do arithmetic operations on any Numeric types, a Rat
      minus and Int just works (and gives you a Rat).

 o   You can do set operations on any of the QuantHash types
      (and some other things, like Arrays), so you can take
      the set difference of a Mix and a Bag (and you'll get a Mix).

How would you know what types are compatible for a particular operation?

Is there a way to know what the resulting type is going to be?
Is there some sort of rule about using the least-specific
possible type?

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