Hacker News new | past | comments | ask | show | jobs | submit login

> I guess my question is: If you want `auto`, why put it in C instead of using C++ with no other C++ specific feature besides auto?

Because they're orthogonal, and making function bodies less verbose with no loss of expressivity is nice, without needing to significantly alter the language?

Pretty much every C competitor has local type inference, and C actually needs more than most due to the `struct` namespace, typing `struct Foo` everywhere is annoying, and needing to typedef everything to avoid it is ugly.

Also C++ is missing convenient C features, like not needing to cast `void*` pointers, and designated initialisers were only added in C++20.




Type inference only make the code harder to read. You ended doing mental compiler work when you could just write the damm type.

And the people who say "I Just hover the variable in my IDE" It doesn't work in a terminal with grep, you can't hoved a diff file and not even github do the hover thing.

Combine that with the implicit type promotion rules of C. Have Fun.


> Type inference only make the code harder to read.

Nonsense.

> Combine that with the implicit type promotio rules of C. Have Fun.

This sort of trivial TI does not make that any worse. C is broken, it neither breaks nor unbreaks C.


typeof and auto are useful for writing type-generic macros.


Yeah but looking how auto has been abused in C++ I don't think it worth it.


C23's auto is not nearly as magic as C++'s auto. You can use it for the simple things but not for the perversely creative abuse scenarios you fear.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: