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

Home » Public Forums » archive » Empty FOREACH loop
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Empty FOREACH loop [message #75108] Mon, 14 February 2011 15:47 Go to next message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
I was quite surprised when the following raised an error for me:

IDL> foreach g, [] do help, g
% Variable is undefined: <UNDEFINED>.
% Execution halted at: $MAIN$

Does this seem like unexpected behavior? I was expecting the loop just
not to execute.

Of course, whatever the right answer is, it shouldn't do this (as it
does on my Mac):

IDL> foreach g, [] do help, g
% Temporary variables are still checked out - cleaning up...

Mike
--
www.michaelgalloy.com
Research Mathematician
Tech-X Corporation
Re: Empty FOREACH loop [message #81721 is a reply to message #75108] Mon, 15 October 2012 07:59 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
On 10/12/12 18:57, David Fanning wrote:
> rigby@crd.ge.com writes:
>
>> Think about the fun you'd have should you happen to misspell an honest-to-goodness defined variable :-)
>
> I agree. This would fall, along with silent error handlers,
> under my definition of Pure Evil if I were classifying it
> in a programming book. :-)

+1

In the context presented, I consider usage of undefined/non-existant
variables as a fundamental programming error.

It causes automatic failure of the "Good Citizen" test when reviewing
code submissions as a measure for granting write access to a repository.

Like going through a stop sign during your driving test. :o)

cheers,

paulv
Re: Empty FOREACH loop [message #81731 is a reply to message #75108] Fri, 12 October 2012 15:57 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
rigby@crd.ge.com writes:

> Think about the fun you'd have should you happen to misspell an honest-to-goodness defined variable :-)

I agree. This would fall, along with silent error handlers,
under my definition of Pure Evil if I were classifying it
in a programming book. :-)

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thue. ("Perhaps thos speakest truth.")
Re: Empty FOREACH loop [message #81732 is a reply to message #75108] Fri, 12 October 2012 15:40 Go to previous message
Bill Nel is currently offline  Bill Nel
Messages: 31
Registered: October 2010
Member
On Friday, October 12, 2012 5:33:01 PM UTC-4, Dick Jackson wrote:

> IDL> foreach x, myUndefinedNonVariable do print,x
>
> % Variable is undefined: MYUNDEFINEDNONVARIABLE.
>
> Would anyone else agree that with no elements in myUndefinedNonVariable, this should quietly do no iterations?
>
> -Dick

Think about the fun you'd have should you happen to misspell an honest-to-goodness defined variable :-)
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Overlay a coloured boundary on a gray scale image
Next Topic: shading a portion of the graph

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

Current Time: Wed Oct 08 18:38:24 PDT 2025

Total time taken to generate the page: 0.00602 seconds