Type combinations

Peter Hall peter.hall at memorphic.com
Sat Nov 24 06:37:47 PST 2007

Is there any way to express an "intersection" type, analogous to a
union type? I can see there may be fewer use cases that there are for
union types, but they could be useful in the following cases:

1. An argument must implement two interfaces, but it's not practical
to introduce a 3rd interface to unify them as a single type.
2. An argument must be some subtype of a given type, but also
implement one or more additional interfaces.

A trivial example (using dubious syntax):

function replicateObject(obj:(DisplayObject & IClonable)):void
   var copy:DisplayObject = obj.clone();

I know that proposals are closed now, but this seems simpler than -
and complimentary to - union types.


More information about the Es4-discuss mailing list