comp.lang.ada
 help / color / mirror / Atom feed
From: anon@att.net
Subject: Re: Why constant components are not permitted ?
Date: Thu, 24 Nov 2011 23:53:19 +0000 (UTC)
Date: 2011-11-24T23:53:19+00:00	[thread overview]
Message-ID: <jamlde$2mc$1@speranza.aioe.org> (raw)
In-Reply-To: 9dac0cd0-2142-4e2c-b049-3e76a1dcea2c@w1g2000vba.googlegroups.com


Unlike C which allow constants ("#define") any where a programmer 
chooses. Ada is more structured. Following Ada RM "3.8 Record types" 
there are no constants allowed within a defintion of a record.


RM 3.8 Record Types

  2   record_type_definition ::= [[abstract] tagged] [limited] 
                                 record_definition

  3   record_definition ::=
          record
             component_list
          end record
        | null record

  4   component_list ::=
            component_item {component_item}
         | {component_item} variant_part
         |  null;

  5   component_item ::= component_declaration | representation_clause

  6   component_declaration ::=
         defining_identifier_list : component_definition 
                                       [:= default_expression];

from RM 3.6 Array Type ;

  7   component_definition ::= [aliased] subtype_indication


from RM 3.2.2 Subtype Declarations

  3   subtype_indication ::=  subtype_mark [constraint]

  4   subtype_mark ::= subtype_name


And even though it is not define in the RM BNF a:

      subtype_name ::= simple_name


So, Component_definition does not allow the keyword "constant". So it 
is illegal within the definition of a record.



In <9dac0cd0-2142-4e2c-b049-3e76a1dcea2c@w1g2000vba.googlegroups.com>, David Sauvage <david.sauvage@adalabs.com> writes:
>On 24 nov, 23:06, a...@att.net wrote:
>> =A0 type test is record
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0a : integer :=3D 16#FFFF# ;
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0b : string ( 1 .. 4 ) :=3D "this" ; --=
> is OK
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0c : string :=3D "is" ; -- error becaus=
>e no define boundary
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0end record ;
>>
>> Reason no one ask the ARG.
>
>ok, but the following is also not permitted
>
>type Object is record
>   Tag : constant Positive :=3D 42; -- GNAT compilation failed :
>constant components are not permitted
>end record;
>
>There is something special about constant components, no related to
>unconstrained types in record.
>
>
>Cheers




  parent reply	other threads:[~2011-11-24 23:53 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-24 18:14 Why constant components are not permitted ? David Sauvage
2011-11-24 19:06 ` anon
2011-11-24 19:49   ` David Sauvage
2011-11-24 22:55     ` Georg Bauhaus
2011-11-24 23:53     ` anon [this message]
2011-11-24 19:46 ` Ludovic Brenta
2011-11-25  9:10   ` Dmitry A. Kazakov
2011-11-25 10:23     ` Ludovic Brenta
2011-11-25 10:45       ` Dmitry A. Kazakov
2011-11-25  6:56 ` Niklas Holsti
2011-11-25  9:53   ` Yannick Duchêne (Hibou57)
2011-11-25 10:06     ` AdaMagica
2011-11-25 10:16       ` AdaMagica
2011-11-25 10:56       ` Yannick Duchêne (Hibou57)
2011-11-25 17:41       ` Niklas Holsti
2011-11-26  0:23         ` anon
2011-11-29  4:10         ` Randy Brukardt
2011-11-29  7:55           ` David Sauvage
2011-11-29 10:55             ` Yannick Duchêne (Hibou57)
2011-11-29 11:17             ` Mark Lorenzen
2011-11-26 10:22       ` Pascal Obry
2011-11-26 10:59         ` Dmitry A. Kazakov
2011-11-25  7:03 ` AdaMagica
2011-11-25  9:12 ` Dmitry A. Kazakov
2011-11-25  9:57   ` Yannick Duchêne (Hibou57)
2011-11-25 10:22     ` Dmitry A. Kazakov
2011-11-25 11:00       ` Yannick Duchêne (Hibou57)
replies disabled

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