logoalt Hacker News

abcd_f • today at 2:38 PM • 2 replies • view on HN

As they used to say on slashdot:

From the "C++ design committee was so preoccupied with whether they could, they never stopped to think whether they should" department.

Asserts:

1. You don't like the being conditional on NDEBUG ot aborting the program - roll out your own. Will still be a one-liner.

2. You want them act as documentation of pre-conditions in headers - just add a comment there.

The only somewhat reasonable development here are the post conditions for functions with multiple returns, but post/s are dramatically less common than pre/s, so their utility is also debatable.


Replies

bluGill • today at 3:15 PM

I have seen far too many times when the comment in the implementaiton doesn't match reality to accept pre/post conditions in a comment. I want my contracts someplace where they get evaluated from time to time so that they are fixed when they are wrong.

pjmlp • today at 2:57 PM

No worries, this will probably land in C as well, static_assert was already.