I wonder, does the important_value function get called and the value discarded or never called at all? Looks like a footgun if it has side-effects.
I wonder, does the important_value function get called and the value discarded or never called at all? Looks like a footgun if it has side-effects.
Not calling the function would be evidence of further derangement in the design.
Such a thing has been perpetrated in C. In C, you can repeat designated initializers. like
The order in which the expressions are called is unspecified, just like function arguments (though the order of initialization /is/ specified; it follows initialization order).The implementaton is allowed to realize that since .a is being initialized again by y(), the earlier initialization is discarded. And it is permitted not to emit a call to x().
That's just like permitting x() not to be called in x() * 0 because we know the answer is zero.
Only certain operators in C short-circuit. And they do so with a strict left-to-right evaluation discipline: like 0 && b will not evaluate b, but b && 0 will evaluate b.
The initializer expressions are not sequenced, yet they can be short-circuited-out in left-to-right order.
Consistency? What's that ...