auto storage class - infer or RAII?
Tomas Lindquist Olsen
tomas at famolsen.dk
Mon Nov 13 18:24:18 PST 2006
Bill Baxter wrote:
> Tomas Lindquist Olsen wrote:
>> Bill Baxter wrote:
>>> Tomas Lindquist Olsen wrote:
>>>> Sean Kelly wrote:
>>>>
>>>> It is definitely a bit weird. I would like to see all combinations
>>>> of these fail. they dont make any sense together. all provide ATI if
>>>> present. the only problem I can see is if you want to put a constant
>>>> inside a static block. but maybe that is handled differently?
>>>>
>>>> IMHO this would make sense:
>>>>
>>>> Invalid:
>>>> ---------
>>>> static const x = 5;
>>>
>>> What's wrong with static and const together?
>>> One says this is actually store with globals not on the stack, the
>>> other says the value isn't going to change. Nothing inconsistent
>>> about having those two together.
>> Does it really make sense to have the programmer decide this
>> distinction? A global const will definitely have static storage. But
>> why not let the compiler decide?
>>
>> I just don't see where having this choice is useful!
>
> In a function?
> In a class?
>
> --bb
a static in a class is well defined. so is a const. for me 'static
const' reads as having the 'static' redundant. a 'const' in D is by
definition static. It cannot change, as only a compile-time constant
will qualify, and thus will be the same to all classes of whatever reads it.
a function 'const' is very much the same. I fail to come up with a
scenario where choosing the storage model for a constant makes any sense!
Can you post an example of why we need 'static const' ?
More information about the Digitalmars-d
mailing list