in reply to Re: Twirling baton progress indicator in Perl
in thread Twirling baton progress indicator in Perl
I know how much we all love when people who haven't been using perl for any length of time bemoan that perl code looks like line noise, or that it's a write-only language. So, I think we should at least not do the same in reverse.
At no point when I was writing C would I have imagined using either switches or "pointer arithmetic" for this. I would have done basically the same thing you just did, but in C.
Which is exactly the same, except it allows work to get accomplished while the baton is twirling, as you just keep calling twirl_baton every so often in the code. Which I'm sure you would have done in perl if it weren't that the OP asked specifically about sleep in their misdiagnosis of their problem. Yes, under the covers, baton[position++ % 4] is pointer arithmetic, but abstractly it is no more pointer arithmetic than your perl usage. For example, array usage is taught way before pointers in most C courses and books.void twirl_baton() { static int position = 0; static char* baton = "-\\|/"; printf("%c\b", baton[position++ % 4]); }
That's not to say that some people didn't learn switch statements with the rotating baton - but my experience doesn't show it to be indicative or cause/effect. I would think this to be more indicative of other languages where arrays aren't so easy to do - e.g., REXX or shell. Or languages where many beginners show up, but never advance to the point of seeing/using arrays (I can think of many QBASIC "programmers" falling into this category - I'm sure there are many VB users as well, although with common usage of VB being GUI, Windows Registry, and database interactions, I would think VB would have a lower percentage of these users than previous iterations of BASIC).
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Twirling baton progress indicator in Perl
by Aristotle (Chancellor) on Oct 11, 2005 at 11:49 UTC |