5

The , , and synonyms are falsely linking to . They should instead be synonyms for .

I believe the status quo started with this request: Merge tags [order-of-operations], [order-of-evaluation], and [operator-precedence]

Technical explanation: distinction between operator precedence and order of execution

It may not be entirely obvious, so let me elaborate on the terminology.

In an expression such as a() + b() + c():

  • Operator precedence tells us that this is grouped as (a() + b()) + c(). However, the precedence in itself does not specify whether a(), b(), or c() are executed first. In some languages, there is a left-to-right evaluation guarantee. However, in C and C++, this is not the case, and a(), b(), and c() can be invoked in an arbitrary order by the compiler.

  • Order of execution is the overarching concept, although it does not dictate which operations are executed in the first place. It not only includes the fact that the addition of a() and b() has to happen prior to the addition with c(), but also includes in what order the functions are invoked.

As a rule of thumb:

Operator precedence states which operations take place, and order of execution states in what order all the operations occur. These two concepts somewhat intersect though.

Therefore, the and are falsely equated with "operator precedence" through the current synonym.

Intuitive linguistic explanation

Even ignoring all the technical aspects, it makes very little sense why is not a synonym for , since "evaluation" and "execution" are basically the same thing.

Practical Issues

An unsuspecting user may be asking a C++ question such as this:

Is the order of initialization guaranteed for globals?

Is the order in which global variable initializers are evaluated guaranteed?

int x = 1; // global variable
int y = x + 1; // is this guaranteed to be 2?

, ,

The poor fool would have inadvertently tagged their question as despite not asking about operator precedence at all.

In practice, it looks like virtually all uses of use this tag, and not one of its synonyms. If there is a way to get specific numbers for how many questions would be affected, I would appreciate some advice.

Conclusion

It would be more appropriate to turn the tags in question into a synonym for .

0

You must log in to answer this question.

Browse other questions tagged .