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, 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 Received: by 10.68.39.100 with SMTP id o4mr14912572pbk.0.1322305162614; Sat, 26 Nov 2011 02:59:22 -0800 (PST) Path: lh20ni19894pbb.0!nntp.google.com!news2.google.com!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Why constant components are not permitted ? Date: Sat, 26 Nov 2011 11:59:26 +0100 Organization: cbb software GmbH Message-ID: <11tnq3hinw2vk.14uei46b2un4l$.dlg@40tude.net> References: <1856c00b-1994-406a-bbb3-73d93785099a@i6g2000vbe.googlegroups.com> <9j8sg4FfjuU1@mid.individual.net> <14efc07c-744c-4f9a-905b-b9e3ad353e55@cc2g2000vbb.googlegroups.com> <4ED0BDEB.9030002@obry.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: FNjoArF0+I5Es1qmRVQoqw.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news2.google.com comp.lang.ada:14663 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Date: 2011-11-26T11:59:26+01:00 List-Id: On Sat, 26 Nov 2011 11:22:35 +0100, Pascal Obry wrote: > Le 25/11/2011 11:06, AdaMagica a �crit : >> 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; >> >> In Ada, you hide the components (private record), define a constructor >> function providing the values for the constant items and provide only >> read operations for them. > > But why on earth do you want a field in a record with the same value for > all objects of this type? record -- This is not Ada! Name : constant Unbounded_String := Read (File); Of course it should be possible to initialize constant fields upon object construction: record -- This is not Ada! Name : constant Unbounded_String; -- Deferred until construction Also don't forget constant views of fields which are privately non-constant. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de