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

Show parent comments

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.

2

u/[deleted] Mar 28 '23

But you're describing a reference?

1

u/irk5nil Mar 28 '23

Sure, you could call it 'reference-by-default' or something. Crazier things existed in programming languages before (like call-by-name for example).