Date: Wed, 4 May 2022 06:58:59 +0000
Exactly!
So there IS a change.
Also, then why was:
explicit int func (double x, float y)
ever added???
When you could use:
int func (double x, float y)
int fuc (auto, auto) =delete;
??
Now THAT is a point!
Consistency!
C++ has consistency everywhere:
e. g:
int arr[]{ 3, 4, 5, 1 };
Class obj{ 3, 4, 5, 1 };
Rather than (JAVA):
int[] arr = {3, 4, 5, 1};
Class obj = new Class(3, 4, 5, 1);
So why not make explicit consistent??
From: Std-Proposals <std-proposals-bounces_at_[hidden]> on behalf of Tatsuya Yanagita via Std-Proposals <std-proposals_at_[hidden]>
Sent: Tuesday, May 3, 2022 5:00:53 PM
To: std-proposals_at_[hidden] <std-proposals_at_[hidden]>
Cc: Tatsuya Yanagita <hemogurobin.711_at_[hidden]>; Bo Persson <bo_at_[hidden]>
Subject: Re: [std-proposals] explicit keyword (new use)
Is explicit exactly same as =delete?
I think they get different results with a brace initializer:
void f(int);
void f(auto) = delete;
void g(explicit int);
int main() {
f({}); // OK
g({}); // ERROR
g(int{}); // OK
}
2022年5月3日(火) 18:42 Bo Persson via Std-Proposals <std-proposals_at_[hidden]<mailto:std-proposals_at_[hidden]>>:
On 2022-05-03 at 09:23, Abdullah Qasim via Std-Proposals wrote:
> But learning it, & understanding it takes 30 sec.
>
> Instead of:
>
> “What are these functions deleted?”
>
> Why not:
> “Oh, ok, these are explicit types!”
So then we have to wonder "this library has deleted member functions,
but that library uses explicit types. Why did they do that? What is the
difference? None?!".
>
> *From: *Jens Maurer via Std-Proposals
> <mailto:std-proposals_at_[hidden]<mailto:std-proposals_at_[hidden]>>
> *Sent: *03 May 2022 12:22
> *To: *Abdullah Qasim via Std-Proposals
> <mailto:std-proposals_at_[hidden]<mailto:std-proposals_at_[hidden]>>
> *Cc: *Jens Maurer <mailto:Jens.Maurer_at_[hidden]<mailto:Jens.Maurer_at_[hidden]>>
> *Subject: *Re: [std-proposals] explicit keyword (new use)
>
> On 03/05/2022 08.51, Abdullah Qasim via Std-Proposals wrote:
> > But here is the thing:
> >
> >
> >
> > Why not make code simpler??
>
> Because it requires everybody to learn a new wrinkle of
> the language. That cost has to be weighed against the
> perceived increase in simplicity.
>
> Jens
>
>
> > Why write multiple “= delete” functions, conscientiously tracking all
> conversions, when explicit inside functions is much simpler??
> >
> >
> >
> > Also, someone suggested explicit template parameters, like this:
> >
> >
> >
> > *template <explicit typename T>*
> >
> >
> >
> > Why not have consistence, & allow:
> >
> >
> >
> > *int func (explicit int x, int y)*
> >
> >
> >
> > as well?
> >
> >
> >
> > *From: *Jason McKesson via Std-Proposals
> <mailto:std-proposals_at_[hidden]<mailto:std-proposals_at_[hidden]>
> <mailto:std-proposals_at_[hidden]<mailto:std-proposals_at_[hidden]>>>
> > *Sent: *01 May 2022 22:07
> > *To: *std-proposals_at_[hidden]<mailto:std-proposals_at_[hidden]>
> <mailto:std-proposals_at_[hidden]<mailto:std-proposals_at_[hidden]>
> <mailto:std-proposals_at_[hidden]<mailto:std-proposals_at_[hidden]>>>
> > *Cc: *Jason McKesson <mailto:jmckesson_at_[hidden]<mailto:jmckesson_at_[hidden]>
> <mailto:jmckesson_at_[hidden]<mailto:jmckesson_at_[hidden]>>>
> > *Subject: *Re: [std-proposals] explicit keyword (new use)
> >
> >
> >
> > We have `= delete` for removing unwanted conversions. Indeed, you can
> > basically force the use of `int` with:
> >
> > template<typename T>
> > int func (int, T) = delete;
> >
> > Any call to `func` that doesn't pass an `int` as the second parameter
> > will fail to compile. Even things convertible to `int` will not be
> > used.
> >
> > If you want to allow more things to call it, you can only cull out
> > floating-point types with this overload:
> >
> > int func(int, double) = delete;
> >
> > Calling func(5, 1) will work, but func(5, 3.4) or even func(5, 2.3f)
> > will fail. This preserves the ability to call it with types
> > convertible to `int` (but those which are convertible to `int` *and*
> > floats will fail due to ambiguity).
> >
> > On Sun, May 1, 2022 at 3:57 AM Abdullah Qasim via Std-Proposals
> > <std-proposals_at_[hidden]<mailto:std-proposals_at_[hidden]>> wrote:
> >>
> >>
> >>
> >> int func (int var, explicit int select_menu)
> >>
> >> {
> >>
> >> /// ...
> >>
> >> }
> >>
> >>
> >>
> >> Why would I want user to put a double value in select_menu ???
> >>
> >>
> >>
> >> Also, why would I want to disallow a double in var ???
> >>
> >>
> >>
> >> The solution:
> >>
> >> Allow explicit in param list!!
> >>
> >>
> >>
> >> Not too hard to implement, either.
> >>
> >> --
So there IS a change.
Also, then why was:
explicit int func (double x, float y)
ever added???
When you could use:
int func (double x, float y)
int fuc (auto, auto) =delete;
??
Now THAT is a point!
Consistency!
C++ has consistency everywhere:
e. g:
int arr[]{ 3, 4, 5, 1 };
Class obj{ 3, 4, 5, 1 };
Rather than (JAVA):
int[] arr = {3, 4, 5, 1};
Class obj = new Class(3, 4, 5, 1);
So why not make explicit consistent??
From: Std-Proposals <std-proposals-bounces_at_[hidden]> on behalf of Tatsuya Yanagita via Std-Proposals <std-proposals_at_[hidden]>
Sent: Tuesday, May 3, 2022 5:00:53 PM
To: std-proposals_at_[hidden] <std-proposals_at_[hidden]>
Cc: Tatsuya Yanagita <hemogurobin.711_at_[hidden]>; Bo Persson <bo_at_[hidden]>
Subject: Re: [std-proposals] explicit keyword (new use)
Is explicit exactly same as =delete?
I think they get different results with a brace initializer:
void f(int);
void f(auto) = delete;
void g(explicit int);
int main() {
f({}); // OK
g({}); // ERROR
g(int{}); // OK
}
2022年5月3日(火) 18:42 Bo Persson via Std-Proposals <std-proposals_at_[hidden]<mailto:std-proposals_at_[hidden]>>:
On 2022-05-03 at 09:23, Abdullah Qasim via Std-Proposals wrote:
> But learning it, & understanding it takes 30 sec.
>
> Instead of:
>
> “What are these functions deleted?”
>
> Why not:
> “Oh, ok, these are explicit types!”
So then we have to wonder "this library has deleted member functions,
but that library uses explicit types. Why did they do that? What is the
difference? None?!".
>
> *From: *Jens Maurer via Std-Proposals
> <mailto:std-proposals_at_[hidden]<mailto:std-proposals_at_[hidden]>>
> *Sent: *03 May 2022 12:22
> *To: *Abdullah Qasim via Std-Proposals
> <mailto:std-proposals_at_[hidden]<mailto:std-proposals_at_[hidden]>>
> *Cc: *Jens Maurer <mailto:Jens.Maurer_at_[hidden]<mailto:Jens.Maurer_at_[hidden]>>
> *Subject: *Re: [std-proposals] explicit keyword (new use)
>
> On 03/05/2022 08.51, Abdullah Qasim via Std-Proposals wrote:
> > But here is the thing:
> >
> >
> >
> > Why not make code simpler??
>
> Because it requires everybody to learn a new wrinkle of
> the language. That cost has to be weighed against the
> perceived increase in simplicity.
>
> Jens
>
>
> > Why write multiple “= delete” functions, conscientiously tracking all
> conversions, when explicit inside functions is much simpler??
> >
> >
> >
> > Also, someone suggested explicit template parameters, like this:
> >
> >
> >
> > *template <explicit typename T>*
> >
> >
> >
> > Why not have consistence, & allow:
> >
> >
> >
> > *int func (explicit int x, int y)*
> >
> >
> >
> > as well?
> >
> >
> >
> > *From: *Jason McKesson via Std-Proposals
> <mailto:std-proposals_at_[hidden]<mailto:std-proposals_at_[hidden]>
> <mailto:std-proposals_at_[hidden]<mailto:std-proposals_at_[hidden]>>>
> > *Sent: *01 May 2022 22:07
> > *To: *std-proposals_at_[hidden]<mailto:std-proposals_at_[hidden]>
> <mailto:std-proposals_at_[hidden]<mailto:std-proposals_at_[hidden]>
> <mailto:std-proposals_at_[hidden]<mailto:std-proposals_at_[hidden]>>>
> > *Cc: *Jason McKesson <mailto:jmckesson_at_[hidden]<mailto:jmckesson_at_[hidden]>
> <mailto:jmckesson_at_[hidden]<mailto:jmckesson_at_[hidden]>>>
> > *Subject: *Re: [std-proposals] explicit keyword (new use)
> >
> >
> >
> > We have `= delete` for removing unwanted conversions. Indeed, you can
> > basically force the use of `int` with:
> >
> > template<typename T>
> > int func (int, T) = delete;
> >
> > Any call to `func` that doesn't pass an `int` as the second parameter
> > will fail to compile. Even things convertible to `int` will not be
> > used.
> >
> > If you want to allow more things to call it, you can only cull out
> > floating-point types with this overload:
> >
> > int func(int, double) = delete;
> >
> > Calling func(5, 1) will work, but func(5, 3.4) or even func(5, 2.3f)
> > will fail. This preserves the ability to call it with types
> > convertible to `int` (but those which are convertible to `int` *and*
> > floats will fail due to ambiguity).
> >
> > On Sun, May 1, 2022 at 3:57 AM Abdullah Qasim via Std-Proposals
> > <std-proposals_at_[hidden]<mailto:std-proposals_at_[hidden]>> wrote:
> >>
> >>
> >>
> >> int func (int var, explicit int select_menu)
> >>
> >> {
> >>
> >> /// ...
> >>
> >> }
> >>
> >>
> >>
> >> Why would I want user to put a double value in select_menu ???
> >>
> >>
> >>
> >> Also, why would I want to disallow a double in var ???
> >>
> >>
> >>
> >> The solution:
> >>
> >> Allow explicit in param list!!
> >>
> >>
> >>
> >> Not too hard to implement, either.
> >>
> >> --
-- Std-Proposals mailing list Std-Proposals_at_[hidden]<mailto:Std-Proposals_at_[hidden]> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
Received on 2022-05-04 06:59:04