John Porter replied to what
> Ted Ashton wrote:
> > John Porter:
> > >
> > > What would be the output of the following program:
> > >
> > > $\ = "\n";
> > > $i = 0;
> > > for ( .. -1 ) {
> > > $i++;
> > > last if $i > 2;
> > > print
> > > }
> > >
> > > If the answer is (as I suspect), "This never prints anything; it goes
> > > into an infinite loop just trying to generate the first number", then
> > > the proposal is absurd and should be scrapped.
> >
> > By my understanding (which is definitely not very thorough), the output would
> > be a run-time error.
>
> What error message? "Program never halts!" ???
:-). I don't know, really. This proposal, while interesting to me, isn't
mine and is pretty much a new thought. My guess would be that the actual list
implementation would be to not unroll anything until it was needed and so the
print or the for would notice that the output is still based on "coming from
infinity" and would die.
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;
}
would either have to error out, count backwards from -1 or go into an infinite
loop trying to find the beginning. Perhaps one of the proponents can enlighten
us. After all, even mathematical induction cannot generate all the elements
of (..-1) unless it starts at -1 and goes backward.
Ted
--
Ted Ashton ([EMAIL PROTECTED]), Info Sys, Southern Adventist University
==========================================================
Whereas at the outset geometry is reported to have concerned herself with
the measurement of muddy land, she now handles celestial as well as
terrestrial problems: she has extended her domain to the furthest bounds of
space.
-- Frankland, W.B.
==========================================================
Deep thoughts to be found at http://www.southern.edu/~ashted