From: Robert Klemme Date: 2008-05-06T01:50:07+09:00 Subject: Re: String copy-on-write question On 05.05.2008 18:33, ts wrote: > Robert Klemme wrote: >> Interesting. Do you also happen to know why not an additional field is >> used that stores the length? > > I've not understood : it has a field which give it the length of > the string, for example with Ah, ok. This happens when one is too lazy to look into the source. :-) Somehow I had assumed that the length was not stored because you made the point that the \0 could not be inserted without altering the original. I concluded, there is no length. :-) > str = '0' * 200 > str[100 .. -1] > > the first object (in str) will have 200 for its length > the field length in the new object will have the value 100 > >> Is the reason maybe usage of C library >> string functions that work on zero terminated strings? > > only matz know this :-) Well, maybe he'll stop by and enlighten us. Kind regards robert