String literals have only one instance?

Stewart Gordon smjg_1998 at yahoo.com
Thu Aug 19 05:46:09 PDT 2010


Jonathan Davis wrote:
<snip>
> You can always check with the is operator though. If it reports true,
> then the two strings have the same instance. If it reports false, then
> they don't.

I can't see how testing each string literal to see if it's the same 
instance as another can work.

The OP's point is: Are identical string literals *guaranteed* to be the 
same instance?  Regardless of implementation?  Regardless of whether 
they're next to each other, in different modules or anything in between? 
  Regardless of the phase of the moon?

Stewart.


More information about the Digitalmars-d-learn mailing list