Re: String literals have only one instance?

2010-08-20 Thread Rory Mcguire
Rory Mcguire wrote: Are all string literals that have the same value initialized to the same address? void main() { string same() { return This; } assert(This is same()); assert(This is This); } Can this be relied upon? Interesting thanks guys. Was just curious about the speed

String literals have only one instance?

2010-08-19 Thread Rory Mcguire
Are all string literals that have the same value initialized to the same address? void main() { string same() { return This; } assert(This is same()); assert(This is This); } Can this be relied upon?

Re: String literals have only one instance?

2010-08-19 Thread Jonathan Davis
On 8/19/10, Rory Mcguire rjmcgu...@gm_no_ail.com wrote: Are all string literals that have the same value initialized to the same address? void main() { string same() { return This; } assert(This is same()); assert(This is This); } Can this be

Re: String literals have only one instance?

2010-08-19 Thread bearophile
Rory Mcguire: Are all string literals that have the same value initialized to the same address? ... Can this be relied upon? Probably a conforming D implementation is free to not give the same address to those. Bye, bearophile

Re: String literals have only one instance?

2010-08-19 Thread Stewart Gordon
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

Re: String literals have only one instance?

2010-08-19 Thread Johannes Pfau
On 19.08.2010 09:53, Rory Mcguire wrote: Are all string literals that have the same value initialized to the same address? void main() { string same() { return This; } assert(This is same()); assert(This is This); } Can this be relied upon? I

Re: String literals have only one instance?

2010-08-19 Thread Simen kjaeraas
Rory Mcguire rjmcgu...@gm_no_ail.com wrote: Are all string literals that have the same value initialized to the same address? void main() { string same() { return This; } assert(This is same()); assert(This is This); } Can this be relied upon?

Re: String literals have only one instance?

2010-08-19 Thread Sean Kelly
Rory Mcguire Wrote: Are all string literals that have the same value initialized to the same address? void main() { string same() { return This; } assert(This is same()); assert(This is This); } Can this be relied upon? This should be