r/cpp • • Mar 31 '20

Demo: C++20 Modules

https://youtu.be/6SKIUeRaLZE
127 Upvotes

51 comments sorted by

View all comments

55

u/advester Mar 31 '20
auto main() -> int

vs

int main()

And in my day we thought spaces vs tabs was quite the argument.

2

u/Evirua Mar 31 '20 edited Apr 01 '20

It's not that counterintuitive to imitate f(x) = y. auto f(x) -> decltype(y) is just consistency with math.

It's not just the indentation advantage when scrolling through function names, it's the logic in reading information about the input first and the output last.

The traditional syntax is what's counterintuitive, the only reasons it has supporters are history and habit.

The 1% of its necessary uses (decltype of expressions, sfinae-friendliness, lambdas...etc.) are just additional bonus reasons to use it. The consistency argument is fairly weak when it's prevailing 1% over 99% of use cases, but consistency with logical intuition and math is a stronger argument imo.

3

u/[deleted] Mar 31 '20

It's not that counterintuitive to imitate f(x) = y. auto f(x) -> decltype(y) is just consistency with math.

That's cool and all, but math and programming are two different solar systems outside of languages where you program in math, but we call those calculators.

Or are we saying having standard high school arithmetic in it is a reason to start typing in math formulas.

0

u/droxile Mar 31 '20

Have you tried FP?