On 2010-07-28 06:54, Martin D Kealey wrote:
On Wed, 28 Jul 2010, Michael Zedeler wrote:
Writing for ($a .. $b).reverse -> $c { ...} may then blow up because it
turns out that $b doesn't have a .succ method when coercing to sequence
(where the LHS must have an initial value), just like
for $a .. $b -> $c { ... }
should be able to blow up because the LHS of a Range shouldn't have to
support .succ.
Presumably you'd only throw that except if, as well, $b doesn't support .pred ?
Yes. It should be .pred. So ($a .. $b).reverse is only possible if
$b.pred is defined and $a.gt is defined (and taking an object that has
the type of $b.pred). If the coercion to Sequence is taking place first,
we'll have to live with two additional constraints ($b.lt and $a.succ),
but I guess it would be easy to overload .reverse and get rid of those.
Regards,
Michael.