We decided a while ago that it's best for string literals to be dynamic
arrays, not static. This came along with the switch to pass-by-value of
static arrays. The problem was templates would end up copying string
literals.
Andrei
On 9/5/11 9:28 AM, Michel Fortin wrote:
Le 2011-09-05 à 8:42, Andrei Alexandrescu a écrit :
On 9/5/11 2:34 AM, Walter Bright wrote:
On 9/4/2011 10:54 PM, Jonathan M Davis wrote:
It's a bug in dmd. string literals aren't lvalues
Yes, they are, because one can take the address of them.
What they are not are *modifiable* lvalues.
How can we express that in the type system?
Actually if you see the string literal "hello" as an immutable(char[5]) inside
the resulting binary, then you can take its address so it is a rvalue.
But that's a static array. If you implicitly convert it to a dynamic array, of
type immutable(char)[], this dynamic array is a temporary rvalue and you
shouldn't be able to take its address.
So do we want static arrays or dynamic arrays as string literals? Static arrays
can be lvalues, dynamic arrays cannot.
_______________________________________________
phobos mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/phobos