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

Home » Public Forums » archive » Re: LIST "bug": .Remove on an empty list
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: LIST "bug": .Remove on an empty list [message #73999 is a reply to message #73994] Mon, 13 December 2010 19:18 Go to previous messageGo to previous message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
On Dec 13, 7:48 pm, Paul van Delst <paul.vande...@noaa.gov> wrote:
> But I got the "LIST::REMOVE: Index is out of range" error instead. I'm still trying to figure out how to best handle it
> (it does make using lists a little bit more complicated). The HASH remove method works as I expected:
>
> IDL> h=hash("a", 3.14)
> IDL> help, h
> H               HASH  <ID=1  NELEMENTS=1>
> IDL> help, h.remove()
> <Expression>    FLOAT     =       3.14000
> IDL> help, h.remove()
> <Expression>    UNDEFINED = !NULL

Besides the bad error message for list::remove(), I would say that the
bug is in hash::remove(). Unless I am missing something, it should
throw an error on an empty hash. Returning !null with no errors makes
the empty list/hash look like it has elements (which happen to have !
null as a value).

For instance,

IDL> l=list(length=1)
IDL> help,l.remove()
<Expression> UNDEFINED = !NULL
IDL> help,l.remove()
% LIST::REMOVE: Index is out of range.
% Error occurred at: LIST::REMOVE
% $MAIN$
% Execution halted at: $MAIN$

If the second remove() returned !null without errors, it would have
looked like the first call, which was properly returning (and
removing) the !null which was the list element. List is doing things
properly, it is hash that is confusing:

IDL> h=hash('a')
IDL> help,h
H HASH <ID=1 NELEMENTS=1>
IDL> help,h.remove()
<Expression> UNDEFINED = !NULL
IDL> help,h
H HASH <ID=1 NELEMENTS=0>
IDL> help,h.remove()
<Expression> UNDEFINED = !NULL
[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
Read Message
Read Message
Read Message
Previous Topic: LIST performance
Next Topic: LIST "bug": .Remove on an empty list

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

Current Time: Sun Oct 12 00:09:30 PDT 2025

Total time taken to generate the page: 1.92212 seconds