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

Home » Public Forums » archive » Re: Most Common IDL Programming Errors
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: Most Common IDL Programming Errors [message #59726 is a reply to message #59724] Wed, 09 April 2008 08:26 Go to previous messageGo to previous message
rigby is currently offline  rigby
Messages: 16
Registered: September 1995
Junior Member
> What would be on your list?

These are my top gotchas:

1) IDL silently truncates array operations to the shorter array.

help, [1,2,3,4] - [1,2]
[0, 0]

(I wish there were a compile_opt switch to prohibit this!0

2) Where() returns a one-element array when there is only one match.

help, where([1,2,3,4] EQ 4)
<Expression> LONG = ARRAY[1]

The combination (1) and (2) is deadly:

array = [1, 2, 3, 4]
j = where(array EQ max(array))
array -= array[j]
print, array
-3

My solution is to use a wrapper around where() which will return a
scalar.

3) Operations which mix signed and unsigned integers can't be trusted.

maxuint = 'ffff'xu
help, maxuint
MAXUINT UINT = 65535
print, fix(1) GT maxuint
1
print, long(1) GT maxuint
0

These results can be understood using IDL's promotion rules for mixed
expressions,
but it's just not worth it. My solution: Never use unsigned integers.

(Why would one use unsigned integers, you might ask? I've done a few
bit-level
simulations of digital hardware using IDL. It would be conceptually
simpler to
use unsigned integer variables to represent unsigned quantities or
signed quantities
where the sign bit is not the left-most bit.)
[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
Read Message
Read Message
Previous Topic: Re: Reading HTML (web) page through socket
Next Topic: Re: delvar, all

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

Current Time: Wed Oct 08 19:31:32 PDT 2025

Total time taken to generate the page: 0.00460 seconds