comp.lang.ada
 help / color / mirror / Atom feed
From: agate!howland.reston.ans.net!europa.eng.gtefsd.com!news.ans.net!newsgate. watson.ibm.com!yktnews.watson.ibm.com!ncohen@ucbvax.Berkeley.EDU  (Norman H. Co
Subject: Re: Forcing default representations
Date: 26 Jul 93 15:12:17 GMT	[thread overview]
Message-ID: <CAs28H.51J@yktnews.watson.ibm.com> (raw)

In article <9307201257.AA00575@eight-ball.boeing.com>,
crispen@eight-ball.boeing.com (Bob Crispen) writes: 

|> Adam Beneschan queries the legality of the following: 
|>
|> >      type One_Byte is range 0..7;
|> >      type Four_Bytes is range 0..31;
|>
|> >      for Landing_Gear_Parameters use
|> >       record
|> >         Position   at 0 range Four_Bytes;
|> >         State      at 4 range One_Byte;
|> >       end record;
|>
|> and another correspondent who hasn't given me permission to quote
|> him says that his Alsys Ada compiler won't compile the code above,
|> while all 3 of my VADS compilers (of different vintages, and for
|> different targets) will.

As other correspondents have pointed out, the syntax rules in RM 13.4(2)
and 3.5(2) make it clear that this should be rejected, and AI-00498
forbids even

      0 range Four_Bytes'Range

on the grounds that 'Range is not a static attribute.  (This
attribute will be static in Ada 9X--see 4.9(25) of Ada 9X RM draft
3.0--but the syntax of a component clause is changed to

   component_clause_component_name at position range first_bit .. last_bit;

where first_bit and last_bit are static simple expressions, so the
component clause above will be forbidden in Ada 9Xfor a different
reason.)

|> What I had in mind of course was analogous to the universal practice: 
|>
|>      type Colors is (Mauve, Puce, Ultraviolet);
|>      for Each_Color in Colors loop
|>
|>
|> "in Colors" being shorthand for "in Colors'first..Colors'last".  I
|> believe every Ada compiler accepts this, but I can't find the
|> LRM entry that says where it has to.  Probably right under my nose.

The syntax of a loop parameter specification in a for loop (RM 5.5(2))
calls for a "discrete_range", which is different from a "range".  A
"discrete_range" can be either a "subtype_indication" or a "range"
(RM 3.6(2)) and a "subtype_indication" is a type mark (like Colors)
optionally followed by a constraint (RM 3.3.2(2)).

--
Norman H. Cohen    ncohen@watson.ibm.com

             reply	other threads:[~1993-07-26 15:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-07-26 15:12 agate!howland.reston.ans.net!europa.eng.gtefsd.com!news.ans.net!newsgate.watson.ibm.com!yktnews.watson.ibm.com!ncohen [this message]
  -- strict thread matches above, loose matches on Subject: below --
1993-07-30 12:00 Forcing default representations Bob Gilbert
1993-07-30  1:15 pipex!warwick!zaphod.crihan.fr!univ-lyon1.fr!scsing.switch.ch!epflnews!di
1993-07-26 18:30 Robert I. Eachus
1993-07-24 21:16 Erik Magnuson
1993-07-24 17:13 pipex!sunic!news.funet.fi!funic!news.eunet.fi!prime!mits!rkaivola
1993-07-23 19:15 Gary Morris @ignite
1993-07-22 18:34 Bob Crispen
1993-07-20 12:57 Bob Crispen
1993-07-19 16:56 Adam Beneschan
1993-07-16 22:26 dog.ee.lbl.gov!overload.lbl.gov!agate!howland.reston.ans.net!noc.near.net
1993-07-13 19:22 crispen
replies disabled

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