On Thu, May 29, 2014 at 12:16 AM, Bardur Arantsson <s...@scientician.net> wrote: > No matter how defective the notion of "length" may be, personally I > think that people will expect the former, but will be very surprised by > the latter. There are certainly cases where the JavaScript version is > wrong, but I conjecture that it "works" for the vast majority of cases > that people and programs are likely to encounter.
Why would they expect the former? What use is the codepoint count? It shouldn't be blindly used in conjunction with slicing up the string, because you need to respect grapheme clusters. It shouldn't be used to remember the positions of substrings, because seeking to a codepoint index in a UTF-8 string is slow, so byte offsets should be used instead. Of course, this could be seen as an argument in favor of naming clarity. Also, I hope nobody uses JavaScript .length for any purpose other than what in Rust would be a byte length, since it doesn't actually count codepoints... '😃'.length 2 _______________________________________________ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev