Consider a Range role that is parameterized (i.e., "Range of T" is a
perfectly valid thing to do).  According to the spec, the definition of
Range depends on the nature of T:

* If the lower bound is Numeric, certain coercion rules are attempted on the
upper bound; otherwise, the two boundaries must have the same type.
** Speculation: if the lower bound is a Whatever, the boundary type should
be determined by the upper bound; if both are Whatever, treat it as Numeric?
* if the boundary type has a .succ method, then the Range can provide a
RangeIterator; otherwise, it can't.

Concerning that last one: would it be reasonable to have a Discrete role
that provides a .succ method, and then overload the Range role?  E.g.:

    role Range[Ordered ::T] { ... }

    role Range[Ordered Discrete ::T] {
        ...
        method iterator ( -> RangeIterator ) { ... }
    }

If so, then this approach might also be used to handle the special behavior
that comes with Numeric types:

    role Range[Ordered Numeric ::T] { ... }

-- 
Jonathan "Dataweaver" Lang

Reply via email to