Thread overview
[Issue 13829] std.uni.byCodePoint for strings has length
Dec 07, 2014
Marc Schütz
Dec 14, 2014
Peter Alexander
Dec 17, 2014
Marc Schütz
Sep 08, 2017
Dmitry Olshansky
Sep 11, 2017
Dmitry Olshansky
Sep 12, 2017
Dmitry Olshansky
December 07, 2014
https://issues.dlang.org/show_bug.cgi?id=13829

--- Comment #1 from Marc Schütz <schuetzm@gmx.net> ---
In case it wasn't clear:

For strings and wstrings, determining the actual number of code points is an O(n) operation and should therefore not be available via length at all. The current implementation returns the number of code units, not of code points.

--
December 10, 2014
https://issues.dlang.org/show_bug.cgi?id=13829

hsteoh@quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh@quickfur.ath.cx

--- Comment #2 from hsteoh@quickfur.ath.cx ---
The documentation of byCodePoint states that it's the identity function when given a range of code points, and currently, strings are ranges of code points (due to autodecoding), so it simply returns the string as-is.

Should this be changed so that it returns a wrapper around the string that suppresses .length instead?

--
December 14, 2014
https://issues.dlang.org/show_bug.cgi?id=13829

Peter Alexander <peter.alexander.au@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |peter.alexander.au@gmail.co
                   |                            |m

--- Comment #3 from Peter Alexander <peter.alexander.au@gmail.com> ---
In a perfect world, I think it should return a different range, but it's now a breaking change, and even breaks its documented behaviour. So I'm voting that this shouldn't be fixed.

Note: hasLength will still return false.

--
December 17, 2014
https://issues.dlang.org/show_bug.cgi?id=13829

--- Comment #4 from Marc Schütz <schuetzm@gmx.net> ---
(In reply to Peter Alexander from comment #3)
> In a perfect world, I think it should return a different range, but it's now a breaking change, and even breaks its documented behaviour. So I'm voting that this shouldn't be fixed.

I strongly disagree with this. The status quo is clearly wrong.

--
December 17, 2014
https://issues.dlang.org/show_bug.cgi?id=13829

hsteoh@quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|hsteoh@quickfur.ath.cx      |

--
September 08, 2017
https://issues.dlang.org/show_bug.cgi?id=13829

Dmitry Olshansky <dmitry.olsh@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|nobody@puremagic.com        |dmitry.olsh@gmail.com

--
September 11, 2017
https://issues.dlang.org/show_bug.cgi?id=13829

--- Comment #5 from Dmitry Olshansky <dmitry.olsh@gmail.com> ---
(In reply to Peter Alexander from comment #3)
> In a perfect world, I think it should return a different range, but it's now a breaking change, and even breaks its documented behaviour. So I'm voting that this shouldn't be fixed.
> 
> Note: hasLength will still return false.

Let's us not replicate the broken 'string has no length except it does' stuff
even more.
If the user says byCodePoint he definetely expects a proper range.
I'll change the documentation to reflect this.

--
September 12, 2017
https://issues.dlang.org/show_bug.cgi?id=13829

--- Comment #6 from Dmitry Olshansky <dmitry.olsh@gmail.com> ---
https://github.com/dlang/phobos/pull/5733

--
September 25, 2017
https://issues.dlang.org/show_bug.cgi?id=13829

--- Comment #7 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/d46bd62bcaa080ea1bfa19fc8d80359226f304a6 Fix issue 13829 - byCodePoint has length

https://github.com/dlang/phobos/commit/4cc17371b0994fe5aa494b800105dcae30ada674 Merge pull request #5733 from DmitryOlshansky/fix-issue-13829

Fix issue 13829 - byCodePoint has length merged-on-behalf-of: Dmitry Olshansky <dmitry@olshansky.me>

--
October 16, 2017
https://issues.dlang.org/show_bug.cgi?id=13829

--- Comment #8 from github-bugzilla@puremagic.com ---
Commits pushed to stable at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/d46bd62bcaa080ea1bfa19fc8d80359226f304a6 Fix issue 13829 - byCodePoint has length

https://github.com/dlang/phobos/commit/4cc17371b0994fe5aa494b800105dcae30ada674 Merge pull request #5733 from DmitryOlshansky/fix-issue-13829

--