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

Home » Public Forums » archive » More LIST weirdness?
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
More LIST weirdness? [message #73980] Tue, 14 December 2010 11:55
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Hello,

Based on the other thread about list access errors, does the following make sense to anyone:

IDL> q = list()
IDL> help, q
Q LIST <ID=1 NELEMENTS=0>
IDL> help, q[0]
<Expression> UNDEFINED = !NULL
IDL> help, q[1]
<Expression> UNDEFINED = !NULL
IDL> help, q[2]
<Expression> UNDEFINED = !NULL
IDL> x=q[5]
IDL> help, x
X UNDEFINED = !NULL

??

I was expecting the "index out of range" type of error. Or e.g.

IDL> y=q[*]
% Illegal subscript range.
% Error occurred at: LIST::_OVERLOADBRACKETSRIGHTSIDE
% $MAIN$
% Execution halted at: $MAIN$

Now I'm confused. Removing an item causes the "LIST::REMOVE: Index is out of range" error. Why wouldn't simply accessing
an invalid index do a similar thing? The behaviour seems inconsistent. Or am I?

I guess the lesson is to always check the list length before removing from it, or referencing in it. That way there is
no special case and if/when ITTVIS changes the behaviour, no harm done. Right?

cheers,

paulv
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: GRID3
Next Topic: Re: More LIST weirdness?

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

Current Time: Wed Oct 08 17:31:23 PDT 2025

Total time taken to generate the page: 0.00594 seconds