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

Home » Public Forums » archive » Passing optional parameters through a wrapper routine
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: Passing optional parameters through a wrapper routine [message #18916 is a reply to message #18840] Thu, 10 February 2000 00:00 Go to previous messageGo to previous message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
David Fanning <davidf@dfanning.com> wrote in message
news:MPG.130b2251759d7b27989a22@news.frii.com...
> Mark Hadfield (m.hadfield@niwa.cri.nz) writes:
>
> ...
>
> There is nothing wrong with "wrapper" routines passing
> undefined variables. I often do this too, especially
> when I write a wrapper function for an object. But there
> is a difference between the wrapper and the wrappee,
> as it were. :-)

OK, that's been clarified.

> It just better be the case that when the undefined
> variables get to the end of the line that the
> program there knows what to do with them. Mine
> do, because that is how I choose to write them.
> Many of the built-in IDL routines do not. That's
> why they issue "undefined variable" errors.

That's an interesting point David. The first few lines of my routines tend
to look something like this:

if n_elements(arg1) then message, 'You haven't defined arg1'

if size(arg2, /TNAME) ne 'STRING' then message, 'Arg2 must be string
specifying the file name'

OK, I do supply values for undefined arguments when there are sensible
defaults, but my fallback approach to handling bad arguments and other
errors is, if in doubt, stop and call for help. The reasons for this
approach are:

1. Laziness

2. The principle that in scientific programming (as opposed, say, to Web
page programming) it is much better for programs to crash than to continue
and return bad data.

3. The expectation that the person running the routine (usually me) will be
able to work out what to do.

4. It is always possible for the calling routine to CATCH errors and handle
them itself if it thinks it knows better.

I have often thought that I SHOULD put more effort into recovering from
errors gracefully but I have never been sure how to go about this. Perhaps I
should read your book?

---
Mark Hadfield
m.hadfield@niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield/
National Institute for Water and Atmospheric Research
PO Box 14-901, Wellington, New Zealand
[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
Previous Topic: Superscripts in IDL [x-y]title
Next Topic: superscripts

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

Current Time: Fri Oct 10 15:03:28 PDT 2025

Total time taken to generate the page: 0.56085 seconds