🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: A better experimental::scope_exit

#1027
From: Ross Finlayson
Date: Tue, 24 Nov 2026 19:22
85 lines
5219 bytes
On 11/24/2026 11:04 AM, Tristan Wibberley wrote:
> 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).
>
>


Seems you need model your resource-management that has clean-up
side-effects as first-class or its own synchronization, since
destructors should have no side effects (that can throw) so that their
clean-up of otherwise the stack with invoking all their destructors
with all their none side-effects, maintains well-defined behavior,
that it seems that anonymous-routine of lambda-off-the-destructor
introduces its own execution context anyways and isn't consistent
with other more basic accounts of "defined behavior", i.e. it's not.

One might imagine that as the language has grown that there are
other conflicting accounts of "defined behavior".

The very-point of error-modeling and exception-modeling is
deemed necessary to "maintain invariants".



"The estimated lifetime of an instance of [httpd] here
before it dies randomly is 23 minutes. When it dies
its last request is sent to a new one."

This is longer than a usual account of "lull in conversation",
which was widely estimated since forty or more years ago,
as 17 minutes, though some aver 7 minutes.

"Why not save it?" "Tragedy of the commons."


"How about that queue over there?" "Oh, that can't go down at all."




I always write const/volatile qualifiers _after_ where it's associated,
instead of before, and always make the pointer or reference part of
the _type_ not the _value_, since it's not like "int x = 0, *px = &x",
that those are _operations_ not _qualifiers_, about then mostly
assignment or "=", the "operator".


Technical Details
Message-ID: <AF-dnZwPEcxqfpj2nZ2dnZfqnPidnZ2d@giganews.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!border-4.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.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> <11e4n3d$33ipm$1@dont-email.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!border-4.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Tue, 24 Nov 2026 19:22:31 +0000
Subject: Re: A better experimental::scope_exit
Newsgroups: comp.lang.c++
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>
 <11e4n3d$33ipm$1@dont-email.me>
From: Ross Finlayson <ross.a.finlayson@gmail.com>
Date: Tue, 24 Nov 2026 11:22:20 -0800
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101
 Thunderbird/38.6.0
MIME-Version: 1.0
In-Reply-To: <11e4n3d$33ipm$1@dont-email.me>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <AF-dnZwPEcxqfpj2nZ2dnZfqnPidnZ2d@giganews.com>
Lines: 85
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-5mSvigJPZKOOKSWQybC4xoLjY5DRP7WcQm1PE5lBLcRDhvyZ/u7i1PXeKh2QeFybA3YEi4EUQa1MkJu!RV+DsxsjuV4g5/n4xf53Fo+2JhUJHL54mrpamtxNwDMbWxscaewbHETPP0aN1JMnsw9HqWn26FAf
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40