C++ Logo

std-proposals

Advanced search

Re: [std-proposals] std::elide

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Wed, 22 May 2024 22:23:58 +0100
On Wed, May 22, 2024 at 9:52 PM Jason McKesson wrote:
>
> Did you just respond to a legitimate question with a meme
> clip? Seriously?


Just got sick of hearing arguments as to why it's pointless to return
a locked mutex from a function, even though there isn't one soul on
this mailing list who aspires to do so.

Nobody on here wants to return a locked mutex by value from a
function. Not one person. 0% of the people on this mailing list wish
to return a locked mutex by value from a function. The count of
persons who plan to write a function to return by value a mutex which
has already been locked is zero. Nobody. No one.

What we want is Named Return Value Optimisation with class types that
are both unmovable and uncopyable, and we have used 'std::mutex' as an
example of such a type, and we have used the 'lock' method as an
example of a post-constructional modification. If memory serves me
right, I sadly and most-regrettably think that I'm the mortal who came
up with this simple quick-and-easy example a few months ago on this
mailing list.

No matter how many times it's re-iterated on this mailing list that
the whole locked mutex thing is just a quick-and-easy example, more
arguments keep coming as to why a skilled programmer would never want
to return a locked mutex by value from a function. Argument after
argument after argument -- even though there's no rebuttal to any of
the arguments. . . yet they keep coming . . . another argument, no
rebuttal, another argument, no rebuttal, another argument, no rebuttal
. . . because, as I said, nobody here actually wants to return a
locked mutex by value from a function. But keep flogging the horse.

Fair enough I didn't help things by posting the Simpsons link but I
was just trying to keep things light-hearted.

If you want good examples of returning post-constructionally-modified
objects by value from a function, there's load of examples given in
Anton's paper:

    https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2025r2

So if we talk about widgets instead of mutexes then can all this
codswallop come to an end?

I had my fifth lesson yesterday to fly a plane . . . and in an attempt
to understand how planes maintain lift, I've been reading up on how
submarines move through water because it's the same principle (i.e. a
propellar providing thrust in a fluid), but after spending too much
time on this mailing list, I'm now afraid to mention this to my flight
instructor because he might take a leaf out of Tiago's book and tell
me again and again and again that submarines are a sub-optimal form of
travel.

Received on 2024-05-22 21:24:11