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 #59723 is a reply to message #59721] Wed, 09 April 2008 10:11 Go to previous messageGo to previous message
brodzik@nsidc.org is currently offline  brodzik@nsidc.org
Messages: 7
Registered: July 2005
Junior Member
On Apr 8, 6:13 pm, David Fanning <n...@dfanning.com> wrote:


> beer in the house again, and it occurred to me that I should
> have a page listing the 10 or 15 most common IDL programming
> errors with their solutions. But I can only think of three.
>
> Here are the three errors I most commonly see in IDL programs.

Using the assignment operator '=' instead of comparison 'eq' in a
conditional test.

One way to be defensive about this is to be in the habit of putting
the constant value
on the left side, so the compiler catches the syntax error long before
runtime.
For example, this will fail the conditional, but happily reassign the
value of a to 0:

IDL>
a=5
IDL> if ( a = 0 ) then print,
'OK'
IDL>
print,a
0

Also a bit of a bear to debug, depending on the conditional
consequences, and how
important it is for a to stay 5...

Whereas this will let the compiler find the problem long before you
run it:

IDL>
a=5
IDL> if ( 0 = a ) then
print,'OK'

if ( 0 = a ) then
print,'OK'

^
% Syntax
error.
IDL>

On the other hand, my coworkers *hate* reading my
"backwards comparison" style, so if you adopt this style,
you'll get a lot of odd looks at walkthroughs.

MJ
[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: Thu Oct 09 15:21:26 PDT 2025

Total time taken to generate the page: 0.88359 seconds