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 #74016 is a reply to message #73994] Fri, 17 December 2010 09:35 Go to previous message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
On Dec 14, 1:35 pm, Paul van Delst <paul.vande...@noaa.gov> wrote:
> Thinking about it a little more, I think I'm biased against IDL and thus making bad design decisions (sorry!). If there
> was a list "Empty" or "IsEmpty" method (like ruby's "empty?" method...for both arrays/lists and hashes), I would be more
> tempted to use it,
>
>   if ( l.isempty() ) then ...return, handle error, whatever...
>
> as opposed to the current IDL idiom,
>
>   if ( n_elements(l) eq 0 ) then ...return, handle error, whatever...

I just remembered that there is not much need for IsEmpty, as the
lists currently already overload their truth value (to the opposite;
an empty list evaluates to false):

IDL> l=list()
IDL> if (~l) then print,'empty list' else print,'list has
',n_elements(l),' elements'
empty list
IDL> l.add,9
IDL> if (~l) then print,'empty list' else print,'list has
',n_elements(l),' elements'
list has 1 elements

And I find "if (~l) then ..." much more convenient than "if
(l.isempty()) then ...".
[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: Wed Oct 08 17:28:05 PDT 2025

Total time taken to generate the page: 0.24326 seconds