What is the purpose of the Most Vexing Parse?

Let’s say MVP didn’t exist.

How would you declare a function?

A foo();

would be a variable definition, not a method declaration. Would you introduce a new keyword? Would you have a more awkward syntax for a function declaration? Or would you rather have

A foo;

define a variable and

A foo();

declare a function?

Your slightly more complicated example is just for consistency with this basic one. It’s easier to say “everything that can be interpreted as a declaration, will be interpreted as a declaration” rather than “everything that can be interpreted as a declaration, will be interpreted as a declaration, unless it’s a single variable definition, in which case it’s a variable definition”.

This probably isn’t the motivation behind it though, but a reason it’s a good thing.

Leave a Comment