3 ms·
Sometimes all the meaning is in the name of a thing (or in the name of a function returning such a thing) and member names dont help but hurt. x/y is a good exa
by jstimpfle 10y ago
Sometimes all the meaning is in the name of a thing (or in the name of a function returning such a thing) and member names dont help but hurt. x/y is a good example, why not a/b? I prefer not having to make these decisions. Also tuple assignment syntax is very nice from a usability standpoint (I don't think C++ has it, but e.g. Python has).
- lorenzhs 10y agoC++17 adds tuple unpacking under the name "structured bindings" auto [a, b] = function_returning_pair(); Of course, tuple unpacking was already possible before if the variables were already declared: int a, b; std::tie(a, b) = function_returning_pair();
- Const-me 10y agoMaybe sometimes, but not this time. The author named their pair "Coordinate". In math and in computer graphics there’s widely known convention the fields of Cartesian coordinates are named x/y and not a/b. When you’ll start writing code that use and/or modify those Coordinate values, meaningful names in C++ source and in the debugger help a lot.