[M3devel] index array by longint?

Rodney M. Bates rodney_bates at lcwb.coop
Sun Jan 10 03:54:51 CET 2010


When writing my original proposal, I agonized at length over whether
to allow (subranges of) LONGINT to be the index type of an array type.  In the
end, I decided that gave a poor ratio of practical benefit to language
and implementation complexity.

However, note, from 2.6.3, "Designators,

"a[i]
     denotes the (i + 1 - FIRST(a))-th element of the array a. The expression a[i] is a
     designator if a is, and is writable if a is. The expression i must be assignable
--------------------------------------------------------------------------^
     to the index type of a. The type of a[i] is the element type of a."

So, by existing rules about assignability, when referring to an element of an
array, the subscript expression could have base type LONGINT, and would just
be "assigned" in the usual way to the index type, a subrange of INTEGER.
This is one of the dozen or so places assignability is used in the language.



Jay K wrote:
> Index array by longint?
> With runtime check that it is <= LAST(INTEGER)?
>   Or really, with runtime bounds check against the array size.
>  
> Seems reasonable?
> Aids the rd/wr change.
> A little bit of pain to implement..unless INTEGER and LONGINT have a 
> common base...
>  
>  
>  - Jay
> 
> 
> 
> 
> 



More information about the M3devel mailing list