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.28.135 with SMTP id b7mr13013961pbh.8.1322267010723; Fri, 25 Nov 2011 16:23:30 -0800 (PST) MIME-Version: 1.0 Path: lh20ni18265pbb.0!nntp.google.com!news1.google.com!goblin1!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: anon@att.net Newsgroups: comp.lang.ada Subject: Re: Why constant components are not permitted ? Date: Sat, 26 Nov 2011 00:23:28 +0000 (UTC) Organization: Aioe.org NNTP Server Message-ID: References: <1856c00b-1994-406a-bbb3-73d93785099a@i6g2000vbe.googlegroups.com> <9j8sg4FfjuU1@mid.individual.net> <14efc07c-744c-4f9a-905b-b9e3ad353e55@cc2g2000vbb.googlegroups.com> <9ja2aiFla6U1@mid.individual.net> Reply-To: anon@anon.org NNTP-Posting-Host: PYUJhwNkWu4hKEERNYYB4A.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: news1.google.com comp.lang.ada:19175 Date: 2011-11-26T00:23:28+00:00 List-Id: -- -- To use constant with "record" define record then create an object -- with preset value that contains the key word "constant" -- procedure a is type test_type is record a : integer ; b : string ( 1 .. 4 ) := "this" ; -- default c : string ( 1 .. 10 ) ; end record ; -- tst is a constant record with all values are unchangable tst : constant test_type := test_type ' ( 16#FFFF# , "that", "0123456789" ) ; begin null ; end ; In <9ja2aiFla6U1@mid.individual.net>, Niklas Holsti writes: >On 11-11-25 11:06 , AdaMagica wrote: >> Useful applications for constant components could be (this is what you >> can have in C++): >> >> record -- *not* Ada >> Name: constant String := "James Bond"; >> Id : constant Positive := 007; -- e.g employee number of a company >> other variable components >> end record; > >The original poster specified the constant value in the declaration of >the record *type*, not separately for each record *object*. This is what >I do not understand: what is the use of a value that is the same for all >objects in which it can appear? > >The "type constants" that Ada now provides are the attributes of a type >(tag, size, and so on), as Ludovic pointed out. > >I understand that some would like to have a "write once" kind of record >component that can be given a value once, when a record object is >created, and cannot be changed afterwards. Discriminants are like that >in Ada, but cannot be of arbitrary type. > >-- >Niklas Holsti >Tidorum Ltd >niklas holsti tidorum fi > . @ .