Voting for std.experimental.checkedint
Walter Bright via Digitalmars-d
digitalmars-d at puremagic.com
Sun Feb 26 13:53:26 PST 2017
On 2/26/2017 1:15 PM, Andrei Alexandrescu wrote:
> Indeed, the routines in core.checkedint are everything needed (in addition to
> some inline code for comparisons) if the purpose is to check operations
> individually.
The purpose of core.checkedint is to provide the smallest possible building
block for doing checked integers. This is to encapsulate it so it:
1. can be made portable
2. can be recognized by the compiler with the potential for using the knowledge
of the semantics of it to generate /better/faster/reliable/more correct/ code
3. is a clue to the reader of the code what the point of the odd looking
expressions is
As John Regehr pointed out in a series of articles,
http://blog.regehr.org/archives/1139
most people do ad-hoc checking which turns out to be very fragile in the face of
compiler optimizations and handling of undefined behavior.
More information about the Digitalmars-d
mailing list