www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Changing the behavior of compile time ? :

One thing that has been bugging me for a while is that the behavior of the
ternary ? : operator. On runtime

auto foo = c() ? a() : b();

first evaluates c(), then only either a() or b(), not both of them. But, on
compile time they are all evaluated.

I'm aware that some template code depends on the behavior of ? : to deduce
the proper type of the expression, but does it always require evaluation of
both branches? Could it just deduce the type without instantiating
templates etc. ?

Changing this would make the template code readable in many places (static
if's and helper templates could be converted to a one liner), and the old
behavior could be simulated in many cases with helper variables.
May 08 2007