DMD 1.025 and 2.009 releases
Charles D Hixson
charleshixsn at earthlink.net
Tue Jan 1 15:25:53 PST 2008
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.
More information about the Digitalmars-d-announce
mailing list