Date: Mon, 12 Jan 2026 17:47:42 +0100
On 12/01/2026 16:13, Frederick Virchanza Gotham via Std-Proposals wrote:
> On Mon, Jan 12, 2026 at 1:11 PM Thiago Macieira wrote:
>>
>> Yes, but why do we need two syntaxes to do the same thing? In Perl, for any
>> non-trivial return if, I end up indenting the if:
>>
>> return $somevar
>> if $a > 0 and !$b;
>>
>> In Perl, a leading if requires the statement be surrounded by brackets, so the
>> above is one line shorter. In C++, it wouldn't be.
>>
>> So why should we spend time changing the core language syntax?
>
>
> As I try to think back now over different programs and different
> projects, embedded microcontrollers and desktop PC's, I've written
> code loads of times where the callee returns either:
>
> (1) void
> (2) bool
> (3) some kind of handle
>
> The void's are pretty simple:
>
> void Func1(int a, double b)
> {
> if ( IsOutOfRange(a) ) return;
> if ( IsOutOfRange(b) ) return;
> DoSomething(a, b);
> }
>
> There isn't much to gain from allowing the above to be changed to:
>
> void Func1(int a, double b)
> {
> return if IsOutOfRange(a);
> return if IsOutOfRange(b);
> DoSomething(a, b);
> }
>
> Now let's consider the bool's:
>
> bool Func2(int a, double b)
> {
> if ( ! InRange(a) ) return false;
> if ( ! InRange(b) ) return false;
> return (double)a > b;
> }
>
> This could be turned into:
>
> bool Func2(int a, double b)
> {
> return if ! InRange(a);
> return if ! InRange(b);
> return (double)a > b;
> }
>
> I already explained that when the compiler sees "return if expr", it
> does the following:
>
> decltype(expr) var = expr;
> if ( static_cast<bool>(var) ) return var;
>
> So you're probably wondering what does "return if ! expr" do? If you
> place an exclamation mark after "return if", the processing changes
> to:
>
> if ( false == static_cast<bool>(var) ) return var;
>
You are /seriously/ suggesting that :
return if ! InRange(a);
should return the opposite bool value to :
return if (!InRange(a));
?
And you think this is all a readability improvement?
At this stage, I'm guessing that most regulars on this list are simply
filtering your posts directly to /dev/null.
> On Mon, Jan 12, 2026 at 1:11 PM Thiago Macieira wrote:
>>
>> Yes, but why do we need two syntaxes to do the same thing? In Perl, for any
>> non-trivial return if, I end up indenting the if:
>>
>> return $somevar
>> if $a > 0 and !$b;
>>
>> In Perl, a leading if requires the statement be surrounded by brackets, so the
>> above is one line shorter. In C++, it wouldn't be.
>>
>> So why should we spend time changing the core language syntax?
>
>
> As I try to think back now over different programs and different
> projects, embedded microcontrollers and desktop PC's, I've written
> code loads of times where the callee returns either:
>
> (1) void
> (2) bool
> (3) some kind of handle
>
> The void's are pretty simple:
>
> void Func1(int a, double b)
> {
> if ( IsOutOfRange(a) ) return;
> if ( IsOutOfRange(b) ) return;
> DoSomething(a, b);
> }
>
> There isn't much to gain from allowing the above to be changed to:
>
> void Func1(int a, double b)
> {
> return if IsOutOfRange(a);
> return if IsOutOfRange(b);
> DoSomething(a, b);
> }
>
> Now let's consider the bool's:
>
> bool Func2(int a, double b)
> {
> if ( ! InRange(a) ) return false;
> if ( ! InRange(b) ) return false;
> return (double)a > b;
> }
>
> This could be turned into:
>
> bool Func2(int a, double b)
> {
> return if ! InRange(a);
> return if ! InRange(b);
> return (double)a > b;
> }
>
> I already explained that when the compiler sees "return if expr", it
> does the following:
>
> decltype(expr) var = expr;
> if ( static_cast<bool>(var) ) return var;
>
> So you're probably wondering what does "return if ! expr" do? If you
> place an exclamation mark after "return if", the processing changes
> to:
>
> if ( false == static_cast<bool>(var) ) return var;
>
You are /seriously/ suggesting that :
return if ! InRange(a);
should return the opposite bool value to :
return if (!InRange(a));
?
And you think this is all a readability improvement?
At this stage, I'm guessing that most regulars on this list are simply
filtering your posts directly to /dev/null.
Received on 2026-01-12 16:47:47
