Ted Ashton wrote:
> I understand very well the concern.  I, for one, don't agree that having
> (1..) in the language implies that having (..-1) is possible (though it
does
> make sense to me that having (1..) and (..-1) would imply having (..)).
After
> all, if I were to write
>
>   for (1..) {
>     print;
>   }
>
> I would get an infinite loop, but one which was doing something, whereas
>
>   for (..-1) {
>     print;
>   }
>
The reason that having (1..) implies having (..-1) is that if you allow
(1..), then this is a valid construct:

  @dot_dot_neg_one = reverse (map {-$_} (1..));

which is identical to (..-1)! So scrapping (..-1) doesn't actually win you
anything, in terms of avoiding 'impossible loops'.

The only way around all this, IMO, is to require that the domain of indexes
of an infinite loop be specified before the list is output in any way.
'Output' includes reduction of the list (see RFC 76). The domain could be
specified explicitly, or could in some cases be derived by Perl implicitly
from the context of the expression.


Reply via email to