On Friday, 5 April 2019 at 14:49:50 UTC, diniz wrote:
Hello,

Since literal strings are interned (and immutable), can I count on the fact that they are compared (==) by pointer?

No. "==" performs a full array comparison and "is" is apparently simplified at compile time. In the compiler there's no notion of string literal as a special expression. It's always a StringExp. See https://d.godbolt.org/z/K5R6u6.

However you're right to say that literal are not duplicated.


Reply via email to