Many years ago, working on the problem of tight I / O graphics, Tom Duff launched a loop and created the Duff Device as follows:
dsend(to, from, count) char *to, *from; int count; { int n = (count + 7) / 8; switch (count % 8) { case 0: do { *to = *from++; case 7: *to = *from++; case 6: *to = *from++; case 5: *to = *from++; case 4: *to = *from++; case 3: *to = *from++; case 2: *to = *from++; case 1: *to = *from++; } while (--n > 0); } }
(Note that this uses the parameters of the old-style function - this is not an error.)
This coding comes directly from thinking in assembler and coding in C and depends on case case. Can this kind of creativity in alternating management structures work in any other languages?
c
Shannon nelson
source share