Re: copying arrays





Ken Tilton wrote:


Pascal Bourguignon wrote:

Ken Tilton <ken@xxxxxxxxxxxxxxxxxx> writes:

[...]
The problem with PP is that, if our assumption is that people cannot
program, then we cannot program. It is one of those complexity
deals. That's wrong, let me try again: we cannot /in our programming/
make allowances for programmer fallibility. It's a slippery
slope. Once we make that bet, er, hedge, where do we stop? If we want
to say this bit of code might be flawed or this programmer might be a
loose cannon, where does the descent into paranoia halt?



In a way, and language specified error signaling is defensive programming.

Why should (/ 1 0) signal an error? It's obvious to everybody that you
should never try to divide 1 by 0. So there's no need to consider
this case in the code of /.


That is not paranoia, that is completeness. One has to consider (handle) zero as a denominator once one decides to have the / operator at all, and since by the definition of that operator no value can be returned as a result of division by zero, the API needs to include "...and watch out for this error...".

No, that's not the point. The point is that throwing an error is not "programming for mistakes". Probably many of you have never even heard such a thing proposed, so will have a hard time understanding the distinction. I am not talking about (assert (not (zerop n)), I am talking about extending oneself in interesting ways because "someone might X". The key quality of "interesting" not held by ASSERT is that it has a cost to develop and itself is complex enough to go wrong. Another likely quality is that, once built in, not easily yanked.

It is just as easy to code after (when (zerop denominator)...) (break "div by zero dude") as it would be (return 42).

kt


--
http://www.theoryyalgebra.com/

"Algebra is the metaphysics of arithmetic." - John Ray

"As long as algebra is taught in school,
there will be prayer in school." - Cokie Roberts

"Stand firm in your refusal to remain conscious during algebra."
- Fran Lebowitz

"I'm an algebra liar. I figure two good lies make a positive."
- Tim Allen

.