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

Re: User selectable lower array bound?



Craig Markwardt wrote:

> 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? :-)

From the manual:

>>>>>>>>>>>>>>
Using Arrays as Subscripts:
<snip>

If an element of the subscript array is less than or equal to zero, the
first element of the subscripted variable is selected. If an element of
the subscript is greater than or equal to the last subscript in the
subscripted variable (N, above), the last element is selected. 
<<<<<<<<<<<<<<

Probably a user complained about having to check the bounds of their
array of indices, and RSI added this feature without thinking about the
consistency ramifications... apparently a theme of theirs.

JD