groff
[Top][All Lists]
Advanced

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

Re: [Groff] Re: .substring bug - indicies don't work as documented(?)


From: Ralph Corderoy
Subject: Re: [Groff] Re: .substring bug - indicies don't work as documented(?)
Date: Sun, 28 Oct 2001 08:56:38 +0000

Hi Bernd,

> BTW how about defining a single argument meaning the corresponding
> character, e.g. ".substring s 1" the first letter and ".substring -1"
> the last letter.

At the moment it just requires duplicating the argument.

    .substring s i i

> It is illogical to start with 1 from the front and with 0 from the
> end.

Using zero for the end of the string and negative back from there makes
it easy to refer to the last three characters without doing the maths
based on string length.

> Moreover, 0 means everything up to behind the last character; so the
> last character should be -1 anyway.

Don't quite get your point on this bit.

> Also 2 args in reversed order could be made into reversing the
> output.

Yes, it could be.  I guess it depends on whether reversing the string
or having the indices in the wrong order is more common.  This way
avoids the `if (i1 > i2) swap(i1, i2)'.  Another option would be
Python's way of returning an empty string which is again sometimes what
you want.


Ralph.


reply via email to

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