Eliminate redundancy of dup/idup
Timon Gehr
timon.gehr at gmx.ch
Sun Sep 9 09:25:50 PDT 2012
On 09/09/2012 05:44 PM, kenji hara wrote:
> 2012/9/10 Adam D. Ruppe <destructionator at gmail.com>:
>> On Sunday, 9 September 2012 at 15:32:01 UTC, kenji hara wrote:
>>>
>>> Then returned value can be implicitly convertible to immutable(E[]).
>>
>>
>> What about rebindable with auto? For example:
>>
>> void main() {
>> char[] a = "cool".dup;
>> string b = a.idup; // explicitly immutable(char)[]
>> auto c = a.idup; // automatically typeof(c) == immutable(char)[]
>
> Yes. In this case, you should write:
> immutable c = a.dup(); // explicit immutable conversion
>
>> c = "another"; // so this compiles
This does not compile anymore now.
>> }
+1 for moving to library and lifting restrictions on conversion.
-1 for removing .idup, it is handy.
More information about the Digitalmars-d
mailing list