comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: IDL FOR Loop variable increments
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: IDL FOR Loop variable increments [message #62603 is a reply to message #62602] Fri, 19 September 2008 01:07 Go to previous messageGo to previous message
Carsten Lechte is currently offline  Carsten Lechte
Messages: 124
Registered: August 2006
Senior Member
Jean H wrote:
> Could you comment on the "risk" of changing the loop counter within the
> loop?

(You did not ask me, but I will comment anyway;)

The risk is called "obfuscation". Outside of certain competitions,
obfuscation is usually considered a thing to avoid. The first statement
in a FOR loop is a nice big billboard that clearly states: "This variable i
will consecutively hold the values from 0 to 10." Imagine your surprise
when i only iterates over some of those values, or even over some totally
different ones when you set i = -3 inside the loop body. Unless you also attach
a blinking comment that notes this unexpected behaviour, future generations
(including yourself in three months) will curse your name when they try to make
sense of your code.

Another thing to consider is if the changing of the loop variable results
in undefined behaviour. IDL seems to follow C's "anything goes" philosophy,
so it will probably work reliably. However, you are still forbidden to
change the type of the loop variable inside the loop;)


chl
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: how to countor on YZ-surface
Next Topic: Getting array indices

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 17:47:15 PDT 2025

Total time taken to generate the page: 0.00473 seconds