On Wed, Aug 10, 2005 at 03:53:00PM +0000, Luke Palmer wrote:
: A new development in perl 6 land that will make some folks very happy.
:  There is now a Set role.  Among its operations are (including
: parentheses):
: 
:     (+)   Union
:     (*)   Intersection
:     (-)   Difference
:     (<=)  Subset
:     (<)   Proper subset
:     (>=)  Superset
:     (>)   Proper superset
:     (in)  Element
:     (=)   Set equality
: 
: I believe the unicode variants are also allowed.

And now some people will begin to wonder how ugly set values will look.
We should also tell them that lists (and possibly any-junctions)
promote to sets in set context, so that the usual way to write a set
of numbers and strings can simply be

    <1 dog 42 cat 666.5>

: So now Type does Set, so we have:
: 
:     A (+) B     # type representing a value that is either A or B
:     A (*) B     # type representing a value that is both A and B
:     A (-) B     # type representing a value that is A but not B
:     etc.
: 
: So types are merely sets of (hypothetical, eventual) instances,
: together with a few operations to make introspection etc. easier.

And the type syntactic slot coerces to a set list, so instead of

    my Cat|Dog $meowoof;

we can write

    my (Cat,Dog) $meowoof;

though we might still allow the | notation for that as well, if "any"
also promotes to set.  (We can't allow unparenthesized & though, since
it's ambiguous with & as a sigil.)  There are still places where we
can use junctions as type constraints, but there are no junctional
base types because they can't always fit into a type lattice.  A type
junction just implies autothreading on the constraint checks, but
we won't try to reason with type junctions.

Larry

Reply via email to