Re: Should conversion of mutable return value to immutable allowed?

2011-02-24 Thread spir
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;

Re: Should conversion of mutable return value to immutable allowed?

2011-02-24 Thread Ali Çehreli
On 02/24/2011 10:28 AM, spir wrote: > 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

Re: Should conversion of mutable return value to immutable allowed?

2011-02-24 Thread Simon Buerger
On 24.02.2011 19:08, 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; re

Re: Should conversion of mutable return value to immutable allowed?

2011-02-24 Thread Jesse Phillips
Ali Çehreli Wrote: > I have another question: Does calling .idup copy any data below? > > string foo() > { > char[] s; > return s.idup; // Is the content copied? > } > > Ali > Yes, dup stands for duplicate and is a property of arrays. There was discussion for allowing immutable ob

Re: Should conversion of mutable return value to immutable allowed?

2011-02-24 Thread Jesse Phillips
Also there is std.exception.assumUnique()

Re: Should conversion of mutable return value to immutable allowed?

2011-02-24 Thread Tomek Sowiński
Ali Çehreli napisał: > 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