Bug 8166 – retro() of splitter() too

Status
RESOLVED
Resolution
WONTFIX
Severity
enhancement
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-05-30T04:59:23Z
Last change time
2018-02-11T01:36:52Z
Keywords
bootcamp
Assigned to
monarchdodra
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2012-05-30T04:59:23Z
This is an operation I'd like to do: import std.range, std.algorithm; void main() { auto p = std.array.splitter("this is a message").retro(); } DMD 2.060alpha gives: test.d(3): Error: template std.range.retro does not match any function template declaration ...\dmd2\src\phobos\std\range.d(1292): Error: template std.range.retro(Range) if (isBidirectionalRange!(Unqual!(Range))) cannot deduce template function from argument types !()(Result) I think a splitter of a narrow string can be a BidirectionalRange.
Comment #1 by monarchdodra — 2012-10-22T02:40:24Z
(In reply to comment #0) > This is an operation I'd like to do: > > import std.range, std.algorithm; > void main() { > auto p = std.array.splitter("this is a message").retro(); > } > > > DMD 2.060alpha gives: > > test.d(3): Error: template std.range.retro does not match any function template > declaration > ...\dmd2\src\phobos\std\range.d(1292): Error: template std.range.retro(Range) > if (isBidirectionalRange!(Unqual!(Range))) cannot deduce template function from > argument types !()(Result) > > > I think a splitter of a narrow string can be a BidirectionalRange. I'll take this.
Comment #2 by jack — 2015-12-21T18:04:20Z
Currently, this can be achieved via auto p = std.array.splitter("this is a message", " ").retro(); but it's deprecated and going to be removed at the end of the month. So I don't think adding this feature to the string specific overload of splitter is going to be welcome because it looks like doing it is buggy (I assume, why else would this be deprecated?). Therefore, I think that this should be marked as won't fix.
Comment #3 by jack — 2015-12-21T18:08:47Z
(In reply to Jack Stouffer from comment #2) > Currently, this can be achieved via > > auto p = std.array.splitter("this is a message", " ").retro(); > > but it's deprecated and going to be removed at the end of the month. So I > don't think adding this feature to the string specific overload of splitter > is going to be welcome because it looks like doing it is buggy (I assume, > why else would this be deprecated?). Therefore, I think that this should be > marked as won't fix. Wait, my mistake. Doing auto p = std.array.splitter("this is a message", ' ').retro(); instead is perfectly fine. The string specific overload can be changed to use the first overload of splitter internally.
Comment #4 by greensunny12 — 2018-02-09T20:23:08Z
Comment #5 by greensunny12 — 2018-02-10T01:27:09Z
Argh from https://github.com/dlang/phobos/pull/6150 > Making splitter a bidirectional range fundamentally broken - at least if the delimiter has more than one element. Think about something like If someone ever runs into this problem, you can of course always apply retro before: [1, 2, 3].retro.splitter("this is a message")
Comment #6 by github-bugzilla — 2018-02-11T01:36:52Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/c7b6aabfea45b2151f0f21548232242e896101d6 Issue 8166 - retro() of splitter() too https://github.com/dlang/phobos/commit/508337e0bbd3aba17e9235a0229b032da72b318d Merge pull request #6150 from wilzbach/splitter-back Issue 8166 - remove dead _backLength code in std.algorithm.splitter merged-on-behalf-of: Sebastian Wilzbach <[email protected]>