Just out of curiosity, is there not a clause in the string section that says "strings are indexed starting from 1"? I recall writing something like that a while ago... ------Original Message------ From: James Paige Sender: [email protected] To: [email protected] ReplyTo: [email protected] Subject: Re: [Ohrrpgce] SVN: james/3415 Clarify the documentation for"replace char" "delete char" and "ascii fr Sent: Feb 26, 2010 10:58 AM
On Fri, Feb 26, 2010 at 01:50:16PM +1300, Ralph Versteegen wrote: > On 26 February 2010 08:32, <[email protected]> wrote: > > james > > 2010-02-25 11:32:11 -0800 (Thu, 25 Feb 2010) > > 230 > > Clarify the documentation for "replace char" "delete char" and "ascii from > > string" > > to specify that the position is indexed starting with 1 and going to > > "string length" > > (as opposed to starting at 0 and going to string length -- 1) > > --- > > U wip/docs/plotdict.xml > > U wip/docs/plotdictionary.html > > So I suppose that when string indexing using array subscripts is > added, it'll disagree with the existing string commands. Since > everything else in the engine uses 0 to num - 1 indexing, it would be > really inconsistent to make array indexing different, and it would be > extremely inconsistent to make string indexing an exception. > > Actually, "ascii from string", "string length", and if strings are > mutable, "replace char" will all have replacements, so will be > obsolete. Guess we could add either a remove-from-array command and > overload it to act on strings, or python's "del foo[i]" to replace > "delete char". Yeah, I am a lot more confortable with 0-based indexing. I was writing some code using ascii from char and it was driving me crazy that it wouldn't work right. When I looked at the source code I realized about the 1-based index, which i what prompted me to update the docs. I see no problem with having the "real" strings do indexing differently from the old-style strings, as long as the difference is documented. --- James _______________________________________________ Ohrrpgce mailing list [email protected] http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org -- Mike Caron _______________________________________________ Ohrrpgce mailing list [email protected] http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org
