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

Home » Public Forums » archive » Re: More LIST weirdness?
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: More LIST weirdness? [message #73978 is a reply to message #73977] Tue, 14 December 2010 12:06 Go to previous messageGo to previous message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
On Dec 14, 5:55 pm, Paul van Delst <paul.vande...@noaa.gov> wrote:
> 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?

That did surprise me. I was expecting it to throw an error, just as
hash does for an inexistent key. By the way, assigning to an
inexistent list element does throw an error, as it should.

So to me there seems to be a bug in hash::remove() and in
list::_overloadbracketsrightside(), as both should be throwing errors
instead of silently returning !null. The reason is, as I wrote in the
other thread, that a list/hash having !null elements is not the same
as one having no elements (or just not having the element specified by
the index/key) .That is the whole reason for the length argument in
list::init(), and hash::init() assigning !null to elements when only
keys are passed.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: More LIST weirdness?
Next Topic: Re: Widget not rendering properly

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

Current Time: Fri Oct 10 09:49:58 PDT 2025

Total time taken to generate the page: 0.07912 seconds