Should conversion of mutable return value to immutable allowed?
Ali Çehreli
acehreli at yahoo.com
Thu Feb 24 10:08:05 PST 2011
Implicit conversions to immutable in the following two functions feel
harmless. Has this been discussed before?
string foo()
{
char[] s;
return s; // Error: cannot implicitly convert expression
// (s) of type char[] to string
}
string bar()
{
char[] s;
return s ~ s; // Error: cannot implicitly convert expression
// (s ~ s) of type char[] to string
}
Is there a reason why that's not possible? I am sure there must be other
cases that at least I would find harmless. :)
Ali
More information about the Digitalmars-d
mailing list