Robert A. Rosenberg writes:

I have a vague impression that PL/I goes one step further. When you define an array, you define > the lower and upper bounds (l:h) with only upper (ie: number of elements) required. Thus you could define a 10 element array that goes from element 5 to 14. In addition it does bounds checking (this might be optional) with an error being raised if, for example, index<5 or index>14 > gets used to access the above array.

As I noted in an earlier post IBM enterprise PL/I supports

-2^31 <= L <= H <= +2^31 - 1,

i.e.,

-2147483648 <= L <- H <= +2147483647.

Very usefully, it even supports the3 speciual boundary-value case of dynamically allocated empty arrays, e.g.,

declare 1 sda based(sdap),
 2 ls binary fixed(31,0),
 2 hs binary fixed(31,0),
 2 fa binary fixed(31,0)
   dimension(l refer(sda.ls):h refer(sda.hs)) ;

declare (l, h) binary fixed(31,0) ;

h = 0b ;
l = 1b ;
allocate sda set(sdap) ;

which sets sdap->sda.ls equal to 1 and sdap->sda.hs equal, to 0 and allocates no storage for the array sdap->sda.fa. (This construct is, for example, useful when one wishes to put a replaceable [default] empty table in which searches always fail in place.)

The range checking that Rosenberg mentioned is indeed optional. It is enabled by prefixing a single executable statement or a block with

(subscriptrange):

as in

(subscriptrange): m = (l + h)/2 ;

John Gilmore
Ashland, MA 01721-1817
USA

_________________________________________________________________
Share your latest news with your friends with the Windows Live Spaces friends module. http://clk.atdmt.com/MSN/go/msnnkwsp0070000001msn/direct/01/?href=http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mk

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

Reply via email to