Dropped Features


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.

The multitypes proposal was dropped because it is :
  • limited : the type needs to be checkable at runtime, which is limited
  • slow : because of runtime type checks
  • hard to implement
  • requires an additional switch semantic
  • overlaps with using which could be improved to implement pseudo-polymorphism
  • @:multitype metadata cover the needs for extern classes
version #10194, modified 2011-02-17 18:22:43 by hudson