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 #62591 is a reply to message #62583] Fri, 19 September 2008 12:09 Go to previous messageGo to previous message
pgrigis is currently offline  pgrigis
Messages: 436
Registered: September 2007
Senior Member
R.G. Stockwell wrote:
> "Jean H" <jghasban@DELTHIS.ucalgary.ANDTHIS.ca> wrote in message
> news:gauiil$u32$1@news.ucalgary.ca...
> ...
>> Could you comment on the "risk" of changing the loop counter within the
>> loop?
>
> my 2 cents.
>
> First, it is in changing the counter of a for loop.
> A for loop explicitly outlines what all counter variables will be.
>
> There are two things:
>
> 1) infinite loop, one could easily change the counter to never
> reach the end condition. A (valid) for loop will always reach the end
> condition.
>
> 2) more insidious, you could inadvertantly cast the counter to a float from
> an int, and then have one extra (and unintended ) statement executed.
This seems not to be possible in IDL, as loop counters, unlike normal
variables, cannot change their type.

Ciao,
Paolo


>
> instead of 0,1,2,3,4,5,6 (and not executing i = 7) you could get
> 0,1,2,3,4,4.99999999,5.99999,6.99999999, (and effectively executing the
> extra i ~ 7 step).
>
> Cheers,
> bob
[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 19:55:15 PDT 2025

Total time taken to generate the page: 0.00194 seconds