9.3.3 Method dispatch and unions
When a type is a union, Dylan uses the following rules:
1. An object is an instance of a union if it is an instance of any of the types that make up that union.
2. If none of the types that make up a union is a subtype of any other, then
A nonunion type is a proper subtype of a union if the nonunion type is a subtype of any of the types that make up the union.
A union is a proper subtype of a nonunion type if all types that make up the union are subtypes of the nonunion type, and if all the types that make up the union, taken together, are not equivalent to the nonunion type.
A union is a proper subtype of another union if each of the types that make up the first union is a subtype of one of the types that make up the other union, and if the two unions are not equivalent.
For example, suppose that we have these definitions:
define constant <false-or-integer> = type-union(<integer>, singleton(#f)); // Method 1 define method say (x :: <false-or-integer>) ... end method say; // Method 2 define method say (x :: <integer>) ... end method say;
Now, if say is called with an argument that is an integer, both methods are applicable, and method 2 is more specific than method 1. If say is called with an argument of #f, only method 1 is applicable.




