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.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,194f7a105da14a4c X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-08-20 01:34:58 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: vashwath@rediffmail.com (prashna) Newsgroups: comp.lang.ada Subject: Re: What is happening Here?Totally clueless Date: 20 Aug 2003 01:34:57 -0700 Organization: http://groups.google.com/ Message-ID: References: NNTP-Posting-Host: 203.90.112.53 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1061368498 24496 127.0.0.1 (20 Aug 2003 08:34:58 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 20 Aug 2003 08:34:58 GMT Xref: archiver1.google.com comp.lang.ada:41737 Date: 2003-08-20T08:34:58+00:00 List-Id: "Nick Roberts" wrote in message news:... > "prashna" wrote in message > news:d40d7104.0308190522.4b631227@posting.google.com... > > > array1 := (others => 0); > > array1(1..2) := array_local'(others => (2)); > > ^^^^ can anybody what exactly is this?why they > > are not assigning directly to 2 without doing this(Typecast????) > > This is a qualification that it being used, as a special syntactic > construction, as an array aggregate (of a specific subtype). > > > When I execute a constraint error is being raised.Can any body explain > > what is going on here. > > The specific subtype in this case -- array_local -- has length 10, whereas > the destination array -- array1 -- as length 2. When assigning an array > value to an array variable (of the same type but different subtypes), the > value and variable must be of the same length. > > In fact, they do not have to have the same bounds. If they are the same > length but of different bounds, the value 'slides' into the variable (the > variable's bounds do not change). An anonymous array aggregate with > indefinite length (because it contains 'others') automatically assumes the > length of the destination. Thus the following are legal declarations and > statements: > > declare > array2: array_unconstrained(11..20); > subtype array_small is array_unconstrained(1..5); > begin > array1 := array_local'(others => 0); -- slides 1..10 -> 11.20 > array1(1..2) := (others => 2); -- assumes length 2 > array2 := array1; -- slides 1..10 -> 11.20 > array2(12..16) := array_small'(others => 3); -- slides 1..5 -> 12..16 > end; > > > Thanks in advance, > > Hope This Helps. Thanks Roberts, Can you tell what are the other situations where I can use this type of aggregate?Is it that aggregates should be used only for arrays or could it be used for any other types?Please give me link where I can find complete, detailed description of aggregates? Thanks,