A Lazy Sequence

A clarification

Duck-wrapping is not exactly function or method overloading. Consider the type T<Any> ∪ Any. Any is any type in the program and T is some wrapper type (here parameterised over Any) and together they form a type union. The problem arises because T<Any> is part of the set of types Any. Therefore T<T<Any>> is also valid for either side of the union.

Contrast this with T<Number> ∪ Number. There is no ambiguity in this type. Likewise String ∪ Element is not ambiguous (and doesn't wrap either). These could both be implemented with method overloading but would not be duck-wrapping.

18 April 2013