C++ Logo

std-proposals

Advanced search

Re: [std-proposals] return if

From: Thiago Macieira <thiago_at_[hidden]>
Date: Mon, 12 Jan 2026 07:11:06 -0600
On Monday, 12 January 2026 06:56:38 Central Standard Time Frederick Virchanza
Gotham via Std-Proposals wrote:
> 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.

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?

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel Data Center - Platform & Sys. Eng.

Received on 2026-01-12 13:11:19