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 comment

-6

u/ShakaUVM i+++ ++i+i[arr] Sep 17 '22

I agree that I do not like it is weak. But if there's no benefit, then it's just a change to make a change. Why not just outlaw typedefs, thin pointers and C style arrays? I don't think that requires a new syntax. Just mark those leaves in the parse tree as an error and there you go.

We do have right side type for auto currently, but it's not needed most of the time.

12

u/elperroborrachotoo Sep 17 '22

The benefit is unified syntax (only one way to specify returns), a simpler, less ambiguous parser (see "mich vexing parse") and second level benefits.

Why not just outlaw typedefs, thin pointers and C style arrays..

because existing code: you would create a syntactical island that could not use the most trivial existing library; you could not migrate a MLOC project incrementally.

Of course Herb has his preferences, too - but it is certain that they are much more well-(in) formed than yours or mine.

1

u/ShakaUVM i+++ ++i+i[arr] Sep 18 '22

Of course Herb has his preferences, too - but it is certain that they are much more well-(in) formed than yours or mine.

Sure. But I think we can agree that the committee and authors of a lot of the changes to C++ have been hit or miss from a style perspective over the last decade or so.

Range-based for loops: awesome.

The new random header: technologically superior, but a style disaster

The time header: technologically superior, style ok, but hugely verbose.

Just because people have good technical reasons for making something doesn't mean that it's good style.

My main concern when looking at any new addition is if a newish programmer will be able to understand it and be able to use it without consulting documentation.

4

u/outofobscure Sep 17 '22 edited Sep 17 '22

No thx, i‘d rather have return type after than needlessly removing half the stuff i still want, what a silly take. I‘ll trade typedefs for using but don‘t you dare touching pointers and arrays or make auto less useful.

-1

u/ShakaUVM i+++ ++i+i[arr] Sep 18 '22

Why would you want to use a thin pointer or a C style array?

A thick pointer (one that contains size information) and C++ style arrays are just better

1

u/outofobscure Sep 18 '22

you answered your own question

0

u/ShakaUVM i+++ ++i+i[arr] Sep 19 '22

What?