r/cpp • • Sep 17 '22

Cppfront: Herb Sutter's personal experimental C++ Syntax 2 -> Syntax 1 compiler

https://github.com/hsutter/cppfront
335 Upvotes

360 comments sorted by

View all comments

Show parent comments

0

u/[deleted] Sep 17 '22

[deleted]

2

u/[deleted] Sep 17 '22

main: () -> int = { } is one of the worst I've seen.

2

u/jloverich Sep 17 '22

Not that different from python Def main() -> int: though there is the extra equal and python has tabs instead of brackets.

3

u/[deleted] Sep 17 '22

Python is the 2nd language I use most, but I don't like that syntax either.

I personally prefer the C way:
int main(int argc, char **argv) { }

Many times the first thing I want to know is the return type, so like all other ways, it's a personal preference.

19

u/[deleted] Sep 17 '22

Apart from ambiguity problems, putting the type first can also hamper readability: Types can be very long, so you have to scan a potentially large part of the line before you get to the function name or, worse, can even figure out that the line you are reading declares or defines a function at all. So I don’t think it’s just a matter of personal preference - there are objective arguments against this syntax.

→ More replies (3)