groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Groff] pic problem


From: Werner LEMBERG
Subject: Re: [Groff] pic problem
Date: Mon, 19 Jul 2004 09:03:07 +0200 (CEST)

> > The only way I can account for all of A, B, C, D is that the logic
> > of the loop
> >
> >   for n = a to b by c do {...}
> >
> > is:
> >
> >   [1] Set n = a.
> >   [2] If a > b, break; else execute {...}
> >   [3] increment a by c [default 1], and go to [2].
> >
> > which would presuppose that a <= b to start with, and c > 0.
> > Not the logic one would expect!
> 
> Interesting... have I actually uncovered a bug?

After checking again, you haven't.  In the current pic.man, you can
find the following:

  for variable = expr1 to expr2 [by [*]expr3] do X body X
         Set variable to expr1.  While the value of variable is less than
         or equal to expr2, do body and increment variable by  expr3;  if
         by  is not given, increment variable by 1.  If expr3 is prefixed
         by * then variable will instead be multiplied by expr3.   X  can
         be any character not occurring in body.

Note the `less than or equal' which implicitly means that `by' must be
non-negative.  The same can be found in pic.ms.

Anyway, I've fixed it now by allowing `by' to be negative also (except
for the multiplicative case where `by' must be positive).


    Werner


reply via email to

[Prev in Thread] Current Thread [Next in Thread]