No we should not support enum types derived from strings

deadalnix deadalnix at gmail.com
Wed May 12 02:30:50 UTC 2021


On Wednesday, 12 May 2021 at 02:21:06 UTC, 12345swordy wrote:
> Yes. A is being replace with the new instance of A that happens 
> to have the same value here. There is no guarantee that they 
> will share the same address.
>
> - Alex

You might want to reconsider how sure of yourself you are. For 
instance by opening https://replit.com/languages/csharp and 
running the following code in there:

using System;

class A {
   int i;
   public A(int i_) { i = i_; }
   public int getI() { return i; }
}

class Program {
   static void Main(string[] args) {
     A a = new A(15);
     Console.WriteLine(a.getI());
     foo(a);
     Console.WriteLine(a.getI());
   }

   static void foo(A ainfoo) {
     ainfoo = new A(23);
     Console.WriteLine(ainfoo.getI());
   }
}



More information about the Digitalmars-d mailing list