digitalmars.D.learn - String front, back return code point/unit
- vit (9/9) Jun 23 2021 Hello,
- Tejas (5/14) Jun 23 2021 I think this video will be helpful:
- vit (4/21) Jun 23 2021 I wrongly formulated question.
- H. S. Teoh (15/17) Jun 23 2021 No. Autodecoding is one of the decisions we regret because it
Hello, I am implementing nogc string struct similar to c++ std::basic_string (link https://code.dlang.org/packages/basic_string). C++ string has methods front, back and pop_back returning/deleting code units. D strings has functions (std.range) front, back and popBack returning/deleting code points (autodecoding?). Which behavior is better?
Jun 23 2021
On Wednesday, 23 June 2021 at 15:31:04 UTC, vit wrote:Hello, I am implementing nogc string struct similar to c++ std::basic_string (link https://code.dlang.org/packages/basic_string). C++ string has methods front, back and pop_back returning/deleting code units. D strings has functions (std.range) front, back and popBack returning/deleting code points (autodecoding?). Which behavior is better?I think this video will be helpful: https://www.youtube.com/watch?v=d3qY4dZ2r4w There was also a discussion about this in the group: https://forum.dlang.org/thread/diexjstekiyzgxlicnts forum.dlang.org
Jun 23 2021
On Wednesday, 23 June 2021 at 15:48:57 UTC, Tejas wrote:On Wednesday, 23 June 2021 at 15:31:04 UTC, vit wrote:I wrongly formulated question. My question is not about ranges/iterators but if is good idea autodecoding custom string or not.Hello, I am implementing nogc string struct similar to c++ std::basic_string (link https://code.dlang.org/packages/basic_string). C++ string has methods front, back and pop_back returning/deleting code units. D strings has functions (std.range) front, back and popBack returning/deleting code points (autodecoding?). Which behavior is better?I think this video will be helpful: https://www.youtube.com/watch?v=d3qY4dZ2r4w There was also a discussion about this in the group: https://forum.dlang.org/thread/diexjstekiyzgxlicnts forum.dlang.org
Jun 23 2021
On Wed, Jun 23, 2021 at 04:01:24PM +0000, vit via Digitalmars-d-learn wrote: [...]My question is not about ranges/iterators but if is good idea autodecoding custom string or not.No. Autodecoding is one of the decisions we regret because it introduces an unavoidable overhead on basically every string operation in Phobos. Autodecoding was introduced under the misunderstanding that code point == grapheme, but unfortunately that is false. So it fails to accomplish its original purpose and on top of that introduces a performance problem. To accomplish its original purpose would require grapheme decoding; but unfortunately that introduces an even worse performance overhead (Unicode grapheme decoding is non-trivial). tl;dr: don't do it. T -- Why are you blatanly misspelling "blatant"? -- Branden Robinson
Jun 23 2021