Implicit conversions through purity
    Jonathan M Davis 
    jmdavisProg at gmx.com
       
    Sat Apr 12 17:02:34 PDT 2014
    
    
  
On Saturday, April 12, 2014 21:26:01 bearophile wrote:
> 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.
> }
Honestly, I would have considered that to be a bug. Converting the return type 
to a different level of mutability based on purity is one thing. Automatically 
casting the return value just because the function is pure is another matter 
entirely. Clearly, it can work, but it seems incredibly sloppy to me.
- Jonathan M Davis
    
    
More information about the Digitalmars-d-learn
mailing list