On Sat, Jun 13, 2020 at 4:42 PM Tom Limoncelli <t...@whatexit.org> wrote:
> I've been coding for a few years (first line of BASIC was in September > 1979) and I have to admit that off-by-one errors have always been a > problem for me. I guess I'm just that kind of sloppy. > > They are surprisingly common! It has to do with recursion, but not the kind that is usually associated with the word in programming. We are not talking about calling yourself and extending the stack! A for-loop is a recursive process insofar every iteration is "the same" but an index is updated. Correctness proofs often work by showing that an "empty" structure (array) has the desired property. And that taking a step from a state with the desired property likewise exhibit it after the interaction. The generalizations are known as "recursion schemes" which are ways to produce and consume structural data in a program. Functional languages are somewhat famous for treating programs as sheer symbolic processing on such structures. An interesting concept is the "unfold" which can be seen in Go as a function producing elements on an unbuffered channel. Nailing these kinds of schemes tend to eradicate a whole slew of typical processing bugs in programs. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAGrdgiX9FM0CJPG%3Dy3UWcN6F%3DH_CNpYWyWn2fe%2B3DfNpCVfOxA%40mail.gmail.com.