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
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?
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
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
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
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
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?
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