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.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,165d3eeae8b654b6 X-Google-Attributes: gid103376,public From: Stephen Leake Subject: Re: constant record components in Ada Date: 1997/06/27 Message-ID: <33B43005.268C@gsfc.nasa.gov>#1/1 X-Deja-AN: 253049146 References: <5p100i$pvn@sutton.cs.columbia.edu> Organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA Reply-To: Stephen.Leake@gsfc.nasa.gov Newsgroups: comp.lang.ada Date: 1997-06-27T00:00:00+00:00 List-Id: Alexander V. Konstantinou wrote: > > I am trying to obtain in Ada (95) the same functionality of the C++ struct > declaration : > > struct map_pair { > const Key_Type first; > Value_Type second; > } > > The idea is to provide a record in which the key value is constant, and the > value type is mutable. The Ada books I have looked at suggest using > discriminants. Unfortunately, discriminants have to be either discrete or > access types. In my case Key_Type is a generic parameter and restricting it > to be a discrete type is too restrictive. Why is a discrete type too restrictive? Discrete types include integer types and enumeration types; what other types are appropriate for keys? Maybe fixed length strings? >On the other hand, making the > discriminant a pointer is in my view an ugly solution since it keeps that > extra pointer around. > > Any ideas on how to tackle this ? You could define a limited type to hold the key; then users could not change it. > > Alexander V. Konstantinou > -- > Alexander V. Konstantinou http://www.cs.columbia.edu/~akonstan/ > akonstan@cs.columbia.edu akonstan@acm.org -- - Stephe