C++ Logo

std-proposals

Advanced search

Re: [std-proposals] return if

From: Thiago Macieira <thiago_at_[hidden]>
Date: Mon, 12 Jan 2026 06:20:36 -0600
On Monday, 12 January 2026 03:27:56 Central Standard Time David Brown via Std-
Proposals wrote:
> There is also the issue of the order of actions. C++ is, at heart, an
> imperative language - "do this, then do that." Check the condition,
> then optionally return. Allowing an "if" statement to be tagged on to
> the end of a "return" looks like the start of the slippery slope leading
> to Perl...

Then we'll also ask for "unless".

 return 0 unless foo();

Do note you can write:
 
 foo() or die("error");

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

Received on 2026-01-12 12:20:43