C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Lakos rule

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Thu, 21 Dec 2023 16:05:28 +0200
On Thu, 21 Dec 2023 at 15:54, Bo Persson via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> On 2023-12-21 at 13:39, Frederick Virchanza Gotham via Std-Proposals wrote:
> >
> > I see people arguing that the Lakos rule should be kept, and others
> > saying it should be abolished.
> >
> > For everyone to meet half way
>
> It is not about half way, and being half bad. That's not how it works.
>
> Here are the arguments directly from the horse's mouth,
>
> "The Lakos Rule" by John Lakos:
>
>
> https://wg21.link/p2861

I can give you a tl;dr. With contracts, it's possible to write
applications where contract violations, i.e. possibly
innocent logic errors, are recoverable, via throwing exceptions when
they occur, catching such exceptions
in the application logic, and continuing running the application after
handling such exception.

This doesn't work if the standard library mandates functions to be
noexcept even when they don't have to be,
and there are some sort of (narrow) contracts associated with such
functions. A library vendor can still make
such functions noexcept, but there's no possibility of another vendor
not doing that.

That's why there is a proposal to keep the rule, to make it possible
to write such applications. That possibility
doesn't prevent library vendors strengthening noexcept-specs to full
noexcept, but the other option of mandating
noexcept on such functions completely takes away the possibility to
apply contract checks with throwing violation
handlers on those functions. The one option doesn't take any
possibility away, the other does.

We don't need halfway hacks, we need to keep and uphold the Lakos Rule.

Received on 2023-12-21 14:05:41