Date: Mon, 12 Jan 2026 15:17:28 +0100
On 12/01/2026 13:56, Frederick Virchanza Gotham via Std-Proposals wrote:
> On Mon, Jan 12, 2026 at 9:28 AM David Brown wrote:
>>
>> However, I /really/ dislike your syntax here, precisely because it is
>> not at all clear or readable. There are so many different ways this
>> syntax could reasonably be interpreted when reading it:
>
>
> Yeah if the reader has never seen "return if" before, then they won't
> be sure what does . . . they'll be wondering if it returns bool or
> if it returns decltype( callee() ).
They will, as I said, be wondering about several different possibilities.
Remember that when a new feature is added to C++, /no/ C++ programmers
will have seen it before. And with an obscure and little-used feature
like this one would be, most C++ programmers would never use the feature
themselves. So every single use of it will be confusing and unclear.
It's one thing to add a new feature that is clearly strange, and people
have to look it up when they first see it, because readers know they
have no idea what it means. But this one looks like it has a fairly
obvious meaning, so people will make assumptions about it when they see
it in code. However, different people will have different guesses as to
what it "obviously" means - with your intended meaning somewhat low on
the betting list.
>
> But human written language is nearly always a little ambiguous when we
> don't have context, especially in "telegraph speak" where we rip out
> all the unnecessary words, e.g. "man found boat capsized need medic"
>
That's why we program computers using programming languages, not human
languages.
> If the feature, "return if", were to be added to the language, give it
> a few months, maybe a year two, and everyone will recognise it at a
> glance.
No, they won't. The solid majority of C++ programmers are probably
still using mostly C++11, if not C++98, for much of their work. Even
those that are nominally using a newer standard - typically at least 5
years behind the published standards - generally only use a tiny
proportion of the new features of the later standards. (Different
people will use a different subset of the new features, of course.) If
this feature gets added to C++29, you can expect a reasonable fraction
of C++ programmers to have heard of it within perhaps a decade. And of
those, only a small proportion will use it, because it is not a very
useful feature.
There are good reasons why changes to C++ - especially the core language
- are only done when they are significantly beneficial to developers.
Things don't get added just because someone thinks it would be cool to
write code slightly differently, or because they want to save a couple
of keypresses when writing a particular bit of code.
Think of a syntax that can make code /significantly/ simpler and clearer
to write - not negligibly shorter and a lot less clear. Think how it
can be used in a wide range of situations in C++, and make a big
difference to daily coding for many people - not just for three lines of
code for one person. Think how it could fit in the big picture of the
C++ language - how can the idea be generalised and work in other
situations? Does it fit with the rest of the language, or is it
contradictory to the way C++ works today? Write lots of "before and
after" code samples to demonstrate the advantages of the change.
Compare it to alternative solutions - both using the existing language,
and with other ideas for new syntax or features.
> On Mon, Jan 12, 2026 at 9:28 AM David Brown wrote:
>>
>> However, I /really/ dislike your syntax here, precisely because it is
>> not at all clear or readable. There are so many different ways this
>> syntax could reasonably be interpreted when reading it:
>
>
> Yeah if the reader has never seen "return if" before, then they won't
> be sure what does . . . they'll be wondering if it returns bool or
> if it returns decltype( callee() ).
They will, as I said, be wondering about several different possibilities.
Remember that when a new feature is added to C++, /no/ C++ programmers
will have seen it before. And with an obscure and little-used feature
like this one would be, most C++ programmers would never use the feature
themselves. So every single use of it will be confusing and unclear.
It's one thing to add a new feature that is clearly strange, and people
have to look it up when they first see it, because readers know they
have no idea what it means. But this one looks like it has a fairly
obvious meaning, so people will make assumptions about it when they see
it in code. However, different people will have different guesses as to
what it "obviously" means - with your intended meaning somewhat low on
the betting list.
>
> But human written language is nearly always a little ambiguous when we
> don't have context, especially in "telegraph speak" where we rip out
> all the unnecessary words, e.g. "man found boat capsized need medic"
>
That's why we program computers using programming languages, not human
languages.
> If the feature, "return if", were to be added to the language, give it
> a few months, maybe a year two, and everyone will recognise it at a
> glance.
No, they won't. The solid majority of C++ programmers are probably
still using mostly C++11, if not C++98, for much of their work. Even
those that are nominally using a newer standard - typically at least 5
years behind the published standards - generally only use a tiny
proportion of the new features of the later standards. (Different
people will use a different subset of the new features, of course.) If
this feature gets added to C++29, you can expect a reasonable fraction
of C++ programmers to have heard of it within perhaps a decade. And of
those, only a small proportion will use it, because it is not a very
useful feature.
There are good reasons why changes to C++ - especially the core language
- are only done when they are significantly beneficial to developers.
Things don't get added just because someone thinks it would be cool to
write code slightly differently, or because they want to save a couple
of keypresses when writing a particular bit of code.
Think of a syntax that can make code /significantly/ simpler and clearer
to write - not negligibly shorter and a lot less clear. Think how it
can be used in a wide range of situations in C++, and make a big
difference to daily coding for many people - not just for three lines of
code for one person. Think how it could fit in the big picture of the
C++ language - how can the idea be generalised and work in other
situations? Does it fit with the rest of the language, or is it
contradictory to the way C++ works today? Write lots of "before and
after" code samples to demonstrate the advantages of the change.
Compare it to alternative solutions - both using the existing language,
and with other ideas for new syntax or features.
Received on 2026-01-12 14:17:36
