comp.lang.ada
 help / color / mirror / Atom feed
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
Date: 12 Aug 93 16:00:30 GMT	[thread overview]
Message-ID: <1993Aug12.160030.14389@aplcen.apl.jhu.edu> (raw)

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 

             reply	other threads:[~1993-08-12 16:00 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-08-12 16:00 Dave Collar d x7468 [this message]
  -- strict thread matches above, loose matches on Subject: below --
2009-03-17  0:59 Unconstrained Arrays belteshazzar
2009-03-17  1:49 ` Jeffrey R. Carter
2009-03-17  2:58   ` belteshazzar
2009-03-17  4:15     ` Jeffrey Creem
2009-03-17  5:20     ` Jeffrey R. Carter
2009-03-17 17:56       ` Jeffrey R. Carter
2009-03-17 23:10         ` belteshazzar
2009-03-18 18:31           ` Jeffrey R. Carter
2009-03-20  1:53           ` Peter C. Chapin
2009-03-20  6:45             ` sjw
2009-03-20  9:46               ` Jacob Sparre Andersen
2009-03-20 11:40               ` Jean-Pierre Rosen
2009-03-25 21:11                 ` sjw
2009-03-25 22:30                   ` Robert A Duff
2009-03-25 23:28                     ` Randy Brukardt
2009-03-26  0:03                       ` Jeffrey R. Carter
2009-03-26  1:00                         ` Robert A Duff
2009-03-20 12:15               ` christoph.grein
2009-03-20 15:45               ` Adam Beneschan
2009-03-23  8:26                 ` belteshazzar
2009-03-25 21:21                 ` sjw
2009-03-25 22:03                   ` Adam Beneschan
2009-03-26  1:32                     ` tmoran
2009-03-27  8:39                   ` Jean-Pierre Rosen
2009-03-27 20:07                     ` sjw
2009-03-29 16:24                     ` sjw
2009-03-27 11:57                   ` Gautier
2009-03-17 15:33     ` Adam Beneschan
2009-03-17 23:00       ` belteshazzar
2009-03-17 20:14 ` anon
2001-12-11 17:17 Unconstrained arrays Michael Unverzagt
2001-12-11 18:22 ` Stephen Leake
2001-12-11 18:24 ` Mark Lundquist
1993-08-15  5:01 Alex Blakemore
1993-08-13 21:08 J. Craig Heberle
1993-08-13 12:34 Paul Durbin
1993-08-12 21:23 Robert Dewar
1993-08-12 19:25 Wes Groleau x1240 C73-8
1993-08-12 17:27 agate!howland.reston.ans.net!math.ohio-state.edu!magnus.acs.ohio-state.ed
1993-08-12 16:26 Mark A Biggar
1993-08-12 15:28 Robert I. Eachus
1993-08-12 15:00 Robert Dewar
1993-08-12 13:03 Raymond Blaak
1993-08-12 12:14 cis.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!howland.
1993-08-12 12:03 cis.ohio-state.edu!pacific.mps.ohio-state.edu!math.ohio-state.edu!magnus.
1993-08-11 23:42 Kenneth Anderson
1993-08-11 23:40 cis.ohio-state.edu!math.ohio-state.edu!cs.utexas.edu!swrinde!menudo.uh.ed
1993-08-11 22:29 Kenneth Anderson
replies disabled

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