[phobos] [D-Programming-Language/phobos] 601c75: Improve parsing error handling

Michel Fortin michel.fortin at michelf.com
Mon Sep 5 06:28:01 PDT 2011


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.

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/





More information about the phobos mailing list