C++ Logo

std-proposals

Advanced search

Re: Fixing some initialization gotchas

From: Hyman Rosen <hyrosen_at_[hidden]>
Date: Fri, 23 Aug 2019 13:44:04 -0400
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.

Received on 2019-08-23 12:46:18