On 02.09.2017 01:37, Q. Schroll wrote:
On Friday, 1 September 2017 at 23:13:50 UTC, Q. Schroll wrote:
[..]
Just as Scott Meyers said: make it easy to use correctly and hard to use incorrectly. Today it's easy to use incorrectly.

While
   enum foo = [1,2,3];
   assert(foo is foo);
fails,
   enum bla = "123";
   assert(foo is foo);
passes.

Enhancement request submitted: https://issues.dlang.org/show_bug.cgi?id=17799

Unfortunately after I found out the second one does not have to do with mutability. Making foo immutable(int)[] does not change anything. It only works for const(char)[], immutable(char)[], and probably w/dchar friends. That's odd.

This is called string pooling. This passed too:

void main(){
    assert("123" is "123");
}

D (at least sometimes) allows the identities of different immutable locations to become conflated.

Reply via email to