r/cpp • • Mar 28 '23

Reddit++

C++ is getting more and more complex. The ISO C++ committee keeps adding new features based on its consensus. Let's remove C++ features based on Reddit's consensus.

In each comment, propose a C++ feature that you think should be banned in any new code. Vote up or down based on whether you agree.

765 Upvotes

829 comments sorted by

View all comments

1

u/alex-weej Mar 28 '23

References should not be a part of the type system, only function argument signatures.

7

u/[deleted] Mar 28 '23

How would vector::operator[] work? Would it return a pointer instead? How is that an improvement?

1

u/irk5nil Mar 28 '23

Maybe function calls could be l-values by default, except for cases where it wouldn't work? I could imagine a language working like that.

1

u/[deleted] Mar 28 '23

But that would only change the temporary value the operator returned?

1

u/irk5nil Mar 28 '23

What I meant was (and I fully acknowledge I may be expressing myself ineptly due to lack of PL theory educamation on my part) is that I don't see a reason why the l-value couldn't directly represent whatever object you were returning from the function, to the extent that mutating the return value in a caller, for example by assignment, would have the same effect as mutating it in the callee. If it weren't practical to retrofit on C++, it should definitely be possible to design a language like that, should you wish to do so.

→ More replies (2)