News for hackers. Stuff that matters.
Re:C++23: The Next C++ Standard by coldpie on Tuesday July 11, 2023 @02:03PM (#36684814)
All the things you wrote could be about as easily written & much more easily read without operator overloading. Operator overloading only allows programmers to feel "smart" for doing a "clever" thing, to the detriment of future readers.

    string("hello ").append("world");

    complexNumber2.mult(complexNumber2);

    // wtf is even going on with this one in your example? have these people never heard of method chaining?
    for(int i : std::views::iota(0,6).filter(even).transform(square))
        (*smartPtr)->methodOnWrapperClass();
That's all about the same verbosity, it's much more clear to the reader even if they're unfamiliar with your codebase, and dropping operator overloading eliminates the "clever" option to do stupid crap like divide file path objects together.
Re:C++23: The Next C++ Standard by AndrewStephens on Tuesday July 11, 2023 @02:11PM (#36684945)
Would you advocate getting rid of operators altogether?

    3.times(2).plus(7)
Some things just lend themselves to being expressed in terms of simple operators.

    (*smartPtr)->methodOnWrapperClass();
That is still using the overloaded SmartPtr<>::operator*() method.

I understand the viewpoint that operator overload is syntactic sugar for things that can easily be done another way, I just disagree that costs outweigh the benefits.

Re:C++23: The Next C++ Standard by coldpie on Tuesday July 11, 2023 @02:15PM (#36685030)
> Would you advocate getting rid of operators altogether?

Of course not. It makes sense for built-in types, as everyone reading the code can be assumed to know them.

> That is still using the overloaded SmartPtr<>::operator*() method.

Good catch ;)

> I just disagree that costs outweigh the benefits.

Yah, I think that's the disagreement. My feeling is there's a teeny, tiny handful of appropriate places for it (almost entirely math) and it opens up a pandora's box of terrible decisions that programmers clearly find irresistible.

Re:C++23: The Next C++ Standard by JonChesterfield on Tuesday July 11, 2023 @08:18PM (#36688894)
Are you suggesting

  3.times(2).plus(7)
as a good thing or a bad thing? I see a.equals(b) occasionally from the first argument is magic crowd but 3.times is novel here. I'm really unsure what the order of operations is for that expression.
Re:C++23: The Next C++ Standard by gpderetta on Tuesday July 11, 2023 @05:57PM (#36687804)
C++ doesn't have extension methods, so you wouldn't be able to add custom algos to the set of chainable algos.

Overloading operator| is a crude way to get the equivalent of extension methods without having to change the language.