PhobosWatch: manifest => enum
Russell Lewis
webmaster at villagersonline.com
Wed Jan 2 11:38:16 PST 2008
Russell Lewis wrote:
> Janice Caron wrote:
>> On 1/2/08, Russell Lewis <webmaster at villagersonline.com> wrote:
>>> I'll ignore for the moment the (very tricky) problem of assigning copies
>>> of const structs. Just for basic types, we could easily solve this by
>>> requiring the syntax "const auto" when we wanted a constant:
>>>
>>> const int X = 3;
>>> auto i = X;
>>> const auto j = X;
>>> i = 4; // legal, typeof(i) is int
>>
>> But typeof(i) /isn't/ int. typeof(i) is const(int). The problem is not
>> how to make a const copy of a const primitive - it's how to make a
>> mutable copy of a const primitive.
>
> I was suggesting how things *should* be, not how they are. Sorry if I
> didn't make that clear.
Hmmm...maybe the problem isn't with auto, after all. Maybe what I'm
really suggesting is that (with primitive types, remember I'm explicitly
not considering structs) when you use a const value on the right-hand
side, then the expression is not const (since you are copying the
value). OTOH, when you use it on the left side, it of course must be const.
Sort of like saying "the variable X" is const, but the value it contains
(3) is not. If you think of the variable as a box that holds a value,
it makes sense.
I haven't thought this one through deeply yet, so there might be a
problem with it, but I thought I'd throw the ponder out.
More information about the Digitalmars-d
mailing list