Implicit conversions through purity
bearophile
bearophileHUGS at lycos.com
Sat Apr 12 14:26:01 PDT 2014
Is it possible and a good idea to allow code like the function
foo2?
string foo1(in string s) pure nothrow {
auto s2 = s.dup;
s2[0] = 'a';
return s2; // OK.
}
void foo2(in string s, ref string sOut) pure nothrow {
auto s2 = s.dup;
s2[0] = 'a';
sOut = s2; // Error: cannot implicitly convert
}
void foo3(in string s, out string sOut) pure nothrow {
auto s2 = s.dup;
s2[0] = 'a';
sOut = s2; // Error: cannot implicitly convert
}
void main() {}
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list