[Issue 20483] std.uni.byGrapheme & Grapheme.opSlice requires obscure REF parameters.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jan 8 20:05:44 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=20483
--- Comment #2 from hsteoh at quickfur.ath.cx ---
The problem is caused by the implementation of Grapheme.opSlice(), which
returns a proxy range object that contains a pointer to the parent Grapheme. A
cursory glance at the code didn't show any obvious reason why this was done
this way; conceivably the proxy object returned by .opSlice could just copy the
necessary data from Grapheme instead of retaining a pointer to it.
This implementation choice makes it hard to work with Graphemes in range-based
pipelines. If anywhere in the pipeline a Grapheme is generated on-the-fly, it
will generally be returned from .front as an rvalue, and therefore even the ref
trick mentioned in this bug will no longer work.
I recommend to change the implementation of .opSlice so that it does not retain
a pointer to the parent Grapheme.
--
More information about the Digitalmars-d-bugs
mailing list