Luke Palmer wrote:
But I counter that arguability by saying that you really shouldn't be
putting one() in type signatures. If you want something to be an A or a
B, and you're not doing any checking later on in the code, then it's
fine if it's both A and B. If you are doing checking later on, then it
should either be in a multimethod or you should factor it out into an
abstract type. Perl's not so keen on what you "should" do, though, but
I offer this as solace for those who wish to break the guidelines:
sub foo ( one(Dog, Cat, Horse) $x )
I think there is a practical application of this. If the classes are
derived from the same base e.g. Mammal then &foo<Dog^Cat^Horse> cannot
be called with a Mammal instance but &foo<Dog|Cat|Horse> could. The former
also excludes junction types. In the latter case there are seven matching
types when superclasses are neglected: Dog, Cat, Horse, Dog|Cat, Dog|Horse,
Cat|Horse and Dog|Cat|Horse.
I also have another idea where the exclusivity of one() is usefull, but
I don't know how to write that in Perl6. I want a
method
Mammal::reproduce( Mammal[male^female] $self:
Mammal[$self.type ^ (male|female)] $partner )
returns Mammal[male^female];
Am I making sense?
--
TSa (Thomas SandlaÃ)