From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 12 Aug 93 16:00:30 GMT From: cis.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!darwin.sura .net!aplcen.apl.jhu.edu!ddsdx2.jhuapl.edu!dlc@ucbvax.Berkeley.EDU (Dave Collar d x7468) Subject: Re: Unconstrained arrays Message-ID: <1993Aug12.160030.14389@aplcen.apl.jhu.edu> List-Id: In <9308111528.aa04642@Paris.ics.uci.edu> kanderso@mabillon.ICS.UCI.EDU (Kennet h Anderson) writes: >Hello, > I have declared the following type (DynamicString is an imported type) > type Str_Array is array (Natural range <>) of DynamicString; >Later when I try to declare objects of this type, the compiler likes this > Viewers : str_array(1 .. 6) := (Create("Airspeed_Guage"), > Create("Altimeter_Guage"), > Create("Compass_Guage"), > Create("Horizon_Guage"), > Create("ROC_Guage"), > Create("Turn_Guage")); >but it does not like this > Viewers : str_array(1 .. 1) := (Create("text_artist")); >Here is the error message generated by the SunAda 1.1 compiler >--### A:error: RM 8.3: no visible identifier is of type str_array >If I change the above declaration to > Viewers : str_array(1 .. 2) := (Create("text_artist"), > Create("ignore")); >The compiler is happy again. > Can someone help me out on this? Why can't I declare AND initialize >an array of only one element? You can. the problem is that "Aggregates containing a single component association must always be given in named notation" LRM 4.3(4) So change your declaration to either Viewers : str_array(1..1) := (1 => Create("text_artist")); or Viewers : str_array(1..1) := (others => Create("text_artist")); This rule is required so that the compiler can tell that it is an aggregate. The compiler is not allowed to use any information from within the aggregate to determine the type of aggregate. "An aggregate can always be distinguished from an expression enclosed by parenthesis: this is a consequence of the fact that named notation is required for an aggregate with a single component" LRM 4.3(8) --Thor dlc@ddsdx2.jhuapl.edu