Jon Lang wrote:
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] { ... }

If the question is "can you define multiple roles with the same name, but taking different signatures", then the answer is yes, and that it goes by the same rules as multiple dispatch (and it's even been implemented :-)). What you pasted won't quite work, however, as you can't write multiple types before a parameter (at least in 6.0.0). So you'd want something more like:

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

Hope this helps,

Jonathan

Reply via email to