From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,b30ef5c12f872cb8 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.15.41 with SMTP id u9mr9585760pbc.3.1322178801258; Thu, 24 Nov 2011 15:53:21 -0800 (PST) MIME-Version: 1.0 Path: lh20ni14461pbb.0!nntp.google.com!news2.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!news-transit.tcx.org.uk!aioe.org!.POSTED!not-for-mail From: anon@att.net Newsgroups: comp.lang.ada Subject: Re: Why constant components are not permitted ? Date: Thu, 24 Nov 2011 23:53:19 +0000 (UTC) Organization: Aioe.org NNTP Server Message-ID: References: <1856c00b-1994-406a-bbb3-73d93785099a@i6g2000vbe.googlegroups.com> <9dac0cd0-2142-4e2c-b049-3e76a1dcea2c@w1g2000vba.googlegroups.com> Reply-To: anon@anon.org NNTP-Posting-Host: +q2ptVhDdOxRBlnn0NDMZA.user.speranza.aioe.org X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 X-Newsreader: IBM NewsReader/2 2.0 Xref: news2.google.com comp.lang.ada:14616 Date: 2011-11-24T23:53:19+00:00 List-Id: 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 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