From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f891f,9d58048b8113c00f X-Google-Attributes: gidf891f,public X-Google-Thread: 10cc59,9d58048b8113c00f X-Google-Attributes: gid10cc59,public X-Google-Thread: 1014db,9d58048b8113c00f X-Google-Attributes: gid1014db,public X-Google-Thread: 103376,2e71cf22768a124d X-Google-Attributes: gid103376,public From: James_Rogers Subject: Re: next "big" language?? (disagree) Date: 1996/06/11 Message-ID: <4pk9q9$a9j@ss2.cs.mci.com>#1/1 X-Deja-AN: 159664671 references: <4p3nqb$k4a@btmpjg.god.bel.alcatel.be> <4p3nto$k4a@btmpjg.god.bel.alcatel.be> <4pj7e0$fat@goanna.cs.rmit.EDU.AU> content-type: text/plain; charset=us-ascii organization: MCI Telecommunications Colorado Springs, CO x-url: news:4pj7e0$fat@goanna.cs.rmit.EDU.AU mime-version: 1.0 newsgroups: comp.lang.ada,comp.lang.pascal,comp.lang.c,comp.lang.misc x-mailer: Mozilla 1.12 (X11; I; AIX 2) Date: 1996-06-11T00:00:00+00:00 List-Id: rav@goanna.cs.rmit.EDU.AU (++ robin) wrote: > Are you seriusly suggesting that EACH time the program >is run that it be edited and recompiled? And what >happens -- as is often the case -- the size of the array >changes DURING the run? Now you are approaching the real problem. Arrays are must always have a specific size. That size may be defined at compile time or it may be det4rmined at run time using dynamic allocation. Either way a given instance of an array does not change its size. If this is not enough reason to use some other more dynamic data structure such as a list or a tree, then the common methods used with arrays include the concept of declaring a size which is the largest expected for current needs. A subset of that array is typically used for the problem at hand, wasting the remainder for future growth. The point is that every array must be accompanied by some method of indicating the specific subset of elements to be processed. In C this means one typically either passes an array pointer and a size parameter, or a special character is expected to be embedded in the array to mark the end of useful data ( the NULL character, for instance). Ada allows a parameter to be expressed as an unconstrained array. This means any size (within system limits) of array may be passed as a parameter. The array attributes 'First, 'Last, 'Range can then be used to traverse the array passed to the subprogram. Now, you ask, how does a calling subprogram pass a specific array to the subprogram expecting an unconstrained array. Ada allows you to pass a slice of an array. For instance, if your predefined array is defined as: example : array (1..10000) of integer; and you want to pass elements 23 through 413 to a function producing a total which uses an unconstrained array parameter, the following syntax is used: Total := sum(example(23..413)); In this case elements 23 through 413 are passed to function "sum". Funciton "sum" sees an array of integer with 'First mapping to element 23 of array example. No recompilation is necessary to change the slice sent to the function. All that is necessary is to use variables in the slice syntax, instead of constants as shown in the above example. -- Jim Rogers ********************************************* I would not say that my mind is filled with useless information. The information is, however, amazingly inappropriate in most circumstances.