Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
I also get the temporary variables stuff, and agree that things like foreach el,!null do print,el foreach el,[] do print,el foreach el,{} do print,el Should all do nothing, with no errors. But if foreach is given a named variable that is !null it does nothing as expected: IDL> n=!null IDL> foreach el,n do print,el IDL> On Feb 14, 9:47 pm, Michael Galloy <mgal...@gmail.com> wrote: > 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
On 2/14/11 8:08 pm, Paulo Penteado wrote: > > I also get the temporary variables stuff, and agree that things like > > foreach el,!null do print,el > foreach el,[] do print,el > foreach el,{} do print,el > > Should all do nothing, with no errors. > > But if foreach is given a named variable that is !null it does nothing > as expected: > > IDL> n=!null > IDL> foreach el,n do print,el Even more interesting: IDL> print, !version { x86_64 darwin unix Mac OS X 8.0.1 Oct 5 2010 64 64} IDL> groups = !null IDL> foreach g, groups do help, g But: IDL> print, !version { x86_64 linux unix linux 8.0 Jun 18 2010 64 64} IDL> groups = !null IDL> foreach g, groups do help, g % Variable is undefined: GROUPS. % Execution halted at: $MAIN$ This must be a fix in 8.0.1. I will do some more research, but sheds some light on the original situation that was causing me some problems debugging. Mike -- www.michaelgalloy.com Research Mathematician Tech-X Corporation
> On 2/14/11 8:08 pm, Paulo Penteado wrote: >> >> I also get the temporary variables stuff, and agree that things like >> >> foreach el,!null do print,el >> foreach el,[] do print,el >> foreach el,{} do print,el >> >> Should all do nothing, with no errors. >> >> But if foreach is given a named variable that is !null it does nothing >> as expected: >> >> IDL> n=!null >> IDL> foreach el,n do print,el Those examples are good, but today I realize I'd really like this to work (quietly do no iterations) if I use an undefined variable (such as an unfilled keyword variable): IDL> foreach x, myUndefinedNonVariable do print,x % Variable is undefined: MYUNDEFINEDNONVARIABLE. % Execution halted at: $MAIN$ Would anyone else agree that with no elements in myUndefinedNonVariable, this should quietly do no iterations? Cheers, -Dick