groff
[Top][All Lists]
Advanced

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

[Groff] .substring


From: Bernd Warken
Subject: [Groff] .substring
Date: Wed, 26 Jun 2002 09:04:07 +0200
User-agent: Mutt/1.2.5i

In the info file, .substring is documented by:

 - Request: .substring str n1 [n2]
     Replace the string in register STR with the substring defined by
     the indices N1 and N2.  The first character in the string has
     index one.  If N2 is omitted, it is taken to be equal to the
     string's length.  If the index value N1 or N2 is negative or zero,
     it is counted from the end of the string, going backwards: The
     last character has index 0, the character before the last
     character has index -1, etc.

I remember that .substring was intended to become more compatible to
whatever.  It seems that this did not happen so far.  It still has the
first character as of index 1 and the last one as of index 0.  I do
not know about any other language with such a behavior.

C and Python use index 0 and -1 as the first and last index resp.,
and a range is determined by the `before' idiom.  This is not comfortable
to everyday thinking, but is quite handy once you got used to it - and
it is the standard for a host of languages.


The documentation of the first argument for .substring sounds a bit 
strange to me.  When using .substring the name of a string is passed,
not a register.  Maybe some register shows up internally, but you cannot
pass some of your registers to this request.

Bernd Warken


reply via email to

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