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

Home » Public Forums » archive » Re: Order of argument evaluation (Was: Re: making a checkerboard array?)
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: Order of argument evaluation (Was: Re: making a checkerboard array?) [message #56016 is a reply to message #56014] Wed, 26 September 2007 06:17 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Allan Whiteford writes:

> For a more reasonable example am I allowed to do:
>
> plot,(x=findgen(11)),x^2
>
> and rely on the first argument of plot being evaluated before the second
> argument (and the side effect of creating 'x') similarly for creating an
> array and editing in place, e.g.:
>
> IDL> ((a=fltarr(3)))[1]=10
> IDL> print,a
> 0.00000 10.0000 0.00000
>
> Does anyone else do this or just me? I tend to only do things like this
> at the command line and don't embed it in programs out of fear that
> it's going to stop working one day. It also arguably makes the code less
> readable but as a pattern it's probably not that bad. I'd like to know
> what others think.

Parentheses have the highest order of precedence, so what
is inside them always gets done first. Since what is inside
them in these cases is a variable creation, I can't see how
you could possibly be breaking any rules, and the construction
seems legitimate to me.

That said, I am generally in the business of writing
understandable code (as opposed to JD, for example, whose
business is to write elegant code), and I can just imagine
the number of students and clients who will be left scratching
their heads over this kind of syntax. Might as well write the
darn thing is LISP to start with!

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: create geotiff
Next Topic: Re: selection box in widget program

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

Current Time: Fri Oct 10 17:17:00 PDT 2025

Total time taken to generate the page: 1.59780 seconds