const assignments problem again

Adam D. Ruppe destructionator at gmail.com
Sat Aug 6 21:31:27 PDT 2011


bearophile:
> I agree, that's why I have added two more points

The precedence of the ternary is pretty easy to handle - if there's
more than one thing in there, just use parenthesis. That's the
only thing I can think of that would make it any more bug prone
than other branches.

Perhaps it'd be worth thinking if parens should be required in any
non-trivial cases.

auto a = something ? "one" : "two"; // ok

auto b = a ~ something ? "one" : "two"; // error, please add parens for clarity

> - It is less maintainable

I don't agree that changing to an if is any burden at all. This
is like saying "if(x) y;" is unacceptable because you might have
to add braces later.

Real maintenance headaches are things like duplicated code
or unnecessary complexity. This is just a very simple case of
syntax translation.


More information about the Digitalmars-d mailing list