C++ Logo

std-proposals

Advanced search

Re: [std-proposals] explicit class (2023, 2019, 2004, 2002)

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Tue, 11 Jun 2024 11:33:35 -0400
On Tue, Jun 11, 2024 at 10:21 AM Frederick Virchanza Gotham via
Std-Proposals <std-proposals_at_[hidden]> wrote:
>
> On Tue, Jun 11, 2024 at 2:18 PM Jonathan Wakely wrote:
> >
> > What's a miranda function?
>
>
> I learned C++ from the book "C++ For Dummies" back in 2002. The author
> Stephen R. Davis wrote:
>
> "I like to call the Miranda functions, ie. if you can't supply
> your own, the court will supply them for you"
>
> Miranda functions are, for example, copy constructor, move
> constructor, assignment operator and so on. Anything that's given to
> you without you needing to ask for it.

So instead of using the term defined by the standard ("special member
functions"), you instead use a term used only in a garbage book that's
over 20 years old.

Looks like my days of not taking you seriously are definitely coming
to a middle.

> > Why can't explicit(false) be used here?
>
>
> That syntax could work too.
>
>
> > Why is making constructors explicit by default related to
> > making special member functions omitted by default?
> > Those seem like two unrelated features.
>
>
> The idea of marking a class as 'explicit' is just to make it very
> restrictive in many ways. Some people like to be very concise when
> writing code. I like to be pedantic and verbose, as in: "I want the
> compiler to ask me to clarify what I meant to do unless I've made it
> crystal clear what I meant to do".
>
> There is a majority of neurotypical people and a minority of
> neurodiverse people in society. Some estimate that the ratio is 99:1.
> When it comes to computer programmers, that minority is a lot bigger,
> with a ratio of something like 13:1. And as you go up in skill level
> with computer programmers, that ratio gets closer and closer. If we
> were to survey all of the people who compose papers to present to the
> C++ committee, I'd believe you if you told me half of them were
> neurodiverse.
>
> The reason I'm getting into all this is that I think a lot of
> programmers want the compiler to demand more clarification from the
> programmer. That's why I dug up posts from 3 other people over the
> past 22 years to show that other people want this too.

What I find most interesting is that you took all of these *very
different* ideas and jammed them together, even though there's a good
chance that the originators of those ideas don't want "explicit" to
mean all of those different things at the same time.

The people who want to force you to use `override` on overridden
functions probably don't care about forcing you to default
constructors. Similarly, the people who want to make implicit
conversion constructors opt-in probably don't care about forcing
people to default all of their special member functions. And most of
those people *really* don't want their features coupled with enforcing
`this->` syntax in every member access. Etc.

By combining all of these ideas together, you've effectively made a
feature that *nobody* wants.

This is the kind of thing that motivation-less thinking leads to.

Received on 2024-06-11 15:33:47