On Wed, Nov 28, 2012 at 7:20 AM, Accipiter Nisus <
acci...@gmail.com> wrote:
>
> Using revrange on a channel or map should indeed result in a compiler error.
> But, if that is an argument against reverse range, then the same could be
> said about other builtin's such as cap that doesn't work on strings, or
> append that only works on slices.
Since you can't do a reverse range on a channel or map, that leaves on
slices, arrays, and strings. Doing a reverse iteration over a slice
or array is trivial, and I doubt it is common enough that it deserves
a special syntax. That leaves only reverse iteration over strings.
While a reverse range on a string is not trivial, I doubt that it is
common. It can, of course, be implemented using functions that are
just as efficient as any possible runtime code.
So I don't see a compelling argument for adding new syntax for this.
It doesn't add very much. In my opinion, certainly not enough to add
a new keyword to the language.
Ian