On Fri, Apr 04, 2014 at 13:04:28 -0700, Walter Bright wrote:
> On 4/4/2014 12:05 PM, bearophile wrote:
> >And with "enum precondition" in the succ() function you can do both cases
> >with a
> >single function:
> >array[Index.A.succ] = t;
> >auto i = Index.A;
> >array[i.succ] = t;
> What about i+10? Do you expect the person to write
> i.succ.succ.succ.succ.succ.succ.succ.succ.succ.succ? Sorry, that sux!
You say that, I see a pattern:
Presumably, you'd have something like:
iter :: Int -> (a -> a) -> a -> a
so you'd have:
array[iter(j, succ, i)]
But really, I think using an interface (cf Ix referenced elsewhere in
the thread) rather than a concrete type for array indices may have been
better, but I also think that ship has sailed here.
> And what about:
> int j;
Why would you be adding arbitrary integers to enumerations and expecting
a valid result?
> And forcing the user to use templates to do any logical or arithmetic
> operations on enum operands? It's just awful.
Again, interfaces :) .