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

Home » Public Forums » archive » Re: Pass-By-Reference question.
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: Pass-By-Reference question. [message #38498 is a reply to message #38497] Wed, 10 March 2004 12:13 Go to previous messageGo to previous message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
Christopher Lee wrote:
> In article <405594fa.0403100119.34769176@posting.google.com>, "Tim
> Robishaw" <timrobishaw@yahoo.com> wrote:
>
>> Hi there,
>> I've been using _REF_EXTRA for a long time now and have come to
>> appreciate that values of keywords sent to a module with the _REF_EXTRA
>> mechanism will override any keywords that are set inside the module.
>> Here is a great example: pro whaddup, _REF_EXTRA=_extra
>> plot, [0], [0], /NODATA, XRANGE=[-5,5], YRANGE=[-5,5], PSYM=4,
>> _EXTRA=_extra
>> end
>> IDL> whaddup
>> I see what the module asked for: axes from -5 to 5 with no datum
>> plotted.
>> Now I can override the XRANGE and YRANGE keyword values by passing them
>> by reference...
>> IDL> whaddup, XRANGE=[-1,1], YRANGE=[-1,1] I see what I asked for: axes
>> from -1 to 1. However, if I send NODATA set to ZERO, i.e., I'd really
>> like to see my datum this time...
>> IDL> whaddup, XRANGE=[-1,1], YRANGE=[-1,1], NODATA=0 I don't get what I
>> asked for. The value for NODATA sent by reference does not override the
>> value set inside the module. This is also true for the /NOERASE
>> keyword.
>
> Hi,
>
> IDL> plot, findgen(10), nodata=1
> IDL> plot, findgen(10), nodata=1,nodata=0
> % Duplicate keyword NODATA in call to: PLOT
> % Execution halted at: $MAIN$
> IDL> e={nodata:0}
> IDL> plot, findgen(10), nodata=1,_EXTRA=e
>
> Duplicate keywords give IDL no chance of knowing what to do, hence it
> complains, and it only looks in the _EXTRA struct if it doesn't find what
> it wants elsewhere.

Not so. As Tim said, keywords passed in via inheritance override
keywords supplied explicitly. This is a very useful feature and
virtually all of my code relies on it.

In previous versions of IDL there have been glitches in IDL's
implementation of keyword precedence (for a while it worked with
value-inheritance but not reference-inheritance) but it has worked the
way I describe since (I think) 5.4 or 5.5. There have been extensive,
confusing discussions about this on the newsgroup in the past.

> If you want an option of overriding the nodata
> keyword, you need to look for it first, hence
>
> pro whaddup, nodata=nodata,_REF_EXTRA=_extra
>
> nodata_internal = 0
> if(arg_present(nodata)) then nodata_internal=nodata > 0 < 1
>
> plot, [0], [0], NODATA=nodata_internal, XRANGE=[-5,5], YRANGE=[-5,5], PSYM=4,
> _EXTRA=_extra
>
> end

Having inherited keywords override explicit keywords avoids the need for
all this and allows much cleaner code.

As to why Tim's example works for XRANGE & YRANGE but not NODATA, I have
no idea. Perhaps you are not really doing what you think you are doing.


--
Mark Hadfield "Ka puwaha te tai nei, Hoea tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)

*****
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
Gratuitous text added to subvert silly news server restrictions.
[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
Previous Topic: IDL online help for v6.0 (sigh)
Next Topic: Re: Pass-By-Reference question. (ARG_PRESENT)

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

Current Time: Fri Nov 28 22:01:52 PST 2025

Total time taken to generate the page: 1.36170 seconds