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

Home » Public Forums » archive » Re: check for duplicate routine names?
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: check for duplicate routine names? [message #23254 is a reply to message #23253] Fri, 19 January 2001 08:52 Go to previous messageGo to previous message
Liam E. Gumley is currently offline  Liam E. Gumley
Messages: 378
Registered: January 2000
Senior Member
Craig Markwardt wrote:
> Another thing that would be nice is warnings about ambiguous uses of
> variables that might shadow a function in the library. Note this
> code:
>
> max = max(x, min=min)
>
> The next time you use min(x), will you get the function or the
> variable named min?
>
> You might say, "oh, I used square brackets, this is not a problem,"
> but since round parenthesis are still allowed (unless you disable
> them), I believe this can still be a problem. This has bitten me a
> *few* times, so I'm not saying it's a huge deal. It is a compile time
> issue since peoples' function libraries are different.

I believe a function takes precedence over an identically named array
subscripted with parentheses, e.g.

IDL> min = indgen(10)
IDL> a = indgen(5)
IDL> print, min(a)
0

Using square brackets eliminates the ambiguity between the function name
and the variable name:

IDL> print, min[a]
0 1 2 3 4

If you want to check whether a built-in or library function already
exists with a certain name (such as 'MIN'), first check the online help:

IDL> ? min

If it's not found there, perhaps there is a library function named
min.pro, and you could try compiling it:

IDL> .compile min

The only remaining possibility (I think) is that a function or procedure
with the same name is buried inside some other procedure or function yet
to be compiled. In any case, using square brackets for array
subscripting helps minimize name-space problems.

Cheers,
Liam.
htp://cimss.ssec.wisc.edu/~gumley
[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
Previous Topic: IDL and basic stable! widgets [Example program??]
Next Topic: Re: Printf and line breaks

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

Current Time: Sun Oct 12 06:42:24 PDT 2025

Total time taken to generate the page: 1.75981 seconds