Dropped Features
Multitypes
function foo( x : Int|String ) { switch(x) { case Int: // x is Int case String: // x is String } } class Foo<T: Int|String> { var data : T; }
A multitype is a new type that consists of several subtypes : these subtypes need to be runtime-checkable (no structures, no type-parameters, no Dynamic).
The semantics of switch is changed when used on a multitype. It requires a case for each subtype (or "default"). In each case expression, the variable is retyped accordingly to the matched subtype.
- limited : the type needs to be checkable at runtime, which is limited
- slow : because of runtime type checks
- hard to implement
- requires an additional
switchsemantic - overlaps with
usingwhich could be improved to implement pseudo-polymorphism @:multitypemetadata cover the needs for extern classes
version #10194, modified 2011-02-17 18:22:43 by hudson