Bug 13717 – `split` no longer defined by std.string
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-11-12T15:53:00Z
Last change time
2015-02-18T03:39:46Z
Assigned to
nobody
Creator
hsteoh
Comments
Comment #0 by hsteoh — 2014-11-12T15:53:55Z
Just filing this so that we don't inadvertently release with a regression.
This problem is caused by the import cleanups in https://github.com/D-Programming-Language/phobos/pull/2675 , specifically, commit ab83cd94dac799e9f88b4750004bc8995ff93d46.
Comment #1 by hsteoh — 2014-11-12T15:57:37Z
Failing test case:
------
import std.string;
void main () {
foreach (s; "ab cd ef".split) {}
}
------
Compiles with Phobos commit c0028b4, but fails starting with ab83cd94.
Comment #2 by ilyayaroshenko — 2014-11-12T16:06:21Z
This is not regression!
There is not any documentation for std.string.split.
This code
------
import std.string;
auto d = "ab cd ef".split;
------
compiles before only because DMD bug.
We should NOT use global selective imports in druntime and phobos, until DMD bug will be fixed.
Comment #3 by ilyayaroshenko — 2014-11-12T16:08:20Z
I am sorry, forget my comment.
This was public imports.
public import std.algorithm : startsWith, endsWith, cmp, count;
public import std.array : join, split;
Will be fixed
Comment #4 by ilyayaroshenko — 2014-11-12T16:10:57Z
Oh, my bad... this code should be removed time ago.
-------
//Remove when repeat is finally removed. They're only here as part of the
//deprecation of these functions in std.string.
public import std.algorithm : startsWith, endsWith, cmp, count;
public import std.array : join, split;
------
What we should do with this undocumented stuff?
Comment #5 by monarchdodra — 2014-11-12T16:48:49Z
The `split(string)` qnd splitter variants *should* be visible from std.string. It was recently removed from std.string and moved to std.algorithm due to function/alias conflicts. These are string specific functions so at least that specific overload should be included by std.string.
Comment #6 by ilyayaroshenko — 2014-11-12T17:08:00Z
What about join, startsWith, endsWith, cmp, count ?
Comment #7 by hsteoh — 2014-11-12T17:08:54Z
Those probably should be included as well. That means can't get rid of those imports just yet. :-(
Comment #8 by ilyayaroshenko — 2014-11-12T17:10:54Z
And we can not deprecate them too because there is now deprecation for imports ;-(
Comment #9 by hsteoh — 2014-11-12T17:14:13Z
Actually, on second thoughts, does it make sense to deprecate them instead? Based on the comment, seems they're supposed to be deprecated because they got moved to other modules (std.array, std.algorithm, etc.).
Comment #10 by hsteoh — 2014-11-12T17:15:20Z
Maybe we should bring this up in the forum to see if anyone has a better idea?
Comment #11 by hsteoh — 2014-11-12T17:17:04Z
Also, @monarchdodra, if we're going to keep these functions in std.string, then they need to be documented, instead of being "implicitly" defined.
Comment #12 by hsteoh — 2014-11-12T17:19:40Z
Here's a crazy idea: what if we introduce template wrappers for these functions, so that the import only happens if the user code actually references those symbols? For example:
-----
// std.string
auto split(Char1,Char2)(const(Char1) s, const(Char2) t) {
import std.array : split;
return split(s, t);
}
-----
So while we can't get rid of the dependency, at least users who don't need it, won't need to pay for it.
Comment #13 by ilyayaroshenko — 2014-11-12T17:20:38Z
Please bring it to forum (my English is bad).
Comment #14 by ilyayaroshenko — 2014-11-12T17:22:21Z
This is not good solution:
------
import std.array;
import std.string;
"foo bar".split(); //Error: much more then one template
------
Comment #15 by ilyayaroshenko — 2014-11-12T17:24:00Z
typo: much -> match
Comment #16 by hsteoh — 2014-11-12T17:29:21Z
Hmm, you're right. This is not good. :-( I can't think of any non-broken way to work around this problem. Looks like we'll have to put those public imports back until we can find a better solution. :-(
Comment #17 by ilyayaroshenko — 2014-11-12T17:30:03Z
OK
Comment #18 by github-bugzilla — 2014-11-12T18:33:32Z