C++ Logo

std-proposals

Advanced search

Re: function at() for span<> that throws exception on out-of-range, like vector and array ::at()

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Sat, 30 Nov 2019 18:41:56 +0200
On Sat, 30 Nov 2019 at 18:31, Lyberta via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> Ville Voutilainen via Std-Proposals:
> > The argument is that an exception that would be thrown by at() is a
> > logic error in the program
> How is sanitizing user input a logic error?

Ahem. You can't make me defend that argument. :) I have worked in
environments where random
bogeyghosts don't just appear from thin air (as in, "but if you try to
protect your users from one kind
of logic errors, they'll run into worse ones, so it's better to punish
them everywhere in order to
magically teach this particular point"), and it's splendidly useful to
be able to tell them something along
the lines of "write simple code; if bad things happen, they will be..
erm.. thrown to layers written by
experts, for handling the bad things".

I am merely trying to explain the argument. I am not defending it. I
am perfectly willing to admit
that I am to some extent attacking it.

Received on 2019-11-30 10:44:30