appologies
Charles D Hixson
charleshixsn at earthlink.net
Wed Jan 2 10:30:02 PST 2008
Charles D Hixson wrote:
> Jarrett Billingsley wrote:
>> ""Jérôme M. Berger"" <jeberger at free.fr> wrote in message
>> news:fleb1b$1ol5$1 at digitalmars.com...
>>
>>> const (C) c = (someCondition) ? (new C (1)) : (new C (2)),
>>
>> OK. I guess the point I was trying to make before is that you can't
>> generally combine declaration and initialization. I'm sure you can
>> all imagine a more complex example that would be prohibitive/stupid to
>> try to initialize in a single expression.
>>
> General solution? (untested)
> 1) define a function to return a value of the desired type and value.
> 2) use it to assign a value to a constant.
>
> I suspect that this function might need to be static, but I seem to
> remember that const is intentionally limited to rom-able values, so that
> shouldn't be too restrictive.
>
> It's still not as pleasant as being able to assign once.
I just re-checked the documentation, and it doesn't say that
it can't be changed after compile time at all...in fact it
says that it *CAN* be changed, just not via the const reference.
More information about the Digitalmars-d-announce
mailing list