F
Frederick Gotham
Victor Bazarov posted:
I make assumptions all the time -- I belive we call them "pre-conditions" in
the programming world. For instance, I can write an algorithm which deals
with an array, and say:
"The array must have at least two elements."
Then, if somebody gets bogus results when they supply it with either:
(1) A null pointer.
(2) An empty array (if there's such a thing).
(3) A sole-element array.
, then I'll just say tough luck. The C++ Standard seems to agree with me,
guess what happens when you supply "strlen" with a null pointer.
That said though, I do make liberal use of "assert".
Assumption is the mother of all f***-ups.
for (int i = 0; i < len; +i)
blah;
is not semantically equivalent to
int i = 0;
do
blah;
while (++i < len);
, that's all.
I make assumptions all the time -- I belive we call them "pre-conditions" in
the programming world. For instance, I can write an algorithm which deals
with an array, and say:
"The array must have at least two elements."
Then, if somebody gets bogus results when they supply it with either:
(1) A null pointer.
(2) An empty array (if there's such a thing).
(3) A sole-element array.
, then I'll just say tough luck. The C++ Standard seems to agree with me,
guess what happens when you supply "strlen" with a null pointer.
That said though, I do make liberal use of "assert".