std.string import cleanup: how to fix regression?
via Digitalmars-d
digitalmars-d at puremagic.com
Thu Nov 13 11:57:35 PST 2014
On Thursday, 13 November 2014 at 19:27:59 UTC, Ilya Yaroshenko
wrote:
> alias can not be deprecated :-(
It can. But evidently, static import cannot be selective:
aa.d:
static import std.algorithm;// : startsWith, endsWith, cmp,
count;
static import std.array;// : join, split;
deprecated {
alias startsWith = std.algorithm.startsWith;
}
bb.d:
import aa;
bool test() {
return "".startsWith("");
}
# dmd -c bb.d
bb.d(2): Deprecation: alias aa.startsWith is deprecated
Remove ";//" to enable the selective imports, and we get errors:
aa.d(1): Error: static import std cannot have an import bind list
aa.d(1): Error: static import __anonymous cannot have an import
bind list
aa.d(1): Error: static import __anonymous cannot have an import
bind list
aa.d(1): Error: static import __anonymous cannot have an import
bind list
aa.d(2): Error: static import std cannot have an import bind list
aa.d(2): Error: static import __anonymous cannot have an import
bind list
This seems like an arbitrary restriction. [1] states that it is
disallowed (under the heading "Selective Imports"), but gives no
justification. It's probably because of the implementation.
Anyway, the imports can be pulled into the `deprecated` block to
make the intention clear:
deprecated {
static import std.algorithm;
static import std.array;
alias startsWith = std.algorithm.startsWith;
}
[1] http://dlang.org/module
More information about the Digitalmars-d
mailing list