🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c++
Article #1025

Re: A better experimental::scope_exit

#1025
From: Tristan Wibberley
Date: Tue, 24 Nov 2026 19:04
53 lines
4086 bytes
On 24/11/2026 14:01, Bonita Montero wrote:
> Am 24.11.2026 um 13:42 schrieb Tristan Wibberley:
> 
>> Of course it wasn't so until C++14 when the preset mode was changed from
>> noexcept(false) to noexcept(true) (was it C++14?), and before C++11
>> there wasn't even a way to change it /from/ noexcept(false).
> 
> It wasn't handled differently with any C++-version, meaning
> that destructors that throw exceptions are nearly no existing.
> 
>> So I think it's really common.
> 
> It's dangerous: If an exception occurs while unwinding the stack of a
> function the unwinding continues and when it is finished the exception
> is propagated upwards. But if you have a second exception while this
> unwinding happens the application is terminated.

That's what I think is the goal in many applications. That's what
noexcept(false) is for. noexcept(true) is for when you want the
termination every time an exception would leak from a destructor with
runtime checks in case you made a booboo.

When the invariants are not maintained it's dangerous to continue, the
future should be broadly as if power were lost by the host or a process
kill occurs (memory unit mapped into process memory is lost, etc).

If you could continue safely then you can re-establish the invariant
within the destructor by all sorts of means. You can throw and handle
exceptions within the destructor without terminating, it is only leaking
of the secondary exception out of the destructor that causes termination.

The rest of the system should gracefully continue thereby making it safe
(eg, failover, rapid restart, etc).

Safety involves not running a program segment when its invariants do not
hold. That much is fundamental. If you can run it then its invariants
perhaps are more conditional after all (perhaps the system has processes
and failover, stochastic redundancy and quora, etc) and maybe then you
don't need any cleanup for a code segment (no problem no scope guard).


-- 
Tristan Wibberley

The message body is Copyright (C) 2026 Tristan Wibberley except
citations and quotations noted. All Rights Reserved except that you may,
of course, cite it academically giving credit to me, distribute it
verbatim as part of a usenet system or its archives, and use it to
promote my greatness and general superiority without misrepresentation
of my opinions other than my opinion of my greatness and general
superiority which you _may_ misrepresent. You definitely MAY NOT train
any production AI system with it but you may train experimental AI that
will only be used for evaluation of the AI methods it implements.
Technical Details
Message-ID: <11e4n3d$33ipm$1@dont-email.me>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <11dsk17$8ske$2@raubtier-asyl.eternal-september.org> <11e2kpl$2cc7p$1@dont-email.me> <11e39t7$2ia0c$1@raubtier-asyl.eternal-september.org> <11e40mr$2qdb1$1@dont-email.me> <11e45ce$2s6qc$1@raubtier-asyl.eternal-september.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Tristan Wibberley <tristan.wibberley+netnews2@alumni.manchester.ac.uk>
Newsgroups: comp.lang.c++
Subject: Re: A better experimental::scope_exit
Date: Tue, 24 Nov 2026 19:04:12 +0000
Organization: A noiseless patient Spider
Lines: 53
Message-ID: <11e4n3d$33ipm$1@dont-email.me>
References: <11dsk17$8ske$2@raubtier-asyl.eternal-september.org>
 <11e2kpl$2cc7p$1@dont-email.me>
 <11e39t7$2ia0c$1@raubtier-asyl.eternal-september.org>
 <11e40mr$2qdb1$1@dont-email.me>
 <11e45ce$2s6qc$1@raubtier-asyl.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 24 Nov 2026 19:04:14 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="3263286"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1908GCdFsQqAdfieMvucppTn7GNDt6hUVFq569B6kQe/Q=="; posting-host="decbdae56b93c9f0180ef0a73d46de56"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:fQfu2XnhbpH8o8GuKZULn8NPXBM= sha256:DGIA7rkii8xbUPTt8TJjix6fTUZhHCjl5VmBtYELG4A=
	sha1:th4r5oNk+26MPkseGcNKvECduQU= sha256:3cDhM47/Wyrjw6DddYxutwJnRJW4jq4TKq9tyyirG7g=
In-Reply-To: <11e45ce$2s6qc$1@raubtier-asyl.eternal-september.org>
Content-Language: en-GB