Parens
Janice Caron
caron800 at googlemail.com
Fri May 9 22:35:31 PDT 2008
On 10/05/2008, Dee Girl <deegirl at noreply.com> wrote:
> void main(string[] args)
> {
> auto c = new const C;
> }
>
> Does not compile. But if I change to const(C) it does compile. It is a bit unusual that parens make such a big difference. Thank you, Dee Girl
When it comes to parens-version versus non-parens-version, it's not
really a problem if one of the two doesn't compile. It would be a
bigger problem if both compile, but behave differently.
But I agree with you. "new const C" should behave like "new const(C)".
However, what you probably should have written is:
const c = new C;
because "auto" is what you use in the absence of any other attribute.
In this case, it suffices to create a new C, and then assign it to a
const-thereafter variable.
More information about the Digitalmars-d
mailing list