Should conversion of mutable return value to immutable allowed?
spir
denis.spir at gmail.com
Thu Feb 24 10:28:45 PST 2011
On 02/24/2011 07:08 PM, Ali Çehreli wrote:
> 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
I'm all for that. Can hardly how auto conversion in the sense mutable -->
immutable could be harmful, but may miss a meaningful point. This would esp be
nice for strings, since we regularly need to use char arrays to construct
textual content.
Denis
--
_________________
vita es estrany
spir.wikidot.com
More information about the Digitalmars-d
mailing list