comp.lang.ada
 help / color / mirror / Atom feed
From: vashwath@rediffmail.com (prashna)
Subject: Re: What is happening Here?Totally clueless
Date: 20 Aug 2003 01:34:57 -0700
Date: 2003-08-20T08:34:58+00:00	[thread overview]
Message-ID: <d40d7104.0308200034.5f08f346@posting.google.com> (raw)
In-Reply-To: bhtedu$30am8$1@ID-25716.news.uni-berlin.de

"Nick Roberts" <nickroberts@blueyonder.co.uk> wrote in message news:<bhtedu$30am8$1@ID-25716.news.uni-berlin.de>...
> "prashna" <vashwath@rediffmail.com> 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,



  reply	other threads:[~2003-08-20  8:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-19 13:22 What is happening Here?Totally clueless prashna
2003-08-19 14:36 ` steveo
2003-08-19 15:06 ` Nick Roberts
2003-08-20  8:34   ` prashna [this message]
2003-08-20 20:45     ` Simon Wright
2003-08-20 22:00       ` chris
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox