[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: User selectable lower array bound?





Paul van Delst <paul.vandelst@noaa.gov> writes:

> Hey there,
> 
> Is is just me, or would anyone else find useful the ability to define arrays in IDL such
> that the lower bound is *not* always zero? Sorta like:
> 
>   x = FINDGEN( 11, LOWER = -5 )
> or
>   y = DBLARR( 100, LOWER = 1 )
> 
> so that accessing elements such as x[ -4 ] or y[ 100 ] are o.k.?

Well, as grumpy as I have been in the past about IDL wishes, this is
one thing I do not want to have in IDL now!

As has been pointed out, the issue gets clouded when dealing with
things like WHERE() [btw, <flame>I think that -1 is one of the single
biggest mistakes that IDL has in it<flame>], but also about how such
an array would be passed to other procedures.  Also, IDL has other
ways of indexing arrays, like indexing a 2d array by 1d subscripts.
What would happen then?

For the most part, I find it pretty easy to bite the bullet and say
x[CONST-4] instead of x[4].  

Which brings a gripe of my own to mind.  One tricky problem with
accessing arrays is that accessing out of bounds elements is both
legal and illegal, depending on whether the subscript index is a
scalar or an array.

a[ [-1] ] = 0   ;; Succeeds!
a[  -1  ] = 0   ;; Fails!

What is up with that? :-)

Craig


-- 
--------------------------------------------------------------------------
Craig B. Markwardt, Ph.D.         EMAIL:    craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
--------------------------------------------------------------------------