Help - can't ADD constness
Janice Caron
caron800 at googlemail.com
Fri Sep 14 02:09:45 PDT 2007
On 9/14/07, Robert Fraser <fraserofthenight at gmail.com> wrote:
> You're using the const storage class, which means compile-time constant. Try:
>
> const(A) = new A();
>
That's close. Turns out I actually needed:
final const(A) a = new A();
Without the "final", a isn't actually const, it's only tail-const.
That's because D2.0 is still using the syntax we haven't got rid of
yet.
Even so, that is still highly counterintuitive. I would have thought
"const T" equivalent to "final const(T)" in D2.0. Sheesh! The sooner
we get rid of this syntax the better.
I wonder if, in D2.1 or whatever it will be called
const a = new A();
will compile.
I hope so, because type deduction is a marvellous thing, and if we end
up having to write the A on both sides of the assignment operator,
that will just irritate me. (const(auto) doesn't work).
More information about the Digitalmars-d
mailing list