C++ Logo

std-proposals

Advanced search

Re: Re-purposing the function exception specification

From: Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
Date: Tue, 30 Jun 2020 13:33:20 -0400
On Tue, Jun 30, 2020 at 1:15 PM andrei--- via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> Good afternoon,
>
> Thanks for the VERY useful insight into the programming-by-contract work.
>
> I don't see why the "group #1" wants to continue after a contract
> violation - it's like trying to call "double sqrt(double x) require: x >= 0
> { ... }" as "sqrt(-1)" - the obvious choice would be to throw something
> like "bad_contract" on a violation (which should then never be "checked").
> I'll read up on this subject further, so thanks again.
>
FYI, "throw an exception of type bad_contract, which can be caught higher
up" is the very definition of "continue running the program after a
contract violation."
If you want to *stop* running after a contract violation, then you have to
actually halt the program; you can't say "let's just jump over here and
keep going."

–Arthur

Received on 2020-06-30 12:36:45