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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1108a1,c7b637f8b783b7c X-Google-Attributes: gid1108a1,public X-Google-Thread: 109fba,c7b637f8b783b7c X-Google-Attributes: gid109fba,public X-Google-Thread: f43e6,c7b637f8b783b7c X-Google-Attributes: gidf43e6,public X-Google-Thread: 107d55,c7b637f8b783b7c X-Google-Attributes: gid107d55,public X-Google-Thread: 103376,c7b637f8b783b7c X-Google-Attributes: gid103376,public X-Google-Thread: fac41,c7b637f8b783b7c X-Google-Attributes: gidfac41,public From: Samuel Mize Subject: Re: The great Java showcase (re: 2nd historic mistake) Date: 1997/08/29 Message-ID: <34072CEE.753@link.com>#1/1 X-Deja-AN: 268954843 References: <34023FC9.59E2B600@eiffel.com> Organization: Hughes Training Inc. Reply-To: smize@link.com Newsgroups: comp.object,comp.software-eng,comp.lang.ada,comp.lang.eiffel,comp.lang.java.tech,comp.lang.c++ Date: 1997-08-29T00:00:00+00:00 List-Id: Patrick Doyle wrote: > > In article , > Laurent Guerby wrote: > >doylep@ecf.toronto.edu (Patrick Doyle) writes: > > > > Ada has the ability to manipulate unconstrained objects (something > >like returning dynamic sized objects/arrays) without requiring user > >heap management. The greatly obviates the need for user > >allocation/deallocation, you can write very large Ada programs without > >doing fine grained heap management (and I agree with you, very error > >prone unless you're some kind of programming deity ;-). > > I'm not sure I follow the Ada approach. How do these "unconstrained > objects" work? Here's a very brief discussion (since this thread is so cross- posted). For more info, see the tutorials at www.adahome.com. An Ada object must be constrained (have a definite size) when it exists. However, you can define a type that is not constrained. Each object of that type gets its constraints when created. If a procedure parameter is unconstrained, it gets its constraints from the value given when the procedure is called. Here's a concrete example: declare -- Define an integer-indexed array of characters. We do NOT -- define the min or max indexes, or the size of the array. type Flex_Array is array (integer range <>) of character; A, B: Natural; -- integers greater than or equal to zero procedure X (F: in Flex_Array); begin -- get values for A and B somehow ... declare Flex_A: Flex_Array (1..A); Flex_B: Flex_Array (3..B); begin X (Flex_A); X (Flex_B); end; end; Where Flex_A and Flex_B exist, they have well-defined sizes. However, these sizes are defined at run time. In the first call to X, F'First (the first array index) will be 1. In the second call to X, F'First will be 3. If B is less than 3, Flex_B is a null array, which is perfectly fine in Ada. Sam Mize