What is the point of nothrow?
Neia Neutuladh
neia at ikeran.org
Wed Jun 13 03:23:07 UTC 2018
On Wednesday, 13 June 2018 at 00:38:55 UTC, Jonathan M Davis
wrote:
> It's possible to write programs that check and handle running
> out of memory, but most programs don't, and usually, if a
> program runs out of memory, it can't do anything about it and
> can't function properly at that point.
Simulations that run out of memory are likely unable to recover
from OutOfMemoryError. Transactional programs like webservers
are likely to run out of memory due to an unusually large request.
> The idea is that it's a bug in your code if you ever index an
> array with an index that's out-of-bounds. If there's any risk
> of indexing incorrectly, then the program needs to check for
> it, or it's a bug in the program. Most indices are not taken
> from program input, so treating them as input in the general
> case wouldn't really make sense
The case I find is almost invariably a hard-coded index into
input data, like a CSV file that is supposed to have ten columns
but only has eight.
This is often a bug in my program simply because most exceptions
I encounter are bugs in my program.
> - plus, of course, treating them as program input in the
> general case would mean using Exceptions, which would then kill
> nothrow.
Which goes back to my point of problems that could be caused by
too wide a range of code being Errors.
More information about the Digitalmars-d-learn
mailing list