C++ Logo

std-proposals

Advanced search

Re: Fixing some initialization gotchas

From: Maciej Cencora <m.cencora_at_[hidden]>
Date: Fri, 23 Aug 2019 20:22:59 +0200
I think what Matthew was trying to say, that you can teach people one rule
how to use auto:
auto x = y;
That works as expected in all C++ version, and with my proposal, other auto
initialization syntaxes would just cause compiler error.

pt., 23 sie 2019 o 19:44 Hyman Rosen via Std-Proposals <
std-proposals_at_[hidden]> napisaƂ(a):

> On Fri, Aug 23, 2019 at 12:44 PM Matthew Woehlke via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>> I can imagine *quite* easily how I would teach `auto a{1}`...
>> DON'T DO THAT.
>> See? Easy!
>>
>
> No, not easy at all. You cannot teach a language in which auto x = { 1 };
> is fine but auto x { 1 }; is a terrible error that nevertheless compiles
> and
> silently does something you don't want. When it comes time to write
> programs,
> no one is going to remember which is which. Having multiple constructs
> that
> appear to do something similar but have different behavior unapparent from
> the
> syntax is never going to be teachable.
>
> This is yet another example where C++ language designers are making
> terrible
> mistakes, most apparent in syntax of templates and lambdas. They seem to
> adhere
> to the notion that as long as they come up with an unambiguous syntax for
> a feature,
> their work is done. That is false. Good language design means that
> intent should be
> determinable from syntax, which in turn means that slight differences
> should not mean
> unrelated things.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2019-08-23 13:25:14