5 ms·
The thing that comes to mind is the C idiom for copying strings: while(dest++ = src++); "...their notion of repetition was so tightly connected to the idea of
by jloughry 13y ago
The thing that comes to mind is the C idiom for copying strings:
while(dest++ = src++);
"...their notion of repetition was so tightly connected to the idea of an associated controlled variable to be stepped up, that they were mentally blocked from seeing the obvious."
- Nilzor 13y agoIs this example really relevant today? Who cares if you write while(dest++ = src++) or for (int i = 0; i < src.length; i++) { dest[i] = src[i] }; Was he just worried that the number of keywords and programming concepts were to many and made the language to complex? He would loath C++ then... Still, we seem to get by.
- jmilloy 13y agoI'm not sure I agree; aren't dest and src still variables that are being stepped up? Maybe they are not "controlled variables", I don't know what that means. This is a task that is eminently suited to repetition, any loop makes sense. Plus, the article mentions FORTRAN's DO loop (not just for loops incrementing a counter). I was expecting an example where a loop worked, but a simpler mathematical solution exists without a loop. Anyone else?