|go ahead... be a heretic|
Re: Re: using two arrays to make a tableby demerphq (Chancellor)
|on Jun 19, 2002 at 13:58 UTC||Need Help??|
I don't know what's so bad about a "C-style for loop"
There are two problems with C style for loops. First they are prone to fencepost errors. In fact programmers that dont have a C/Java background get them wrong an awful lot, for instance I come from a Pascal background, and despite being a reasonably good programmer often make mistakes when I use them. (hence I dont use them if I can get away with it).
Second is that they are marginally less efficient than perl style for loops. Granted this isnt the best argument, but combined with the former its IMO pretty good reasoning that avoiding them is a good way to reduce error, speed up your code and leave a more maintainable product (the later is excellent justifiction IMO).
it isn't there so people can complain about its usage
No its there to make C programmers feel more at home. Presumably a C programmer has already learned the subtleties of this style of loop and so will not make the common errors as often. This doesnt mean that it should be recommended or even overlooked, especially as the alternative is so much superior.
As for your solution ++. splice() is one of those tools that I have yet to become entirely comfortable with. I suppose its something I should try to use more often.
Good post, thanks.
Yves / DeMerphq