On 1/11/07, Berger, Daniel <Daniel.Berger / qwest.com> wrote: > > -----Original Message----- > > From: Arnaud Bergeron [mailto:abergeron / gmail.com] > > Sent: Wednesday, January 10, 2007 9:20 PM > > To: ruby-core / ruby-lang.org > > Subject: Re: String#upto edge case - empty string causes infinite loop > > <snip> > > > > I understand your point, but I could just as well argue > > that there is > > > no logical successor to an empty string, and therefore it's > > a special > > > case. Another point to consider is that, if we have "".succ return > > > "0", we get this result from String#upto: > > > > I think you missunderstood something. I don't propose it > > returns "0" but "\000" which the character with ASCII value 0 > > (i.e. NUL). I agree it could be some other value, but why I > > chose this one is because that is the string with the > > "smallest" (as determined by <) value which is bigger than "". > > Hm, I guess if I think about it as null rather than 0 it makes more > sense. > > > > "".upto(2) => ["", "0", "1", "2"] > > > > > > Either approach feels more or less arbitrary. I vote to err on the > > > side of caution and stick with my original patch. :) > > > > I think this issue might not be as important as I let it show > > because this is not common code. I still feel that ("" < > > "".succ) == false is wrong though. > > > > However, if succ is not going to change, then it's better to > > have your patch than nothing. > > > > Last but not the least. I realize I have not provided a > > patch for my solution. Well here it is: > > > > --- string.c.orig Wed Jan 10 22:52:14 2007 > > +++ string.c Wed Jan 10 23:18:12 2007 > > @@ -1392,7 +1392,6 @@ > > > > str = rb_str_new5(orig, RSTRING(orig)->ptr, RSTRING(orig)->len); > > OBJ_INFECT(str, orig); > > - if (RSTRING(str)->len == 0) return str; > > > > sbeg = RSTRING(str)->ptr; s = sbeg + RSTRING(str)->len - 1; > > I guess either one works for me. I leave it to Matz to decide which he > prefers. I'm fine with that. > Regards, > > Dan > > > This communication is the property of Qwest and may contain confidential or > privileged information. Unauthorized use of this communication is strictly > prohibited and may be unlawful. If you have received this communication > in error, please immediately notify the sender by reply e-mail and destroy > all copies of the communication and any attachments. > > -- I'm trying to launch the internet; so I open a terminal and go "percent sign 'Internet'" at the prompt and it doesn't work. What gives??!! -- random troll